Java Class.getSuperclass Examples

Java Class.getSuperclass - 30 examples found. These are the top rated real world Java examples of Class.getSuperclass extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
  /**
   * model
   *
   * @param me
   */
  @Override
  public void configPlugin(Plugins me) {

    componentSscan(basePackage);

    IDataSourceProvider iDataSourceProvider = setDataSource();
    try {
      me.add((IPlugin) iDataSourceProvider);
    } catch (Exception e) {
      throw new RuntimeException("is not IPlugin type");
    }
    ActiveRecordPlugin arp = new ActiveRecordPlugin(iDataSourceProvider);

    addActiveRecord(arp); // 加入附加的活动记录
    Scan driven = new Scan();
    for (String pake : basePackage) {
      Set<Class<?>> clazzs = driven.getClasses(pake);

      for (Class<?> clazz : clazzs) {
        LOG.info(clazz.getName());
        Class superClass = clazz.getSuperclass();
        Class<?> jfClz = com.jfinal.plugin.activerecord.Model.class;
        if (superClass == jfClz || superClass.getSuperclass() == jfClz) {
          M model = clazz.getAnnotation(M.class);
          if (null != model) {
            arp.addMapping(model.value(), model.id(), (Class<? extends Model<?>>) clazz);
          }
        }
      }
    }
    me.add(arp);
  }
  @SuppressWarnings("unchecked")
  static Class<? extends Event<?>> getEventClass(Class<?> handlerClass) {

    for (Class<?> i : handlerClass.getInterfaces()) {
      if (EventHandler.class.equals(i)) {
        for (Type t : handlerClass.getGenericInterfaces()) {
          if (t instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) t;
            if (EventHandler.class.equals(pt.getRawType())) {

              return (Class<? extends Event<?>>) pt.getActualTypeArguments()[0];
            }
          }
        }
      } else if (EventHandler.class.isAssignableFrom(i)) {
        return getEventClass((Class<? extends EventHandler<?>>) i);
      }
    }

    if (EventHandler.class.isAssignableFrom(handlerClass.getSuperclass())) {
      return getEventClass((Class<?>) handlerClass.getSuperclass());
    }

    return null;
  }
Example #3
0
  /**
   * Special helper function which allows for a map of default values.
   *
   * <p>First getString(directory,componentClass.getSimpleName(), null) is invoked, if the returned
   * value is null, the defaultMap is consulted for a value.
   *
   * @param directory
   * @param componentClass
   * @param defaultMap
   * @return
   */
  protected String get(
      String directory,
      Class<? extends RocketComponent> componentClass,
      Map<Class<?>, String> defaultMap) {

    // Search preferences
    Class<?> c = componentClass;
    while (c != null && RocketComponent.class.isAssignableFrom(c)) {
      String value = this.getString(directory, c.getSimpleName(), null);
      if (value != null) return value;
      c = c.getSuperclass();
    }

    if (defaultMap == null) return null;

    // Search defaults
    c = componentClass;
    while (RocketComponent.class.isAssignableFrom(c)) {
      String value = defaultMap.get(c);
      if (value != null) return value;
      c = c.getSuperclass();
    }

    return null;
  }
 public void postInitialize(Set<Class<?>> indexedClasses) {
   // we initialize only once because we no longer have a reference to the reflectionManager
   // in theory
   Class<?> plainClass = beanClass;
   if (entityState == EntityState.NON_INDEXABLE) {
     throw new AssertionFailure("A non indexed entity is post processed");
   }
   Set<Class<?>> tempMappedSubclasses = new HashSet<Class<?>>();
   // together with the caller this creates a o(2), but I think it's still faster than create the
   // up hierarchy for each class
   for (Class<?> currentClass : indexedClasses) {
     if (plainClass != currentClass && plainClass.isAssignableFrom(currentClass)) {
       tempMappedSubclasses.add(currentClass);
     }
   }
   this.mappedSubclasses = Collections.unmodifiableSet(tempMappedSubclasses);
   Class<?> superClass = plainClass.getSuperclass();
   this.isRoot = true;
   while (superClass != null) {
     if (indexedClasses.contains(superClass)) {
       this.isRoot = false;
       break;
     }
     superClass = superClass.getSuperclass();
   }
 }
Example #5
0
  /** Looks inside the given class and finds all declared properties */
  protected static Property<?>[] generateProperties(Class<? extends AbstractModel> cls) {
    ArrayList<Property<?>> properties = new ArrayList<>();
    if (cls.getSuperclass() != AbstractModel.class) {
      properties.addAll(
          Arrays.asList(generateProperties((Class<? extends AbstractModel>) cls.getSuperclass())));
    }

    // a property is public, static & extends Property
    for (Field field : cls.getFields()) {
      if ((field.getModifiers() & Modifier.STATIC) == 0) {
        continue;
      }
      if (!Property.class.isAssignableFrom(field.getType())) {
        continue;
      }
      try {
        if (((Property<?>) field.get(null)).table == null) {
          continue;
        }
        properties.add((Property<?>) field.get(null));
      } catch (IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }

    return properties.toArray(new Property<?>[properties.size()]);
  }
 private static Class<?>[] getObjectInterfaces(Class<?> objectClass, List<Class<?>> interfaces) {
   // Rq: object.getClass().getInterfaces() ne suffit pas pour Connection dans Tomcat
   // car la connection est une instance de PoolGuardConnectionWrapper
   // et connection.getClass().getInterfaces() est vide dans ce cas
   final List<Class<?>> myInterfaces;
   if (interfaces == null) {
     myInterfaces = new ArrayList<Class<?>>(Arrays.asList(objectClass.getInterfaces()));
     Class<?> classe = objectClass.getSuperclass();
     while (classe != null) {
       final Class<?>[] classInterfaces = classe.getInterfaces();
       if (classInterfaces.length > 0) {
         final List<Class<?>> superInterfaces = Arrays.asList(classInterfaces);
         // removeAll d'abord car il ne faut pas de doublon dans la liste
         myInterfaces.removeAll(superInterfaces);
         myInterfaces.addAll(superInterfaces);
       }
       classe = classe.getSuperclass();
     }
     // on ignore l'interface javax.naming.Referenceable car sinon le rebind sous jetty appelle
     // referenceable.getReference() et devient inutile
     myInterfaces.remove(Referenceable.class);
   } else {
     myInterfaces = interfaces;
   }
   return myInterfaces.toArray(new Class<?>[myInterfaces.size()]);
 }