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

How to use
getDeclaredMethods
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getDeclaredMethods (Showing top 20 results out of 26,217)

origin: spring-projects/spring-framework

public static Method findInterfaceMethod(Class iface) {
  if (!iface.isInterface()) {
    throw new IllegalArgumentException(iface + " is not an interface");
  }
  Method[] methods = iface.getDeclaredMethods();
  if (methods.length != 1) {
    throw new IllegalArgumentException("expecting exactly 1 method in " + iface);
  }
  return methods[0];
}
origin: spring-projects/spring-framework

  public Object run() throws Exception {
    Method[] methods = Object.class.getDeclaredMethods();
    for (Method method : methods) {
      if ("finalize".equals(method.getName())
          || (method.getModifiers() & (Modifier.FINAL | Modifier.STATIC)) > 0) {
        continue;
      }
      OBJECT_METHODS.add(method);
    }
    return null;
  }
});
origin: apache/incubator-dubbo

/**
 * Returns the readResolve method
 */
protected Method getReadResolve(Class cl) {
  for (; cl != null; cl = cl.getSuperclass()) {
    Method[] methods = cl.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++) {
      Method method = methods[i];
      if (method.getName().equals("readResolve") &&
        method.getParameterTypes().length == 0)
        return method;
    }
  }
  return null;
}
origin: apache/incubator-dubbo

/**
 * Returns the writeReplace method
 */
protected Method getWriteReplace(Class cl, Class param) {
  for (; cl != null; cl = cl.getSuperclass()) {
    for (Method method : cl.getDeclaredMethods()) {
      if (method.getName().equals("writeReplace")
          && method.getParameterTypes().length == 1
          && param.equals(method.getParameterTypes()[0]))
        return method;
    }
  }
  return null;
}
origin: apache/incubator-dubbo

/**
 * Returns the writeReplace method
 */
protected Method getWriteReplace(Class cl, Class param) {
  for (; cl != null; cl = cl.getSuperclass()) {
    for (Method method : cl.getDeclaredMethods()) {
      if (method.getName().equals("writeReplace")
          && method.getParameterTypes().length == 1
          && param.equals(method.getParameterTypes()[0]))
        return method;
    }
  }
  return null;
}
origin: libgdx/libgdx

/** Returns an array of {@link Method} containing the methods declared by the class represented by the supplied Class. */
static public Method[] getDeclaredMethods (Class c) {
  java.lang.reflect.Method[] methods = c.getDeclaredMethods();
  Method[] result = new Method[methods.length];
  for (int i = 0, j = methods.length; i < j; i++) {
    result[i] = new Method(methods[i]);
  }
  return result;
}
origin: square/retrofit

private void eagerlyValidateMethods(Class<?> service) {
 Platform platform = Platform.get();
 for (Method method : service.getDeclaredMethods()) {
  if (!platform.isDefaultMethod(method) && !Modifier.isStatic(method.getModifiers())) {
   loadServiceMethod(method);
  }
 }
}
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

 static ImmutableList<Method> getTestMethods(Class<?> testClass) {
  List<Method> result = Lists.newArrayList();
  for (Method method : testClass.getDeclaredMethods()) {
   if (Modifier.isPublic(method.getModifiers())
     && method.getReturnType() == void.class
     && method.getParameterTypes().length == 0
     && method.getName().startsWith("test")) {
    result.add(method);
   }
  }
  return ImmutableList.copyOf(result);
 }
}
origin: google/guava

private static Set<MethodSignature> getPublicStaticMethods(Class<?> clazz) {
 Set<MethodSignature> publicStaticMethods = newHashSet();
 for (Method method : clazz.getDeclaredMethods()) {
  int modifiers = method.getModifiers();
  if (isPublic(modifiers) && isStatic(modifiers)) {
   publicStaticMethods.add(new MethodSignature(method));
  }
 }
 return publicStaticMethods;
}
origin: google/guava

/**
 * Returns an object responsible for performing sanity tests against the return values of all
 * public static methods declared by {@code cls}, excluding superclasses.
 */
public FactoryMethodReturnValueTester forAllPublicStaticMethods(Class<?> cls) {
 ImmutableList.Builder<Invokable<?, ?>> builder = ImmutableList.builder();
 for (Method method : cls.getDeclaredMethods()) {
  Invokable<?, ?> invokable = Invokable.from(method);
  invokable.setAccessible(true);
  if (invokable.isPublic() && invokable.isStatic() && !invokable.isSynthetic()) {
   builder.add(invokable);
  }
 }
 return new FactoryMethodReturnValueTester(cls, builder.build(), "public static methods");
}
origin: google/guava

public static TestSuite suite() {
 // we create a test suite containing a test for every AbstractFutureTest test method and we
 // set it as the name of the test.  Then in runTest we can reflectively load and invoke the
 // corresponding method on AbstractFutureTest in the correct classloader.
 TestSuite suite = new TestSuite(AbstractFutureFallbackAtomicHelperTest.class.getName());
 for (Method method : AbstractFutureTest.class.getDeclaredMethods()) {
  if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("test")) {
   suite.addTest(
     TestSuite.createTest(AbstractFutureFallbackAtomicHelperTest.class, method.getName()));
  }
 }
 return suite;
}
origin: google/guava

public static TestSuite suite() {
 // we create a test suite containing a test for every FuturesTest test method and we
 // set it as the name of the test.  Then in runTest we can reflectively load and invoke the
 // corresponding method on FuturesTest in the correct classloader.
 TestSuite suite = new TestSuite(AggregateFutureStateFallbackAtomicHelperTest.class.getName());
 for (Method method : FuturesTest.class.getDeclaredMethods()) {
  if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("test")) {
   suite.addTest(
     TestSuite.createTest(
       AggregateFutureStateFallbackAtomicHelperTest.class, method.getName()));
  }
 }
 return suite;
}
origin: spring-projects/spring-framework

@Test
public void supportsAllDefaultHandlerExceptionResolverExceptionTypes() throws Exception {
  Class<ResponseEntityExceptionHandler> clazz = ResponseEntityExceptionHandler.class;
  Method handleExceptionMethod = clazz.getMethod("handleException", Exception.class, WebRequest.class);
  ExceptionHandler annotation = handleExceptionMethod.getAnnotation(ExceptionHandler.class);
  List<Class<?>> exceptionTypes = Arrays.asList(annotation.value());
  for (Method method : DefaultHandlerExceptionResolver.class.getDeclaredMethods()) {
    Class<?>[] paramTypes = method.getParameterTypes();
    if (method.getName().startsWith("handle") && (paramTypes.length == 4)) {
      String name = paramTypes[0].getSimpleName();
      assertTrue("@ExceptionHandler is missing " + name, exceptionTypes.contains(paramTypes[0]));
    }
  }
}
origin: google/guava

public void testAllHashFunctionsHaveKnownHashes() throws Exception {
 // The following legacy hashing function methods have been covered by unit testing already.
 List<String> legacyHashingMethodNames = ImmutableList.of("murmur2_64", "fprint96");
 for (Method method : Hashing.class.getDeclaredMethods()) {
  if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
    && Modifier.isPublic(method.getModifiers()) // only the public methods
    && method.getParameterTypes().length == 0 // only the seed-less grapes^W hash functions
    && !legacyHashingMethodNames.contains(method.getName())) {
   HashFunction hashFunction = (HashFunction) method.invoke(Hashing.class);
   assertTrue(
     "There should be at least 3 entries in KNOWN_HASHES for " + hashFunction,
     KNOWN_HASHES.row(hashFunction).size() >= 3);
  }
 }
}
origin: spring-projects/spring-framework

private void doTestHierarchyResolution(Class<?> clazz) throws Exception {
  for (Method method : clazz.getDeclaredMethods()){
    Method bridged = BridgeMethodResolver.findBridgedMethod(method);
    Method expected = clazz.getMethod("test", FooEntity.class);
    assertEquals(expected, bridged);
  }
}
origin: google/guava

static void assertSeedlessHashFunctionEquals(Class<?> clazz) throws Exception {
 for (Method method : clazz.getDeclaredMethods()) {
  if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
    && Modifier.isPublic(method.getModifiers()) // only the public methods
    && method.getParameterTypes().length == 0) { // only the seed-less hash functions
   HashFunction hashFunction1a = (HashFunction) method.invoke(clazz);
   HashFunction hashFunction1b = (HashFunction) method.invoke(clazz);
   new EqualsTester().addEqualityGroup(hashFunction1a, hashFunction1b).testEquals();
   // Make sure we're returning not only equal instances, but constants.
   assertSame(hashFunction1a, hashFunction1b);
   assertEquals(hashFunction1a.toString(), hashFunction1b.toString());
  }
 }
}
origin: google/guava

 public PackageSanityTests() {
  setDefault(BaseEncoding.class, BaseEncoding.base64());
  setDefault(int.class, 32);
  setDefault(String.class, "abcd");
  setDefault(Method.class, AbstractPackageSanityTests.class.getDeclaredMethods()[0]);
  setDefault(MapMode.class, MapMode.READ_ONLY);
  setDefault(CharsetEncoder.class, Charsets.UTF_8.newEncoder());
 }
}
origin: google/guava

public void testNulls() {
 for (Method method : ParameterTest.class.getDeclaredMethods()) {
  for (Parameter param : Invokable.from(method).getParameters()) {
   new NullPointerTester().testAllPublicInstanceMethods(param);
  }
 }
}
origin: google/guava

public void testEquals() {
 EqualsTester tester = new EqualsTester();
 for (Method method : ParameterTest.class.getDeclaredMethods()) {
  for (Parameter param : Invokable.from(method).getParameters()) {
   tester.addEqualityGroup(param);
  }
 }
 tester.testEquals();
}
java.langClassgetDeclaredMethods

Javadoc

Returns an array containing Method objects for all methods declared in the class represented by this Class. If there are no methods or if this Class represents an array class, a primitive type or void 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
  • 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