Codota Logo
Method.getAnnotations
Code IndexAdd Codota to your IDE (free)

How to use
getAnnotations
method
in
java.lang.reflect.Method

Best Java code snippets using java.lang.reflect.Method.getAnnotations (Showing top 20 results out of 8,298)

  • Common ways to obtain Method
private void myMethod () {
Method m =
  • Codota IconClass clazz;clazz.getMethod("<changeme>")
  • Codota IconClass clazz;String name;Class[] parameterTypes;clazz.getMethod(name, parameterTypes)
  • Codota IconPropertyDescriptor pd;pd.getReadMethod()
  • Smart code suggestions by Codota
}
origin: junit-team/junit4

/**
 * Returns the annotations on this method
 */
public Annotation[] getAnnotations() {
  return method.getAnnotations();
}
origin: google/j2objc

/**
 * Returns the annotations on this method
 */
@Override
public Annotation[] getAnnotations() {
  return fMethod.getAnnotations();
}
origin: junit-team/junit4

protected Annotation[] testAnnotations(Method method) {
  return method.getAnnotations();
}
origin: square/retrofit

Builder(Retrofit retrofit, Method method) {
 this.retrofit = retrofit;
 this.method = method;
 this.methodAnnotations = method.getAnnotations();
 this.parameterTypes = method.getGenericParameterTypes();
 this.parameterAnnotationsArray = method.getParameterAnnotations();
}
origin: spring-projects/spring-framework

public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) {
  this.method = method;
  this.annotations = Collections.unmodifiableSet(
      new LinkedHashSet<>(Arrays.asList(method.getAnnotations())));
  this.cacheAnnotation = cacheAnnotation;
  this.cacheName = cacheName;
}
origin: prestodb/presto

public static List<Method> findPublicStaticMethodsWithAnnotation(Class<?> clazz, Class<?> annotationClass)
{
  ImmutableList.Builder<Method> methods = ImmutableList.builder();
  for (Method method : clazz.getMethods()) {
    for (Annotation annotation : method.getAnnotations()) {
      if (annotationClass.isInstance(annotation)) {
        checkArgument(Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()), "%s annotated with %s must be static and public", method.getName(), annotationClass.getSimpleName());
        methods.add(method);
      }
    }
  }
  return methods.build();
}
origin: square/retrofit

 @Override
 public T invoke(Object proxy, Method method, Object[] args) throws Throwable {
  Type returnType = method.getGenericReturnType();
  Annotation[] methodAnnotations = method.getAnnotations();
  CallAdapter<R, T> callAdapter =
    (CallAdapter<R, T>) retrofit.callAdapter(returnType, methodAnnotations);
  return callAdapter.adapt(behaviorCall);
 }
});
origin: square/retrofit

private static <ResponseT, ReturnT> CallAdapter<ResponseT, ReturnT> createCallAdapter(
  Retrofit retrofit, Method method) {
 Type returnType = method.getGenericReturnType();
 Annotation[] annotations = method.getAnnotations();
 try {
  //noinspection unchecked
  return (CallAdapter<ResponseT, ReturnT>) retrofit.callAdapter(returnType, annotations);
 } catch (RuntimeException e) { // Wide exception range because factories are user code.
  throw methodError(method, e, "Unable to create call adapter for %s", returnType);
 }
}
origin: redisson/redisson

@Override
public List<Annotation> getAnnotations() {
  Annotation[] annotations = null;
  if (read != null) {
    annotations = read.getAnnotations();
  } else if (field != null) {
    annotations = field.getAnnotations();
  }
  return annotations != null ? Arrays.asList(annotations) : delegate.getAnnotations();
}
origin: prestodb/presto

@SafeVarargs
public static Set<Method> findPublicMethodsWithAnnotation(Class<?> clazz, Class<? extends Annotation>... annotationClasses)
{
  ImmutableSet.Builder<Method> methods = ImmutableSet.builder();
  for (Method method : clazz.getDeclaredMethods()) {
    for (Annotation annotation : method.getAnnotations()) {
      for (Class<?> annotationClass : annotationClasses) {
        if (annotationClass.isInstance(annotation)) {
          checkArgument(Modifier.isPublic(method.getModifiers()), "Method [%s] annotated with @%s must be public", method, annotationClass.getSimpleName());
          methods.add(method);
        }
      }
    }
  }
  return methods.build();
}
origin: swagger-api/swagger-core

  public static String getHttpMethodFromCustomAnnotations(Method method) {
    for (Annotation methodAnnotation : method.getAnnotations()) {
      HttpMethod httpMethod = methodAnnotation.annotationType().getAnnotation(HttpMethod.class);
      if (httpMethod != null) {
        return httpMethod.value().toLowerCase();
      }
    }
    return null;
  }
}
origin: square/retrofit

private static <ResponseT> Converter<ResponseBody, ResponseT> createResponseConverter(
  Retrofit retrofit, Method method, Type responseType) {
 Annotation[] annotations = method.getAnnotations();
 try {
  return retrofit.responseBodyConverter(responseType, annotations);
 } catch (RuntimeException e) { // Wide exception range because factories are user code.
  throw methodError(method, e, "Unable to create converter for %s", responseType);
 }
}
origin: spring-projects/spring-framework

@Override
public boolean hasAnnotatedMethods(String annotationName) {
  try {
    Method[] methods = getIntrospectedClass().getDeclaredMethods();
    for (Method method : methods) {
      if (!method.isBridge() && method.getAnnotations().length > 0 &&
          AnnotatedElementUtils.isAnnotated(method, annotationName)) {
        return true;
      }
    }
    return false;
  }
  catch (Throwable ex) {
    throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
  }
}
origin: spring-projects/spring-framework

@Override
public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
  try {
    Method[] methods = getIntrospectedClass().getDeclaredMethods();
    Set<MethodMetadata> annotatedMethods = new LinkedHashSet<>(4);
    for (Method method : methods) {
      if (!method.isBridge() && method.getAnnotations().length > 0 &&
          AnnotatedElementUtils.isAnnotated(method, annotationName)) {
        annotatedMethods.add(new StandardMethodMetadata(method, this.nestedAnnotationsAsMap));
      }
    }
    return annotatedMethods;
  }
  catch (Throwable ex) {
    throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
  }
}
origin: spring-projects/spring-framework

private boolean isAnnotated(Method method) {
  Annotation[] anns = method.getAnnotations();
  if (anns == null) {
    return false;
  }
  for (Annotation ann : anns) {
    String name = ann.annotationType().getName();
    if (name.endsWith("Anno")) {
      return true;
    }
  }
  return false;
}
origin: spring-projects/spring-framework

/**
 * Get all {@link Annotation Annotations} that are <em>present</em> on the
 * supplied {@link Method}.
 * <p>Correctly handles bridge {@link Method Methods} generated by the compiler.
 * <p>Meta-annotations will <em>not</em> be searched.
 * @param method the Method to retrieve annotations from
 * @return the annotations found, an empty array, or {@code null} if not
 * resolvable (e.g. because nested Class values in annotation attributes
 * failed to resolve at runtime)
 * @see org.springframework.core.BridgeMethodResolver#findBridgedMethod(Method)
 * @see AnnotatedElement#getAnnotations()
 */
@Nullable
public static Annotation[] getAnnotations(Method method) {
  try {
    return synthesizeAnnotationArray(BridgeMethodResolver.findBridgedMethod(method).getAnnotations(), method);
  }
  catch (Throwable ex) {
    handleIntrospectionFailure(method, ex);
    return null;
  }
}
origin: spring-projects/spring-framework

/**
 * Filter on methods not annotated with the given annotation type.
 */
@SafeVarargs
public final Builder<T> annotNotPresent(Class<? extends Annotation>... annotationTypes) {
  String message = "annotationNotPresent=" + Arrays.toString(annotationTypes);
  addFilter(message, method -> {
    if (annotationTypes.length != 0) {
      return Arrays.stream(annotationTypes).noneMatch(annotType ->
          AnnotatedElementUtils.findMergedAnnotation(method, annotType) != null);
    }
    else {
      return method.getAnnotations().length == 0;
    }
  });
  return this;
}
origin: spring-projects/spring-framework

/**
 * Filter on methods not annotated with the given annotation type.
 */
@SafeVarargs
public final Builder<T> annotNotPresent(Class<? extends Annotation>... annotationTypes) {
  String message = "annotationNotPresent=" + Arrays.toString(annotationTypes);
  addFilter(message, method -> {
    if (annotationTypes.length != 0) {
      return Arrays.stream(annotationTypes).noneMatch(annotType ->
          AnnotatedElementUtils.findMergedAnnotation(method, annotType) != null);
    }
    else {
      return method.getAnnotations().length == 0;
    }
  });
  return this;
}
origin: square/dagger

@Test public void testGetElementKey_WithQualifier() throws NoSuchMethodException {
 Method method = KeysTest.class.getDeclaredMethod("qualifiedElementProvides", new Class<?>[]{});
 assertThat(Keys.getSetKey(method.getGenericReturnType(), method.getAnnotations(), method))
   .isEqualTo("@javax.inject.Named(value=foo)/java.util.Set<java.lang.String>");
}
origin: square/dagger

@Test public void testGetElementKey_NoQualifier() throws NoSuchMethodException {
 Method method = KeysTest.class.getDeclaredMethod("elementProvides", new Class<?>[]{});
 assertThat(Keys.getSetKey(method.getGenericReturnType(), method.getAnnotations(), method))
   .isEqualTo("java.util.Set<java.lang.String>");
}
java.lang.reflectMethodgetAnnotations

Popular methods of Method

  • invoke
    Returns the result of dynamically invoking this method. Equivalent to receiver.methodName(arg1, arg2
  • getName
  • getParameterTypes
  • getReturnType
  • setAccessible
  • getDeclaringClass
  • getAnnotation
  • getModifiers
  • isAnnotationPresent
  • getGenericReturnType
    Returns the return type of this method as a Type instance.
  • getParameterAnnotations
  • getGenericParameterTypes
    Returns the parameter types as an array of Type instances, in declaration order. If this method has
  • getParameterAnnotations,
  • getGenericParameterTypes,
  • isAccessible,
  • equals,
  • toString,
  • getExceptionTypes,
  • getParameterCount,
  • isBridge,
  • isSynthetic

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JCheckBox (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now