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

How to use
getDeclaredAnnotation
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getDeclaredAnnotation (Showing top 20 results out of 1,908)

origin: spring-projects/spring-framework

/**
 * Determine whether the given {@code Class} is a Kotlin type
 * (with Kotlin metadata present on it).
 */
public static boolean isKotlinType(Class<?> clazz) {
  return (kotlinMetadata != null && clazz.getDeclaredAnnotation(kotlinMetadata) != null);
}
origin: org.springframework/spring-core

/**
 * Determine whether the given {@code Class} is a Kotlin type
 * (with Kotlin metadata present on it).
 */
public static boolean isKotlinType(Class<?> clazz) {
  return (kotlinMetadata != null && clazz.getDeclaredAnnotation(kotlinMetadata) != null);
}
origin: swagger-api/swagger-core

public static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Class<?> cls) {
  if (cls == null) {
    return null;
  }
  io.swagger.v3.oas.annotations.media.Schema mp = null;
  io.swagger.v3.oas.annotations.media.ArraySchema as = cls.getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema.class);
  if (as != null) {
    mp = as.schema();
  } else {
    mp = cls.getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
  }
  return mp;
}
origin: apache/ignite

/**
 * Gets declared annotation for a class.
 *
 * @param <T> Type of annotation to return.
 * @param cls Class to get annotation from.
 * @param annCls Annotation to get.
 * @return Instance of annotation, or {@code null} if not found.
 */
@Nullable public static <T extends Annotation> T getDeclaredAnnotation(Class<?> cls, Class<T> annCls) {
  if (cls == Object.class)
    return null;
  return cls.getDeclaredAnnotation(annCls);
}
origin: robovm/robovm

/**
 * Returns true if the annotation exists.
 */
private boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationClass) {
  if (annotationClass == null) {
    throw new NullPointerException("annotationClass == null");
  }
  return getDeclaredAnnotation(annotationClass) != null;
}
origin: neo4j/neo4j

private String groupPrefix()
{
  return SslPolicyConfig.class.getDeclaredAnnotation( Group.class ).value();
}
origin: spring-projects/spring-framework

/**
 * Determine whether an annotation of the specified {@code annotationType}
 * is declared locally (i.e. <em>directly present</em>) on the supplied
 * {@code clazz}.
 * <p>The supplied {@link Class} may represent any type.
 * <p>Meta-annotations will <em>not</em> be searched.
 * <p>Note: This method does <strong>not</strong> determine if the annotation
 * is {@linkplain java.lang.annotation.Inherited inherited}. For greater
 * clarity regarding inherited annotations, consider using
 * {@link #isAnnotationInherited(Class, Class)} instead.
 * @param annotationType the annotation type to look for
 * @param clazz the class to check for the annotation on
 * @return {@code true} if an annotation of the specified {@code annotationType}
 * is <em>directly present</em>
 * @see java.lang.Class#getDeclaredAnnotations()
 * @see java.lang.Class#getDeclaredAnnotation(Class)
 * @see #isAnnotationInherited(Class, Class)
 */
public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz) {
  try {
    return (clazz.getDeclaredAnnotation(annotationType) != null);
  }
  catch (Throwable ex) {
    handleIntrospectionFailure(clazz, ex);
    return false;
  }
}
origin: resilience4j/resilience4j

private RateLimiter getRateLimiterAnnotation(ProceedingJoinPoint proceedingJoinPoint) {
  RateLimiter rateLimiter = null;
  Class<?> targetClass = proceedingJoinPoint.getTarget().getClass();
  if (targetClass.isAnnotationPresent(RateLimiter.class)) {
    rateLimiter = targetClass.getAnnotation(RateLimiter.class);
    if (rateLimiter == null) {
      rateLimiter = targetClass.getDeclaredAnnotation(RateLimiter.class);
    }
    if (rateLimiter == null) {
      logger.debug("TargetClass has no declared annotation 'RateLimiter'");
    }
  }
  return rateLimiter;
}
origin: spring-projects/spring-framework

@Nullable
private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClass) {
  Set<BootstrapWith> annotations = AnnotatedElementUtils.findAllMergedAnnotations(testClass, BootstrapWith.class);
  if (annotations.isEmpty()) {
    return null;
  }
  if (annotations.size() == 1) {
    return annotations.iterator().next().value();
  }
  // Allow directly-present annotation to override annotations that are meta-present.
  BootstrapWith bootstrapWith = testClass.getDeclaredAnnotation(BootstrapWith.class);
  if (bootstrapWith != null) {
    return bootstrapWith.value();
  }
  throw new IllegalStateException(String.format(
      "Configuration error: found multiple declarations of @BootstrapWith for test class [%s]: %s",
      testClass.getName(), annotations));
}
origin: robovm/robovm

@Override public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
  if (annotationType == null) {
    throw new NullPointerException("annotationType == null");
  }
  A annotation = getDeclaredAnnotation(annotationType);
  if (annotation != null) {
    return annotation;
  }
  if (annotationType.isAnnotationPresent(Inherited.class)) {
    for (Class<?> sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
      annotation = sup.getDeclaredAnnotation(annotationType);
      if (annotation != null) {
        return annotation;
      }
    }
  }
  return null;
}
origin: swagger-api/swagger-core

public static io.swagger.v3.oas.annotations.media.Schema getSchemaDeclaredAnnotation(Annotated a) {
  if (a == null) {
    return null;
  }
  io.swagger.v3.oas.annotations.media.ArraySchema arraySchema = a.getRawType().getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema.class);
  if (arraySchema != null) {
    return arraySchema.schema();
  } else {
    return a.getRawType().getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
  }
}
origin: resilience4j/resilience4j

private CircuitBreaker getBackendMonitoredAnnotation(ProceedingJoinPoint proceedingJoinPoint) {
  if (logger.isDebugEnabled()) {
    logger.debug("circuitBreaker parameter is null");
  }
  CircuitBreaker circuitBreaker = null;
  Class<?> targetClass = proceedingJoinPoint.getTarget().getClass();
  if (targetClass.isAnnotationPresent(CircuitBreaker.class)) {
    circuitBreaker = targetClass.getAnnotation(CircuitBreaker.class);
    if (circuitBreaker == null) {
      if (logger.isDebugEnabled()) {
        logger.debug("TargetClass has no annotation 'CircuitBreaker'");
      }
      circuitBreaker = targetClass.getDeclaredAnnotation(CircuitBreaker.class);
      if (circuitBreaker == null) {
        if (logger.isDebugEnabled()) {
          logger.debug("TargetClass has no declared annotation 'CircuitBreaker'");
        }
      }
    }
  }
  return circuitBreaker;
}
origin: spring-projects/spring-framework

private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType, Set<Annotation> visited) {
  try {
    A annotation = clazz.getDeclaredAnnotation(annotationType);
    if (annotation != null) {
      return annotation;
origin: org.springframework/spring-core

/**
 * Determine whether an annotation of the specified {@code annotationType}
 * is declared locally (i.e. <em>directly present</em>) on the supplied
 * {@code clazz}.
 * <p>The supplied {@link Class} may represent any type.
 * <p>Meta-annotations will <em>not</em> be searched.
 * <p>Note: This method does <strong>not</strong> determine if the annotation
 * is {@linkplain java.lang.annotation.Inherited inherited}. For greater
 * clarity regarding inherited annotations, consider using
 * {@link #isAnnotationInherited(Class, Class)} instead.
 * @param annotationType the annotation type to look for
 * @param clazz the class to check for the annotation on
 * @return {@code true} if an annotation of the specified {@code annotationType}
 * is <em>directly present</em>
 * @see java.lang.Class#getDeclaredAnnotations()
 * @see java.lang.Class#getDeclaredAnnotation(Class)
 * @see #isAnnotationInherited(Class, Class)
 */
public static boolean isAnnotationDeclaredLocally(Class<? extends Annotation> annotationType, Class<?> clazz) {
  try {
    return (clazz.getDeclaredAnnotation(annotationType) != null);
  }
  catch (Throwable ex) {
    handleIntrospectionFailure(clazz, ex);
    return false;
  }
}
origin: org.springframework/spring-core

private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType, Set<Annotation> visited) {
  try {
    A annotation = clazz.getDeclaredAnnotation(annotationType);
    if (annotation != null) {
      return annotation;
origin: kiegroup/jbpm

  public static void validate(Class<? extends WorkItemHandler> handlerClass,
                WorkItem workItem) throws Exception {

    Wid handlerWidAnnotation = handlerClass.getDeclaredAnnotation(Wid.class);
    if (workItem == null || handlerWidAnnotation == null || handlerWidAnnotation.parameters() == null || handlerWidAnnotation.parameters().length < 1) {
      // nothing to validate
      return;
    }

    for (WidParameter handlerWidParameter : handlerWidAnnotation.parameters()) {
      if (handlerWidParameter.name() != null && handlerWidParameter.required()) {
        if (workItem.getParameter(handlerWidParameter.name()) == null) {
          logger.error("Workitem declares following required parameter which does not exist: " + handlerWidParameter.name());
          throw new IllegalArgumentException("Workitem declares following required parameter which does not exist: " + handlerWidParameter.name());
        }
      }
    }
  }
}
origin: JpressProjects/jpress

WechatAddonConfig wechatAddonConfig = addonClass.getDeclaredAnnotation(WechatAddonConfig.class);
if (wechatAddonConfig == null) {
  continue;
origin: swagger-api/swagger-core

protected Discriminator resolveDiscriminator(JavaType type, ModelConverterContext context) {
  io.swagger.v3.oas.annotations.media.Schema declaredSchemaAnnotation = AnnotationsUtils.getSchemaDeclaredAnnotation(type.getRawClass());
  String disc = (declaredSchemaAnnotation == null) ? "" : declaredSchemaAnnotation.discriminatorProperty();
  if (disc.isEmpty()) {
    // longer method would involve AnnotationIntrospector.findTypeResolver(...) but:
    JsonTypeInfo typeInfo = type.getRawClass().getDeclaredAnnotation(JsonTypeInfo.class);
    if (typeInfo != null) {
      disc = typeInfo.property();
    }
  }
  if (!disc.isEmpty()) {
    Discriminator discriminator = new Discriminator()
        .propertyName(disc);
    if (declaredSchemaAnnotation != null) {
      DiscriminatorMapping mappings[] = declaredSchemaAnnotation.discriminatorMapping();
      if (mappings != null && mappings.length > 0) {
        for (DiscriminatorMapping mapping : mappings) {
          if (!mapping.value().isEmpty() && !mapping.schema().equals(Void.class)) {
            discriminator.mapping(mapping.value(), constructRef(context.resolve(new AnnotatedType().type(mapping.schema())).getName()));
          }
        }
      }
    }
    return discriminator;
  }
  return null;
}
origin: swagger-api/swagger-core

public static Annotation mergeSchemaAnnotations(
    Annotation[] ctxAnnotations, JavaType type) {
  io.swagger.v3.oas.annotations.media.Schema tS = type.getRawClass().getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
  if (!hasSchemaAnnotation(tS)) {
    tS = null;
  io.swagger.v3.oas.annotations.media.ArraySchema tA = type.getRawClass().getDeclaredAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema.class);
  if (!hasArrayAnnotation(tA)) {
    tA = null;
origin: mulesoft/mule

/**
 * Finds the first class in a class hierarchy that is annotated with {@link ArtifactClassLoaderRunnerConfig}.
 * <p/>
 * Annotated class is searched by levels, in a Breadth-first search (BFS) way. Starting from the class received as a parameter,
 * first the class is checked and return if annotated. Otherwise interface directly implemented by the class will be added to
 * review and finally its super class.
 * <p/>
 * Implemented interfaces have priority over class hierarchy as base classes can be imported from other modules with different
 * runner configurations.
 *
 * @param testClass class of the test begin executed by the test runner.
 * @return the first class found in the hierarchy that is annotated, null if no class in the hierarchy is annotated.
 */
public static Class findConfiguredClass(Class<?> testClass) {
 Deque<Class> classesToReview = new LinkedList<>();
 classesToReview.push(testClass);
 while (!classesToReview.isEmpty()) {
  Class currentClass = classesToReview.pop();
  if (currentClass.getDeclaredAnnotation(ArtifactClassLoaderRunnerConfig.class) != null) {
   LOGGER.info("Reading test runner configuration for test '{}' from '{}'", testClass.getName(), currentClass.getName());
   return currentClass;
  }
  addAll(classesToReview, currentClass.getInterfaces());
  if (currentClass.getSuperclass() != null && currentClass.getSuperclass() != Object.class) {
   classesToReview.add(currentClass.getSuperclass());
  }
 }
 return null;
}
java.langClassgetDeclaredAnnotation

Javadoc

Returns the annotation if it exists.

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
  • 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
  • Top PhpStorm plugins
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