Java Class.getDeclaredClasses Examples

Java Class.getDeclaredClasses - 30 examples found. These are the top rated real world Java examples of Class.getDeclaredClasses extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
  private void addClass(Class<?> c) {
    if (classes.add(c)) {
      if (c.getSuperclass() != null) {
        addClass(c.getSuperclass());
      }
      for (Class<?> sc : c.getInterfaces()) {
        addClass(sc);
      }
      for (Class<?> dc : c.getDeclaredClasses()) {
        addClass(dc);
      }
      for (Method m : c.getDeclaredMethods()) {
        addClass(m.getReturnType());
        for (Class<?> p : m.getParameterTypes()) {
          addClass(p);
        }
      }

      if (c != void.class && dimensions(c) < 2) {
        Class<?> arrayClass = Array.newInstance(c, 0).getClass();
        arrayClasses.put(c, arrayClass);
        addClass(arrayClass);
      }
    }
  }
 /** Return the class with the given name. */
 private static Class getClassImpl(Class parent, String name) throws ClassNotFoundException {
   Class[] clazzes = parent.getDeclaredClasses();
   for (int i = 0; i < clazzes.length; i++) {
     if (clazzes[i].getName().equals(parent.getName() + "$" + name)) return clazzes[i];
   }
   throw new ClassNotFoundException("Invalid class : " + parent.getName() + "$" + name);
 }
Example #3
0
  private static void registerSubTileWithMini(String key, Class<? extends SubTileEntity> clazz) {
    BotaniaAPI.registerSubTile(key, clazz);

    for (Class innerClazz : clazz.getDeclaredClasses())
      if (innerClazz.getSimpleName().equals("Mini"))
        BotaniaAPI.registerMiniSubTile(key + "Chibi", innerClazz, key);
  }
 private void verifyExternalClass(final Class clazz) {
   // don't recommended to instantiate the class doing clazz.newInstance().
   clazz.getDeclaredConstructors();
   clazz.getDeclaredFields();
   clazz.getDeclaredMethods();
   clazz.getDeclaredClasses();
   clazz.getDeclaredAnnotations();
 }
 public static Class<?> getDeclaredClass(String className, Class<?> containingClass) {
   for (Class<?> declaredClass : containingClass.getDeclaredClasses()) {
     if (declaredClass.getSimpleName().equals(className)) {
       return declaredClass;
     }
   }
   return null;
 }
Example #6
0
 /**
  * Returns inner class with the specified name.
  *
  * @param fromClass class to look for the inner class
  * @param innerClassName inner class name
  * @return inner class with the specified name
  */
 public static Class getInnerClass(final Class fromClass, final String innerClassName) {
   for (final Class innerClass : fromClass.getDeclaredClasses()) {
     if (getClassName(innerClass).equals(innerClassName)) {
       return innerClass;
     }
   }
   return null;
 }