當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassUtils.getAllSuperclasses方法代碼示例

本文整理匯總了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();
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:25,代碼來源:ConfigValueChangeValidator.java

示例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);
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:16,代碼來源:StageDefinitionExtractor.java

示例3: getAllSuperclasses

import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
 * 遞歸返回所有的SupperClasses,包含Object.class
 */
public static List<Class<?>> getAllSuperclasses(final Class<?> cls) {
	return ClassUtils.getAllSuperclasses(cls);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:7,代碼來源:ClassUtil.java

示例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;
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:21,代碼來源:GenericClass.java


注:本文中的org.apache.commons.lang3.ClassUtils.getAllSuperclasses方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。