use of org.apache.deltaspike.data.api.Repository in project deltaspike by apache.
the class EntityMetadataInitializer method extract.
private EntityMetadata extract(Class<?> repositoryClass) {
// get from annotation
Repository repository = repositoryClass.getAnnotation(Repository.class);
Class<?> entityClass = repository.forEntity();
boolean isEntityClass = !Object.class.equals(entityClass) && EntityUtils.isEntityClass(entityClass);
if (isEntityClass) {
return new EntityMetadata(entityClass, EntityUtils.primaryKeyClass(entityClass));
}
// get from type
for (Type inf : repositoryClass.getGenericInterfaces()) {
EntityMetadata result = extractFromType(inf);
if (result != null) {
return result;
}
}
EntityMetadata entityMetadata = extractFromType(repositoryClass.getGenericSuperclass());
if (entityMetadata != null) {
return entityMetadata;
}
for (Type intf : repositoryClass.getGenericInterfaces()) {
entityMetadata = extractFromType(intf);
if (entityMetadata != null) {
return entityMetadata;
}
}
if (repositoryClass.getSuperclass() != null) {
return extract(repositoryClass.getSuperclass());
}
return null;
}
Aggregations