本文整理匯總了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));
}