Tabnine Logo
Class.getAnnotations
Code IndexAdd Tabnine to your IDE (free)

How to use
getAnnotations
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getAnnotations (Showing top 20 results out of 5,814)

origin: spring-projects/spring-framework

/**
 * Create a new {@link StandardAnnotationMetadata} wrapper for the given Class,
 * providing the option to return any nested annotations or annotation arrays in the
 * form of {@link org.springframework.core.annotation.AnnotationAttributes} instead
 * of actual {@link Annotation} instances.
 * @param introspectedClass the Class to introspect
 * @param nestedAnnotationsAsMap return nested annotations and annotation arrays as
 * {@link org.springframework.core.annotation.AnnotationAttributes} for compatibility
 * with ASM-based {@link AnnotationMetadata} implementations
 * @since 3.1.1
 */
public StandardAnnotationMetadata(Class<?> introspectedClass, boolean nestedAnnotationsAsMap) {
  super(introspectedClass);
  this.annotations = introspectedClass.getAnnotations();
  this.nestedAnnotationsAsMap = nestedAnnotationsAsMap;
}
origin: junit-team/junit4

/**
 * Returns the annotations on this class
 */
public Annotation[] getAnnotations() {
  if (clazz == null) {
    return new Annotation[0];
  }
  return clazz.getAnnotations();
}
origin: google/j2objc

/**
 * Returns the annotations on this class
 */
public Annotation[] getAnnotations() {
  if (fClass == null) {
    return new Annotation[0];
  }
  return fClass.getAnnotations();
}
origin: lets-blade/blade

public Annotation[] getAnnotations() {
  return clazz.getAnnotations();
}
origin: lets-blade/blade

public Annotation[] getAnnotations() {
  return clazz.getAnnotations();
}
origin: prestodb/presto

private static boolean shouldUseFileSplitsFromInputFormat(InputFormat<?, ?> inputFormat)
{
  return Arrays.stream(inputFormat.getClass().getAnnotations())
      .map(Annotation::annotationType)
      .map(Class::getSimpleName)
      .anyMatch(name -> name.equals("UseFileSplitsFromInputFormat"));
}
origin: libgdx/libgdx

/** Returns an array of {@link Annotation} objects reflecting all annotations declared by the supplied class, and inherited
 * from its superclass. Returns an empty array if there are none. */
static public Annotation[] getAnnotations (Class c) {
  java.lang.annotation.Annotation[] annotations = c.getAnnotations();
  Annotation[] result = new Annotation[annotations.length];
  for (int i = 0; i < annotations.length; i++) {
    result[i] = new Annotation(annotations[i]);
  }
  return result;
}
origin: libgdx/libgdx

/** Returns an array of {@link Annotation} objects reflecting all annotations declared by the supplied class, and inherited
 * from its superclass. Returns an empty array if there are none. */
static public Annotation[] getAnnotations (Class c) {
  java.lang.annotation.Annotation[] annotations = c.getAnnotations();
  Annotation[] result = new Annotation[annotations.length];
  for (int i = 0; i < annotations.length; i++) {
    result[i] = new Annotation(annotations[i]);
  }
  return result;
}
origin: com.google.inject/guice

 @Override
 public Boolean load(Class<? extends Annotation> annotationType) {
  for (Annotation annotation : annotationType.getAnnotations()) {
   if (annotationTypes.contains(annotation.annotationType())) {
    return true;
   }
  }
  return false;
 }
};
origin: jersey/jersey

private boolean isEjbComponent(Class<?> component) {
  for (Annotation a : component.getAnnotations()) {
    if (EjbComponentAnnotations.contains(a.annotationType().getName())) {
      return true;
    }
  }
  return false;
}
origin: oblac/jodd

/**
 * Returns {@code true} if type is a Kotlin class.
 */
public static boolean isKotlinClass(final Class type) {
  final Annotation[] annotations = type.getAnnotations();
  for (Annotation annotation : annotations) {
    if (annotation.annotationType().getName().equals("kotlin.Metadata")) {
      return true;
    }
  }
  return false;
}
origin: junit-team/junit4

/**
 * Create a <code>Description</code> named after <code>testClass</code>
 *
 * @param testClass A {@link Class} containing tests
 * @return a <code>Description</code> of <code>testClass</code>
 */
public static Description createSuiteDescription(Class<?> testClass) {
  return new Description(testClass, testClass.getName(), testClass.getAnnotations());
}
origin: google/j2objc

/**
 * Create a <code>Description</code> named after <code>testClass</code>
 *
 * @param testClass A {@link Class} containing tests
 * @return a <code>Description</code> of <code>testClass</code>
 */
public static Description createSuiteDescription(Class<?> testClass) {
  return new Description(testClass, testClass.getName(), testClass.getAnnotations());
}
origin: junit-team/junit4

protected Annotation[] classAnnotations() {
  return testClass.getJavaClass().getAnnotations();
}
origin: google/j2objc

protected Annotation[] classAnnotations() {
  return fTestClass.getJavaClass().getAnnotations();
}
origin: junit-team/junit4

private <T extends Annotation> T findDeepAnnotation(
    Annotation[] annotations, Class<T> annotationType, int depth) {
  if (depth == 0) {
    return null;
  }
  for (Annotation each : annotations) {
    if (annotationType.isInstance(each)) {
      return annotationType.cast(each);
    }
    Annotation candidate = findDeepAnnotation(each.annotationType()
        .getAnnotations(), annotationType, depth - 1);
    if (candidate != null) {
      return annotationType.cast(candidate);
    }
  }
  return null;
}
origin: com.google.inject/guice

/** Returns the scope annotation on {@code type}, or null if none is specified. */
public static Class<? extends Annotation> findScopeAnnotation(
  Errors errors, Class<?> implementation) {
 return findScopeAnnotation(errors, implementation.getAnnotations());
}
origin: spring-projects/spring-framework

private void recursivelyCollectMetaAnnotations(Set<Annotation> visited, Annotation annotation) {
  Class<? extends Annotation> annotationType = annotation.annotationType();
  String annotationName = annotationType.getName();
  if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotationName) && visited.add(annotation)) {
    try {
      // Only do attribute scanning for public annotations; we'd run into
      // IllegalAccessExceptions otherwise, and we don't want to mess with
      // accessibility in a SecurityManager environment.
      if (Modifier.isPublic(annotationType.getModifiers())) {
        this.attributesMap.add(annotationName,
            AnnotationUtils.getAnnotationAttributes(annotation, false, true));
      }
      for (Annotation metaMetaAnnotation : annotationType.getAnnotations()) {
        recursivelyCollectMetaAnnotations(visited, metaMetaAnnotation);
      }
    }
    catch (Throwable ex) {
      if (logger.isDebugEnabled()) {
        logger.debug("Failed to introspect meta-annotations on " + annotation + ": " + ex);
      }
    }
  }
}
origin: spring-projects/spring-framework

Annotation[] metaAnnotations = annotationClass.getAnnotations();
if (!ObjectUtils.isEmpty(metaAnnotations)) {
  Set<Annotation> visited = new LinkedHashSet<>();
origin: spring-projects/spring-framework

/**
 * Factory method to obtain a {@link SourceClass} from a {@link Class}.
 */
SourceClass asSourceClass(@Nullable Class<?> classType) throws IOException {
  if (classType == null) {
    return new SourceClass(Object.class);
  }
  try {
    // Sanity test that we can reflectively read annotations,
    // including Class attributes; if not -> fall back to ASM
    for (Annotation ann : classType.getAnnotations()) {
      AnnotationUtils.validateAnnotation(ann);
    }
    return new SourceClass(classType);
  }
  catch (Throwable ex) {
    // Enforce ASM via class name resolution
    return asSourceClass(classType.getName());
  }
}
java.langClassgetAnnotations

Javadoc

Returns an array containing all the annotations of this class. If there are no annotations then an empty array is returned.

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
    Finds a resource with a given name. The rules for searching resources associated with a given class
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now