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

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

Best Java code snippets using java.lang.reflect.Method.getReturnType (Showing top 20 results out of 33,570)

  • 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: spring-projects/spring-framework

/**
 * Determine if the supplied {@code method} is an annotation attribute method.
 * @param method the method to check
 * @return {@code true} if the method is an attribute method
 * @since 4.2
 */
static boolean isAttributeMethod(@Nullable Method method) {
  return (method != null && method.getParameterCount() == 0 && method.getReturnType() != void.class);
}
origin: spring-projects/spring-framework

@Nullable
private Object wrapCacheValue(Method method, @Nullable Object cacheValue) {
  if (method.getReturnType() == Optional.class &&
      (cacheValue == null || cacheValue.getClass() != Optional.class)) {
    return Optional.ofNullable(cacheValue);
  }
  return cacheValue;
}
origin: spring-projects/spring-framework

public static boolean isCandidateWriteMethod(Method method) {
  String methodName = method.getName();
  Class<?>[] parameterTypes = method.getParameterTypes();
  int nParams = parameterTypes.length;
  return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) &&
      (!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) &&
      (nParams == 1 || (nParams == 2 && int.class == parameterTypes[0])));
}
origin: spring-projects/spring-framework

/**
 * Determine the conventional variable name for the return type of the given
 * method, taking the generic collection type, if any, into account, falling
 * back on the given actual return value if the method declaration is not
 * specific enough, e.g. {@code Object} return type or untyped collection.
 * @param method the method to generate a variable name for
 * @param value the return value (may be {@code null} if not available)
 * @return the generated variable name
 */
public static String getVariableNameForReturnType(Method method, @Nullable Object value) {
  return getVariableNameForReturnType(method, method.getReturnType(), value);
}
origin: spring-projects/spring-framework

/**
 * Determine the conventional variable name for the return type of the
 * given method, taking the generic collection type, if any, into account.
 * @param method the method to generate a variable name for
 * @return the generated variable name
 */
public static String getVariableNameForReturnType(Method method) {
  return getVariableNameForReturnType(method, method.getReturnType(), null);
}
origin: spring-projects/spring-framework

@Nullable
private static Method determineToMethod(Class<?> targetClass, Class<?> sourceClass) {
  if (String.class == targetClass || String.class == sourceClass) {
    // Do not accept a toString() method or any to methods on String itself
    return null;
  }
  Method method = ClassUtils.getMethodIfAvailable(sourceClass, "to" + targetClass.getSimpleName());
  return (method != null && !Modifier.isStatic(method.getModifiers()) &&
      ClassUtils.isAssignable(targetClass, method.getReturnType()) ? method : null);
}
origin: spring-projects/spring-framework

  @Override
  public boolean matches(Method method, Class<?> targetClass) {
    return method.getReturnType().equals(String.class);
  }
},
origin: spring-projects/spring-framework

  @Override
  public boolean matches(Method m, @Nullable Class<?> targetClass) {
    return m.getReturnType() == int.class;
  }
};
origin: spring-projects/spring-framework

  @Override
  public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
    return m.getReturnType() == Void.TYPE;
  }
});
origin: google/guava

InteractionTester(Class<T> interfaceType, Method method) {
 this.interfaceType = interfaceType;
 this.method = method;
 this.passedArgs = getParameterValues(method);
 this.returnValue = new FreshValueGenerator().generateFresh(method.getReturnType());
}
origin: spring-projects/spring-framework

/**
 * Return the type of object that this FactoryBean creates,
 * or {@code null} if not known in advance.
 */
@Override
public Class<?> getObjectType() {
  if (!isPrepared()) {
    // Not fully initialized yet -> return null to indicate "not known yet".
    return null;
  }
  return getPreparedMethod().getReturnType();
}
origin: spring-projects/spring-framework

private static Method findMethodWithReturnType(String name, Class<?> returnType, Class<SettingsDaoImpl> targetType) {
  Method[] methods = targetType.getMethods();
  for (Method m : methods) {
    if (m.getName().equals(name) && m.getReturnType().equals(returnType)) {
      return m;
    }
  }
  return null;
}
origin: spring-projects/spring-framework

private static Method getMethodForReturnType(Class<?> returnType) {
  return Arrays.stream(TestBean.class.getMethods())
      .filter(method -> method.getReturnType().equals(returnType))
      .findFirst()
      .orElseThrow(() ->
          new IllegalArgumentException("Unique return type not found: " + returnType));
}
origin: google/guava

 static void verifyConsitentRawType() {
  for (Method method : RawTypeConsistencyTester.class.getDeclaredMethods()) {
   assertEquals(
     method.getReturnType(), TypeToken.of(method.getGenericReturnType()).getRawType());
   for (int i = 0; i < method.getParameterTypes().length; i++) {
    assertEquals(
      method.getParameterTypes()[i],
      TypeToken.of(method.getGenericParameterTypes()[i]).getRawType());
   }
  }
 }
}
origin: google/guava

@GwtIncompatible // reflection
public void testAsMapBridgeMethods() {
 for (Method m : TreeMultimap.class.getMethods()) {
  if (m.getName().equals("asMap") && m.getReturnType().equals(SortedMap.class)) {
   return;
  }
 }
}
origin: spring-projects/spring-framework

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
    if (Future.class.equals(invocation.getMethod().getReturnType())) {
      return new AsyncResult<>(invocation.getArguments()[0].toString());
    }
    return null;
  }
});
origin: spring-projects/spring-framework

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
    if (Future.class.equals(invocation.getMethod().getReturnType())) {
      return new AsyncResult<>(invocation.getArguments()[0].toString());
    }
    return null;
  }
});
origin: google/guava

@GwtIncompatible // reflection
public void testKeySetBridgeMethods() {
 for (Method m : TreeMultimap.class.getMethods()) {
  if (m.getName().equals("keySet") && m.getReturnType().equals(SortedSet.class)) {
   return;
  }
 }
 fail("No bridge method found");
}
origin: google/guava

 @GwtIncompatible // reflection
 public void testGetBridgeMethods() {
  for (Method m : TreeMultimap.class.getMethods()) {
   if (m.getName().equals("get") && m.getReturnType().equals(SortedSet.class)) {
    return;
   }
  }
  fail("No bridge method found");
 }
}
origin: google/guava

 @GwtIncompatible // reflection
 @AndroidIncompatible // Reflection bug, or actual binary compatibility problem?
 public void testElementSetBridgeMethods() {
  for (Method m : TreeMultiset.class.getMethods()) {
   if (m.getName().equals("elementSet") && m.getReturnType().equals(SortedSet.class)) {
    return;
   }
  }
  fail("No bridge method found");
 }
}
java.lang.reflectMethodgetReturnType

Javadoc

Returns a Class object that represents the formal return type of the method represented by this Method object.

Popular methods of Method

  • invoke
    Returns the result of dynamically invoking this method. Equivalent to receiver.methodName(arg1, arg2
  • getName
  • getParameterTypes
  • 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
  • isAccessible
  • getGenericParameterTypes,
  • isAccessible,
  • equals,
  • getAnnotations,
  • toString,
  • getExceptionTypes,
  • getParameterCount,
  • isBridge,
  • isSynthetic

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • findViewById (Activity)
  • putExtra (Intent)
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • JCheckBox (javax.swing)
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