Search in sources :

Example 1 with JpaResource

use of io.crnk.jpa.annotations.JpaResource in project crnk-framework by crnk-project.

the class JpaResourceInformationProvider method getResourceType.

@Override
public String getResourceType(Class<?> entityClass) {
    JpaResource annotation = entityClass.getAnnotation(JpaResource.class);
    if (annotation != null) {
        return annotation.type();
    }
    if (entityClass.getAnnotation(MappedSuperclass.class) != null) {
        // super classes do not have a document type
        return null;
    }
    String name = entityClass.getSimpleName();
    if (name.endsWith(ENTITY_NAME_SUFFIX)) {
        name = name.substring(0, name.length() - ENTITY_NAME_SUFFIX.length());
    }
    return Character.toLowerCase(name.charAt(0)) + name.substring(1);
}
Also used : MappedSuperclass(javax.persistence.MappedSuperclass) JpaResource(io.crnk.jpa.annotations.JpaResource)

Aggregations

JpaResource (io.crnk.jpa.annotations.JpaResource)1 MappedSuperclass (javax.persistence.MappedSuperclass)1