下面列出了org.apache.commons.lang3.ClassUtils#hierarchy ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public EntityUUID(final URI entitySetURI, final Class<?> type, final Object key) {
this.entitySetURI = entitySetURI;
this.key = key;
this.tempKey = (int) (Math.random() * 1000000);
if (type == null || !Serializable.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Invalid Entity type class: " + type);
}
if (this.type == null) {
for (Class<?> clazz : ClassUtils.hierarchy(type, ClassUtils.Interfaces.INCLUDE)) {
if (ArrayUtils.contains(clazz.getInterfaces(), EntityType.class)) {
this.type = clazz;
}
}
}
}
/**
* Creates a Bindings object containing the entire class hierarchy of the given view type. All extended classes and interfaces
* implemented by the given type will be bound to the specified view.
*
* @param viewType The class representing the type of view to bind
* @param view The view object to bind
* @param <T> The type of view to bind
* @return A bindings object
*/
@SuppressWarnings("unchecked")
public static <T> Bindings hierarchy(Class<? super T> viewType, T view) {
Bindings bindings = new Bindings();
for (Class<?> superType : ClassUtils.hierarchy(viewType, ClassUtils.Interfaces.INCLUDE)) {
bindings.addBinding((Class<? super T>) superType, view);
}
return bindings;
}