/** * Get the list of relationship names for an entity. * * @param entityClass entity name * @return List of relationship names for entity */ public List<String> getRelationships(Class<?> entityClass) { return getEntityBinding(entityClass).relationships; }
/** * Returns the Include name for a given binding class. * * @param entityClass the entity class * @return binding class * @see Include */ public String getJsonAliasFor(Class<?> entityClass) { return getEntityBinding(entityClass).jsonApiType; }
/** * Returns the Entity name for a given binding class. * * @param entityClass the entity class * @return binding class * @see Entity */ public String getEntityFor(Class<?> entityClass) { return getEntityBinding(entityClass).entityName; }
/** * Get the list of attribute names for an entity. * * @param entityClass entity name * @return List of attribute names for entity */ public List<String> getAttributes(Class<?> entityClass) { return getEntityBinding(entityClass).attributes; }
/** * Get the list of relationship names for an entity. * * @param entityClass entity name * @return List of relationship names for entity */ public List<String> getRelationships(Class<?> entityClass) { return getEntityBinding(entityClass).relationships; }
/** * Get a type for a field on an entity. * * @param entityClass Entity class * @param identifier Field to lookup type * @return Type of entity */ public Class<?> getType(Class<?> entityClass, String identifier) { ConcurrentHashMap<String, Class<?>> fieldTypes = getEntityBinding(entityClass).fieldsToTypes; return fieldTypes == null ? null : fieldTypes.get(identifier); }
/** * Retrieve the accessible object for a field. * * @param targetClass the object to get * @param fieldName the field name to get or invoke equivalent get method * @return the value */ public AccessibleObject getAccessibleObject(Class<?> targetClass, String fieldName) { return getEntityBinding(targetClass).fieldsToValues.get(fieldName); }
/** * Get a type for a field on an entity. * * @param entityClass Entity class * @param identifier Field to lookup type * @return Type of entity */ public Class<?> getType(Class<?> entityClass, String identifier) { ConcurrentHashMap<String, Class<?>> fieldTypes = getEntityBinding(entityClass).fieldsToTypes; return fieldTypes == null ? null : fieldTypes.get(identifier); }
/** * Retrieve the accessible object for a field. * * @param targetClass the object to get * @param fieldName the field name to get or invoke equivalent get method * @return the value */ public AccessibleObject getAccessibleObject(Class<?> targetClass, String fieldName) { return getEntityBinding(targetClass).fieldsToValues.get(fieldName); }
/** * Fetch all entity classes that provided entity inherits from (i.e. all superclass entities down to, * but excluding Object). * * @param entityClass Entity class * @return List of all super class entity classes */ public List<Class<?>> getSuperClassEntities(Class entityClass) { return getEntityBinding(entityClass).inheritedTypes.stream() .filter(entityBindings::containsKey) .collect(Collectors.toList()); }
/** * Gets the specified permission definition (if any) at the class level. * * @param resourceClass the entity to check * @param annotationClass the permission to look for * @return a {@code ParseTree} expressing the permissions, if one exists * or {@code null} if the permission is not specified at a class level */ public ParseTree getPermissionsForClass(Class<?> resourceClass, Class<? extends Annotation> annotationClass) { EntityBinding binding = getEntityBinding(resourceClass); return binding.entityPermissions.getClassChecksForPermission(annotationClass); }
/** * Returns the name of the id field. * * @param entityClass Entity class * @return id field name */ public String getIdFieldName(Class<?> entityClass) { return getEntityBinding(entityClass).getIdFieldName(); }
/** * Returns whether the entire entity uses Field or Property level access. * @param entityClass Entity Class * @return The JPA Access Type */ public AccessType getAccessType(Class<?> entityClass) { return getEntityBinding(entityClass).getAccessType(); }
/** * Returns type of id field. * * @param entityClass the entity class * @return ID type */ public Class<?> getIdType(Class<?> entityClass) { return getEntityBinding(entityClass).getIdType(); }
/** * Return annotation from class, parents or package. * * @param recordClass the record class * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(Class<?> recordClass, Class<A> annotationClass) { return getEntityBinding(recordClass).getAnnotation(annotationClass); }
/** * Determine if a given (entity class, permission) pair have any permissions defined. * * @param resourceClass the entity class * @param annotationClass the permission annotation * @return {@code true} if that permission is defined anywhere within the class */ public boolean entityHasChecksForPermission(Class<?> resourceClass, Class<? extends Annotation> annotationClass) { EntityBinding binding = getEntityBinding(resourceClass); return binding.entityPermissions.hasChecksForPermission(annotationClass); }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<?> cls, Class<A> annotationClass, String fieldName) { return getEntityBinding(cls).getTriggers(annotationClass, fieldName); }
/** * Determine whether or not a method is request scopeable. * * @param entityClass Entity to check * @param method Method on entity to check * @return True if method accepts a RequestScope, false otherwise. */ public boolean isMethodRequestScopeable(Class<?> entityClass, Method method) { return getEntityBinding(entityClass).requestScopeableMethods.getOrDefault(method, false); }
/** * Determine whether or not a method is request scopeable. * * @param entityClass Entity to check * @param method Method on entity to check * @return True if method accepts a RequestScope, false otherwise. */ public boolean isMethodRequestScopeable(Class<?> entityClass, Method method) { return getEntityBinding(entityClass).requestScopeableMethods.getOrDefault(method, false); }
/** * Bind a particular initializer to a class. * * @param <T> the type parameter * @param initializer Initializer to use for class * @param cls Class to bind initialization */ public <T> void bindInitializer(Initializer<T> initializer, Class<T> cls) { bindIfUnbound(cls); getEntityBinding(cls).setInitializer(initializer); }