本文整理匯總了Java中org.apache.commons.lang3.ClassUtils.getAllSuperclasses方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassUtils.getAllSuperclasses方法的具體用法?Java ClassUtils.getAllSuperclasses怎麽用?Java ClassUtils.getAllSuperclasses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.ClassUtils
的用法示例。
在下文中一共展示了ClassUtils.getAllSuperclasses方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConfigInstancesFromServiceAnnotations
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* Returns the ConfigInstances classes from the annotation on the given Service class ,
* including the ConfigInstances annotated on any of its super classes.
* NOTE: Only the super classes that are subclass of Service are inspected.
*/
private static Stream<Class<? extends ConfigInstance>> getConfigInstancesFromServiceAnnotations(Class<? extends Service> serviceClass) {
List<Class<?>> classHierarchy = ClassUtils.getAllSuperclasses(serviceClass);
classHierarchy.add(serviceClass);
return classHierarchy.stream()
.filter(Service.class::isAssignableFrom)
.filter(clazz -> clazz.isAnnotationPresent(RestartConfigs.class))
.map(clazz -> {
RestartConfigs annotation = clazz.getDeclaredAnnotation(RestartConfigs.class);
if (annotation.value().length == 0) {
throw new IllegalStateException(String.format(
"%s has a %s annotation with no ConfigInstances given as argument.",
clazz.getSimpleName(), RestartConfigs.class.getSimpleName()));
}
return annotation;
})
.map(RestartConfigs::value)
.flatMap(Arrays::stream)
.distinct();
}
示例2: getGroups
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
public static List<String> getGroups(Class klass) {
Set<String> set = new LinkedHashSet<>();
addGroupsToList(klass, set);
List<Class<?>> allSuperclasses = ClassUtils.getAllSuperclasses(klass);
for(Class<?> superClass : allSuperclasses) {
if(!superClass.isInterface() && superClass.isAnnotationPresent(ConfigGroups.class)) {
addGroupsToList(superClass, set);
}
}
if(set.isEmpty()) {
set.add(""); // the default empty group
}
return new ArrayList<>(set);
}
示例3: getAllSuperclasses
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* 遞歸返回所有的SupperClasses,包含Object.class
*/
public static List<Class<?>> getAllSuperclasses(final Class<?> cls) {
return ClassUtils.getAllSuperclasses(cls);
}
示例4: isSubclass
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* <p>
* isSubclass
* </p>
*
* @param superclass
* a {@link java.lang.reflect.Type} object.
* @param subclass
* a {@link java.lang.reflect.Type} object.
* @return a boolean.
*/
public static boolean isSubclass(Type superclass, Type subclass) {
List<Class<?>> superclasses = ClassUtils.getAllSuperclasses((Class<?>) subclass);
List<Class<?>> interfaces = ClassUtils.getAllInterfaces((Class<?>) subclass);
if (superclasses.contains(superclass) || interfaces.contains(superclass)) {
return true;
}
return false;
}