本文整理汇总了Java中org.seedstack.shed.reflect.ClassPredicates类的典型用法代码示例。如果您正苦于以下问题:Java ClassPredicates类的具体用法?Java ClassPredicates怎么用?Java ClassPredicates使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassPredicates类属于org.seedstack.shed.reflect包,在下文中一共展示了ClassPredicates类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: streamClasses
import org.seedstack.shed.reflect.ClassPredicates; //导入依赖的package包/类
/**
* Checks that classes satisfying a specification are assignable to a base class and return a
* typed stream of it.
*/
@SuppressWarnings("unchecked")
public static <T> Stream<Class<? extends T>> streamClasses(Collection<Class<?>> classes,
Class<? extends T> baseClass) {
return classes
.stream()
.filter(ClassPredicates.classIsDescendantOf(baseClass))
.map(c -> (Class<T>) c);
}
示例2: findIdentityGeneratorInterface
import org.seedstack.shed.reflect.ClassPredicates; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Class<IdentityGenerator> findIdentityGeneratorInterface(
Class<? extends IdentityGenerator> identityGeneratorClass) {
return (Class<IdentityGenerator>) Classes.from(identityGeneratorClass)
.traversingInterfaces()
.traversingSuperclasses()
.classes()
.filter(ClassPredicates.classIsInterface()
.and(ClassPredicates.classIsAssignableFrom(IdentityGenerator.class)))
.findFirst().<BaseException>orElseThrow(
() -> BusinessException.createNew(BusinessErrorCode.ILLEGAL_IDENTITY_GENERATOR)
.put("class", identityGeneratorClass));
}