public class EntityDictionary extends Object
Include.name()
Modifier and Type | Field and Description |
---|---|
protected Set<String> |
apiVersions |
protected CopyOnWriteArrayList<Type<?>> |
bindEntityRoots |
protected ConcurrentHashMap<org.apache.commons.lang3.tuple.Pair<String,String>,Type<?>> |
bindJsonApiToEntity |
protected com.google.common.collect.BiMap<String,Class<? extends Check>> |
checkNames |
static String |
ELIDE_PACKAGE_PREFIX |
protected ConcurrentHashMap<Type<?>,EntityBinding> |
entityBindings |
protected ConcurrentHashMap<Type<?>,Function<RequestScope,PermissionExecutor>> |
entityPermissionExecutor |
protected Injector |
injector |
static String |
NO_VERSION |
static String |
REGULAR_ID_NAME |
protected Map<String,UserCheck> |
roleChecks |
protected Function<Class,Serde> |
serdeLookup |
protected ConcurrentHashMap<Type<?>,List<Type<?>>> |
subclassingEntities |
Constructor and Description |
---|
EntityDictionary(Map<String,Class<? extends Check>> checks)
Instantiate a new EntityDictionary with the provided set of checks.
|
EntityDictionary(Map<String,Class<? extends Check>> checks,
Injector injector)
Instantiate a new EntityDictionary with the provided set of checks and an injection function.
|
EntityDictionary(Map<String,Class<? extends Check>> checks,
Injector injector,
Function<Class,Serde> serdeLookup) |
EntityDictionary(Map<String,Class<? extends Check>> checks,
Injector injector,
Function<Class,Serde> serdeLookup,
Set<Type<?>> entitiesToExclude) |
EntityDictionary(Map<String,Class<? extends Check>> checks,
Injector injector,
Set<Type<?>> entitiesToExclude)
Instantiate a new EntityDictionary with the provided set of checks and an injection function.
|
EntityDictionary(Map<String,Class<? extends Check>> checks,
Map<String,UserCheck> roleChecks,
Injector injector)
Instantiate a new EntityDictionary with the provided set of checks and an injection function.
|
EntityDictionary(Map<String,Class<? extends Check>> checks,
Map<String,UserCheck> roleChecks,
Injector injector,
Function<Class,Serde> serdeLookup,
Set<Type<?>> entitiesToExclude) |
EntityDictionary(Map<String,Class<? extends Check>> checks,
Set<Type<?>> entitiesToExclude)
Instantiate a new EntityDictionary with the provided set of checks.
|
Modifier and Type | Method and Description |
---|---|
void |
addArgumentsToAttribute(Type<?> cls,
String attributeName,
Set<ArgumentType> arguments)
Add a collection of argument to the attributes.
|
void |
addArgumentToAttribute(Type<?> cls,
String attributeName,
ArgumentType argument)
Add a single argument to the attribute.
|
void |
addArgumentToEntity(Type<?> cls,
ArgumentType argument)
Add a single argument to the Entity.
|
void |
addRoleCheck(String role,
UserCheck check)
Adds a user check for a given role to the dictionary.
|
void |
addSecurityCheck(Class<?> cls)
Add security checks and bind them to the dictionary.
|
void |
addSecurityChecks(Set<Class<?>> classes)
Add security checks and bind them to the dictionary.
|
<A extends Annotation> |
attributeOrRelationAnnotationExists(Type<?> cls,
String fieldName,
Class<A> annotationClass)
Returns whether or not a specified annotation is present on an entity field or its corresponding method.
|
void |
bindEntity(Class<?> cls)
Add given Entity bean to dictionary.
|
void |
bindEntity(Class<?> cls,
Set<Class<? extends Annotation>> hiddenAnnotations)
Add given Entity bean to dictionary.
|
void |
bindEntity(EntityBinding entityBinding)
Add an EntityBinding instance to dictionary.
|
void |
bindEntity(Type<?> cls)
Add given Entity bean to dictionary.
|
void |
bindEntity(Type<?> cls,
Set<Class<? extends Annotation>> hiddenAnnotations)
Add given Entity bean to dictionary.
|
void |
bindLegacyHooks(EntityBinding binding) |
void |
bindPermissionExecutor(Class<?> clz,
Function<RequestScope,PermissionExecutor> permissionExecutorFunction)
Add a permissionExecutorGenerator to the provided class.
|
void |
bindPermissionExecutor(Type<?> clz,
Function<RequestScope,PermissionExecutor> permissionExecutorFunction)
Add a permissionExecutorGenerator to the provided class.
|
void |
bindTrigger(Class<?> entityClass,
LifeCycleHookBinding.Operation operation,
LifeCycleHookBinding.TransactionPhase phase,
LifeCycleHook hook,
boolean allowMultipleInvocations)
Binds a lifecycle hook to a particular entity class.
|
void |
bindTrigger(Class<?> entityClass,
String fieldOrMethodName,
LifeCycleHookBinding.Operation operation,
LifeCycleHookBinding.TransactionPhase phase,
LifeCycleHook hook)
Binds a lifecycle hook to a particular field or method in an entity.
|
void |
bindTrigger(Type<?> entityClass,
LifeCycleHookBinding.Operation operation,
LifeCycleHookBinding.TransactionPhase phase,
LifeCycleHook hook,
boolean allowMultipleInvocations)
Binds a lifecycle hook to a particular entity class.
|
void |
bindTrigger(Type<?> entityClass,
String fieldOrMethodName,
LifeCycleHookBinding.Operation operation,
LifeCycleHookBinding.TransactionPhase phase,
LifeCycleHook hook)
Binds a lifecycle hook to a particular field or method in an entity.
|
Map<Type<?>,PermissionExecutor> |
buildPermissionExecutors(RequestScope scope)
Create a PermissionExecutor from list of bound permissionExecutorGenerator.
|
boolean |
cascadeDeletes(Type<?> targetClass,
String fieldName)
Returns true if the relationship cascades deletes and false otherwise.
|
Object |
coerce(Object target,
Object value,
String fieldName,
Type<?> fieldType)
Coerce provided value into expected class type.
|
boolean |
entityHasChecksForPermission(Type<?> resourceClass,
Class<? extends Annotation> annotationClass)
Determine if a given (entity class, permission) pair have any permissions defined.
|
static Method |
findMethod(Type<?> entityClass,
String name,
Type<?>... paramClass)
Find an arbitrary method.
|
AccessibleObject |
getAccessibleObject(Object target,
String fieldName)
Retrieve the accessible object for a field from a target object.
|
AccessibleObject |
getAccessibleObject(Type<?> targetClass,
String fieldName)
Retrieve the accessible object for a field.
|
javax.persistence.AccessType |
getAccessType(Type<?> entityClass)
Returns whether the entire entity uses Field or Property level access.
|
List<String> |
getAllFields(Object entity)
Get a list of all fields including both relationships and attributes.
|
List<String> |
getAllFields(Type<?> entityClass)
Get a list of all fields including both relationships and attributes.
|
String |
getAnnotatedColumnName(Type<?> cls,
String fieldName)
Get column name using JPA.
|
<A extends Annotation> |
getAnnotation(PersistentResource record,
Class<A> annotationClass)
Return annotation from class, parents or package.
|
<A extends Annotation> |
getAnnotation(Type<?> recordClass,
Class<A> annotationClass)
Return annotation from class, parents or package.
|
Set<ArgumentType> |
getAttributeArguments(Type<?> cls,
String attributeName)
Returns the Collection of all arguments of an attribute.
|
<A extends Annotation> |
getAttributeOrRelationAnnotation(Type<?> entityClass,
Class<A> annotationClass,
String identifier)
Return a single annotation from field or accessor method.
|
<A extends Annotation> |
getAttributeOrRelationAnnotations(Type<?> entityClass,
Class<A> annotationClass,
String identifier)
Return multiple annotations from field or accessor method.
|
List<String> |
getAttributes(Object entity)
Get the list of attribute names for an entity.
|
List<String> |
getAttributes(Type<?> entityClass)
Get the list of attribute names for an entity.
|
Set<EntityBinding> |
getBindings()
Get all bindings.
|
Set<Type<?>> |
getBoundClasses()
Get all bound classes.
|
Set<Type<?>> |
getBoundClassesByVersion(String apiVersion)
Get all bound classes for a particular API version.
|
Class<? extends Check> |
getCheck(String checkIdentifier)
Returns the check mapped to a particular identifier.
|
String |
getCheckIdentifier(Class<? extends Check> checkClass)
Returns the friendly named mapped to this given check.
|
Set<String> |
getCheckIdentifiers()
Gets all the registered check identifiers.
|
Map<String,Class<? extends Check>> |
getCheckMappings()
Get the check mappings.
|
List<String> |
getElideBoundRelationships(Object entity)
Get a list of elide-bound relationships.
|
List<String> |
getElideBoundRelationships(Type<?> entityClass)
Get a list of elide-bound relationships.
|
Set<ArgumentType> |
getEntityArguments(Type<?> cls)
Returns the Collection of all arguments of an entity.
|
EntityBinding |
getEntityBinding(Type<?> entityClass)
Returns an entity binding if the provided class has been bound in the dictionary.
|
Type<?> |
getEntityClass(String entityName,
String version)
Returns the binding class for a given entity name.
|
static String |
getEntityName(Type<?> modelClass)
Looks up the API model name for a given class.
|
Set<String> |
getFieldsOfType(Type<?> targetClass,
Type<?> targetType)
Retrieve fields from an object containing a particular type.
|
static Annotation |
getFirstAnnotation(Type<?> entityClass,
List<Class<? extends Annotation>> annotationClassList)
Return first matching annotation from class, parents or package.
|
static Annotation |
getFirstPackageAnnotation(Type<?> entityClass,
List<Class<? extends Annotation>> annotationClassList)
Return first matching annotation from a package or parent package.
|
String |
getId(Object value)
Gets id.
|
Collection<Annotation> |
getIdAnnotations(Object value)
Returns annotations applied to the ID field.
|
String |
getIdFieldName(Type<?> entityClass)
Returns the name of the id field.
|
Type<?> |
getIdType(Type<?> entityClass)
Returns type of id field.
|
Injector |
getInjector()
Get the Injector for this dictionary.
|
String |
getJsonAliasFor(Type<?> entityClass)
Returns the Include name for a given binding class.
|
<A extends Annotation> |
getMethodAnnotation(Type<?> recordClass,
String method,
Class<A> annotationClass)
Return annotation from class for provided method.
|
static String |
getModelVersion(Type<?> modelClass)
Returns the api version bound to a particular model class.
|
String |
getNameFromAlias(Object entity,
String alias)
Get the true field/method name from an alias.
|
String |
getNameFromAlias(Type<?> entityClass,
String alias)
Get the true field/method name from an alias.
|
Type<?> |
getParameterizedType(Object entity,
String identifier)
Retrieve the parameterized type for the given field.
|
Type<?> |
getParameterizedType(Object entity,
String identifier,
int paramIndex)
Retrieve the parameterized type for the given field.
|
Type<?> |
getParameterizedType(Type<?> entityClass,
String identifier)
Retrieve the parameterized type for the given field.
|
Type<?> |
getParameterizedType(Type<?> entityClass,
String identifier,
int paramIndex)
Retrieve the parameterized type for the given field.
|
org.antlr.v4.runtime.tree.ParseTree |
getPermissionsForClass(Type<?> resourceClass,
Class<? extends Annotation> annotationClass)
Gets the specified permission definition (if any) at the class level.
|
org.antlr.v4.runtime.tree.ParseTree |
getPermissionsForField(Type<?> resourceClass,
String field,
Class<? extends Annotation> annotationClass)
Gets the specified permission definition (if any) at the class level.
|
String |
getRelationInverse(Type<?> cls,
String relation)
If a relationship is bidirectional, returns the name of the peer relationship in the peer entity.
|
List<String> |
getRelationships(Object entity)
Get the list of relationship names for an entity.
|
List<String> |
getRelationships(Type<?> entityClass)
Get the list of relationship names for an entity.
|
RelationshipType |
getRelationshipType(Object entity,
String relation)
Get the type of relationship from a relation.
|
RelationshipType |
getRelationshipType(Type<?> cls,
String relation)
Get the type of relationship from a relation.
|
UserCheck |
getRoleCheck(String role)
Returns an instantiated role check for the given role.
|
Map<String,UserCheck> |
getRoleChecks()
Returns the map of role to their user role check object.
|
static String |
getSimpleName(Type<?> cls)
Cache the simple name of the provided class.
|
List<Type<?>> |
getSubclassingEntities(Type entityClass)
Get a list of inherited entities from a particular entity.
|
List<Type<?>> |
getSuperClassEntities(Type<?> entityClass)
Fetch all entity classes that provided entity inherits from (i.e.
|
Collection<LifeCycleHook> |
getTriggers(Type<?> cls,
LifeCycleHookBinding.Operation op,
LifeCycleHookBinding.TransactionPhase phase) |
Collection<LifeCycleHook> |
getTriggers(Type<?> cls,
LifeCycleHookBinding.Operation op,
LifeCycleHookBinding.TransactionPhase phase,
String fieldName) |
Type<?> |
getType(Object entity,
String identifier)
Get a type for a field on an entity.
|
static <T> Type<T> |
getType(T object) |
Type<?> |
getType(Type<?> entityClass,
String identifier)
Get a type for a field on an entity.
|
Object |
getValue(Object target,
String fieldName,
RequestScope scope)
Invoke the get[fieldName] method on the target object OR get the field with the corresponding name.
|
boolean |
hasBinding(Type<?> cls)
Returns whether or not a class is already bound.
|
<T> void |
initializeEntity(T entity)
Initialize an entity.
|
boolean |
isAttribute(Type<?> entityClass,
String attributeName) |
boolean |
isComputed(Type<?> entityClass,
String fieldName) |
boolean |
isIdGenerated(Type<?> entityClass)
Returns whether or not the ID field for a given model is generated by the persistence layer.
|
boolean |
isJPAEntity(Type<?> objClass)
Check whether a class is a JPA entity.
|
boolean |
isMethodRequestScopeable(Object entity,
Method method)
Determine whether or not a method is request scopeable.
|
boolean |
isMethodRequestScopeable(Type<?> entityClass,
Method method)
Determine whether or not a method is request scopeable.
|
boolean |
isRelation(Type<?> entityClass,
String relationName) |
boolean |
isRoot(Type<?> entityClass)
Is root.
|
boolean |
isStrictNonTransferable(Type<?> entityClass)
Returns whether or not an entity can ever be shared post creation.
|
boolean |
isTransferable(Type<?> entityClass)
Returns whether or not an entity is shareable.
|
boolean |
isValidField(Type<?> cls,
String fieldName)
Returns whether or not a specified field exists in an entity.
|
static Type<?> |
lookupAnnotationDeclarationClass(Type<?> objClass,
Class<? extends Annotation> annotationClass)
Search a class hierarchy to find the first instance of a declared annotation.
|
Type<?> |
lookupBoundClass(Type<?> objClass)
Return bound entity or null.
|
Type<?> |
lookupEntityClass(Type<?> objClass)
Follow for this class or super-class for JPA
Entity annotation. |
Type<?> |
lookupIncludeClass(Type<?> objClass)
Follow for this class or super-class for Include annotation.
|
void |
scanForSecurityChecks()
Scan for security checks and automatically bind them to the dictionary.
|
void |
setId(Object target,
String id)
Sets the ID field of a target object.
|
void |
setValue(Object target,
String fieldName,
Object value)
Invoke the set[fieldName] method on the target object OR set the field with the corresponding name.
|
<T> List<T> |
walkEntityGraph(Set<Type<?>> entities,
Function<Type<?>,T> transform)
Walks the entity graph and performs a transform function on each element.
|
public static final String ELIDE_PACKAGE_PREFIX
public static final String NO_VERSION
protected final ConcurrentHashMap<org.apache.commons.lang3.tuple.Pair<String,String>,Type<?>> bindJsonApiToEntity
protected final ConcurrentHashMap<Type<?>,EntityBinding> entityBindings
protected final ConcurrentHashMap<Type<?>,Function<RequestScope,PermissionExecutor>> entityPermissionExecutor
protected final CopyOnWriteArrayList<Type<?>> bindEntityRoots
protected final ConcurrentHashMap<Type<?>,List<Type<?>>> subclassingEntities
protected final com.google.common.collect.BiMap<String,Class<? extends Check>> checkNames
protected final Injector injector
public static final String REGULAR_ID_NAME
public EntityDictionary(Map<String,Class<? extends Check>> checks)
com.yahoo.elide.core.security.checks.prefab
are mapped to Prefab.CONTAINER.CHECK
(e.g. @ReadPermission(expression="Prefab.Role.All")
or @ReadPermission(expression="Prefab.Common.UpdateOnCreate")
)checks
- a map that links the identifiers used in the permission expression strings
to their implementing classespublic EntityDictionary(Map<String,Class<? extends Check>> checks, Set<Type<?>> entitiesToExclude)
com.yahoo.elide.core.security.checks.prefab
are mapped to Prefab.CONTAINER.CHECK
(e.g. @ReadPermission(expression="Prefab.Role.All")
or @ReadPermission(expression="Prefab.Common.UpdateOnCreate")
)checks
- a map that links the identifiers used in the permission expression strings
to their implementing classes.entitiesToExclude
- Set of Models to exclude from Binding.public EntityDictionary(Map<String,Class<? extends Check>> checks, Injector injector)
com.yahoo.elide.core.security.checks.prefab
are mapped
to Prefab.CONTAINER.CHECK
* (e.g. @ReadPermission(expression="Prefab.Role.All")
or @ReadPermission(expression="Prefab.Common.UpdateOnCreate")
)checks
- a map that links the identifiers used in the permission expression strings
to their implementing classesinjector
- a function typically associated with a dependency injection framework that will
initialize Elide models.public EntityDictionary(Map<String,Class<? extends Check>> checks, Map<String,UserCheck> roleChecks, Injector injector)
com.yahoo.elide.core.security.checks.prefab
are mapped
to Prefab.CONTAINER.CHECK
* (e.g. @ReadPermission(expression="Prefab.Role.All")
or @ReadPermission(expression="Prefab.Common.UpdateOnCreate")
)checks
- a map that links the identifiers used in the permission expression strings
to their implementing classesroleChecks
- a map that links the user check identifiers used in the permission expression strings
to their User Check objectinjector
- a function typically associated with a dependency injection framework that will
initialize Elide models.public EntityDictionary(Map<String,Class<? extends Check>> checks, Injector injector, Set<Type<?>> entitiesToExclude)
com.yahoo.elide.core.security.checks.prefab
are mapped
to Prefab.CONTAINER.CHECK
* (e.g. @ReadPermission(expression="Prefab.Role.All")
or @ReadPermission(expression="Prefab.Common.UpdateOnCreate")
)checks
- a map that links the identifiers used in the permission expression strings
to their implementing classesinjector
- a function typically associated with a dependency injection framework that will
initialize Elide models.entitiesToExclude
- Set of Models to exclude from Binding.public EntityDictionary(Map<String,Class<? extends Check>> checks, Injector injector, Function<Class,Serde> serdeLookup)
public EntityDictionary(Map<String,Class<? extends Check>> checks, Injector injector, Function<Class,Serde> serdeLookup, Set<Type<?>> entitiesToExclude)
public void addRoleCheck(String role, UserCheck check)
role
- The role associated with the check.check
- The instantiated check class.public UserCheck getRoleCheck(String role)
role
- The role associated with the check.public Map<String,UserCheck> getRoleChecks()
public Set<String> getCheckIdentifiers()
public static String getSimpleName(Type<?> cls)
cls
- the Class
object to be checkedpublic static Method findMethod(Type<?> entityClass, String name, Type<?>... paramClass) throws NoSuchMethodException
entityClass
- the entity classname
- the nameparamClass
- the param classNoSuchMethodException
- the no such method exceptionpublic EntityBinding getEntityBinding(Type<?> entityClass)
entityClass
- public boolean isIdGenerated(Type<?> entityClass)
entityClass
- The model to lookup.public Type<?> getEntityClass(String entityName, String version)
entityName
- entity namepublic String getJsonAliasFor(Type<?> entityClass)
entityClass
- the entity classInclude
public boolean entityHasChecksForPermission(Type<?> resourceClass, Class<? extends Annotation> annotationClass)
resourceClass
- the entity classannotationClass
- the permission annotationtrue
if that permission is defined anywhere within the classpublic org.antlr.v4.runtime.tree.ParseTree getPermissionsForClass(Type<?> resourceClass, Class<? extends Annotation> annotationClass)
resourceClass
- the entity to checkannotationClass
- the permission to look forParseTree
expressing the permissions, if one exists
or null
if the permission is not specified at a class levelpublic org.antlr.v4.runtime.tree.ParseTree getPermissionsForField(Type<?> resourceClass, String field, Class<? extends Annotation> annotationClass)
resourceClass
- the entity to checkfield
- the field to inspectannotationClass
- the permission to look forParseTree
expressing the permissions, if one exists
or null
if the permission is not specified on that fieldpublic Class<? extends Check> getCheck(String checkIdentifier)
checkIdentifier
- the name from the expression stringCheck
mapped to the identifier or null
if the given identifer is unmappedpublic List<Type<?>> getSuperClassEntities(Type<?> entityClass)
entityClass
- Entity classpublic List<Type<?>> getSubclassingEntities(Type entityClass)
entityClass
- Entity classpublic String getCheckIdentifier(Class<? extends Check> checkClass)
checkClass
- The class to lookuppublic String getIdFieldName(Type<?> entityClass)
entityClass
- Entity classpublic javax.persistence.AccessType getAccessType(Type<?> entityClass)
entityClass
- Entity Classpublic Set<Type<?>> getBoundClasses()
public Set<Type<?>> getBoundClassesByVersion(String apiVersion)
public Set<EntityBinding> getBindings()
public Map<String,Class<? extends Check>> getCheckMappings()
public List<String> getAttributes(Type<?> entityClass)
entityClass
- entity namepublic Injector getInjector()
public List<String> getAttributes(Object entity)
entity
- entity instancepublic List<String> getRelationships(Type<?> entityClass)
entityClass
- entity namepublic List<String> getRelationships(Object entity)
entity
- entity instancepublic List<String> getElideBoundRelationships(Type<?> entityClass)
entityClass
- Entity class to find relationships forpublic List<String> getElideBoundRelationships(Object entity)
entity
- Entity instance to find relationships forpublic boolean isMethodRequestScopeable(Object entity, Method method)
entity
- Entity instancemethod
- Method on entity to checkpublic boolean isMethodRequestScopeable(Type<?> entityClass, Method method)
entityClass
- Entity to checkmethod
- Method on entity to checkpublic List<String> getAllFields(Type<?> entityClass)
entityClass
- entity namepublic List<String> getAllFields(Object entity)
entity
- entitypublic RelationshipType getRelationshipType(Type<?> cls, String relation)
cls
- Entity classrelation
- Name of relationship fieldpublic String getRelationInverse(Type<?> cls, String relation)
cls
- the clsrelation
- the relationpublic RelationshipType getRelationshipType(Object entity, String relation)
entity
- Entity instancerelation
- Name of relationship fieldpublic Type<?> getType(Type<?> entityClass, String identifier)
If this method is called on a bean such as the following
public class Address {
{@literal @}Id
private Long id
private String street1;
private String street2;
}
then
getType(Address.class, "id") = Long.class
getType(Address.class, "street1") = String.class
getType(Address.class, "street2") = String.class
But if the ID field is not "id" and there is no such non-ID field called "id", i.e.
public class Address {
{@literal @}Id
private Long surrogateKey
private String street1;
private String street2;
}
then
getType(Address.class, "id") = Long.class
getType(Address.class, "surrogateKey") = Long.class
getType(Address.class, "street1") = String.class
getType(Address.class, "street2") = String.class
JSON-API spec does not allow "id" as non-ID field name. If, therefore, there is a non-ID field called "id",
calling this method has undefined behaviorentityClass
- Entity classidentifier
- Identifier/Field to lookup typepublic Type<?> getType(Object entity, String identifier)
entity
- Entity instanceidentifier
- Field to lookup typepublic Type<?> getParameterizedType(Type<?> entityClass, String identifier)
entityClass
- the entity classidentifier
- the identifierpublic Type<?> getParameterizedType(Type<?> entityClass, String identifier, int paramIndex)
entityClass
- the entity classidentifier
- the identifier/field nameparamIndex
- the index of the parameterizationpublic Type<?> getParameterizedType(Object entity, String identifier)
entity
- Entity instanceidentifier
- Field to lookuppublic Type<?> getParameterizedType(Object entity, String identifier, int paramIndex)
entity
- Entity instanceidentifier
- Field to lookupparamIndex
- the index of the parameterizationpublic String getNameFromAlias(Type<?> entityClass, String alias)
entityClass
- Entity namealias
- Alias to convertpublic String getNameFromAlias(Object entity, String alias)
entity
- Entity instancealias
- Alias to convertpublic <T> void initializeEntity(T entity)
T
- the type parameterentity
- Entity to initializepublic boolean isTransferable(Type<?> entityClass)
entityClass
- the entity type to check for the shareable permissionspublic boolean isStrictNonTransferable(Type<?> entityClass)
entityClass
- the entity type to check for the shareable permissionspublic void bindEntity(Class<?> cls)
cls
- Entity bean classpublic void bindEntity(Type<?> cls)
cls
- Entity bean classpublic void bindEntity(Class<?> cls, Set<Class<? extends Annotation>> hiddenAnnotations)
cls
- Entity bean classhiddenAnnotations
- Annotations for hiding a field in APIpublic void bindEntity(Type<?> cls, Set<Class<? extends Annotation>> hiddenAnnotations)
cls
- Entity bean classhiddenAnnotations
- Annotations for hiding a field in APIpublic void bindEntity(EntityBinding entityBinding)
entityBinding
- EntityBinding instancepublic void bindPermissionExecutor(Class<?> clz, Function<RequestScope,PermissionExecutor> permissionExecutorFunction)
clz
- Entity model classpermissionExecutorFunction
- Function that given a request scope returns permissionExecutorpublic void bindPermissionExecutor(Type<?> clz, Function<RequestScope,PermissionExecutor> permissionExecutorFunction)
clz
- Entity model typepermissionExecutorFunction
- Function that given a request scope returns permissionExecutorpublic Map<Type<?>,PermissionExecutor> buildPermissionExecutors(RequestScope scope)
scope
- - request scope to generate permission executor.public <A extends Annotation> A getAnnotation(PersistentResource record, Class<A> annotationClass)
A
- genericClassrecord
- the recordannotationClass
- the annotation classpublic <A extends Annotation> A getAnnotation(Type<?> recordClass, Class<A> annotationClass)
A
- genericClassrecordClass
- the record classannotationClass
- the annotation classpublic <A extends Annotation> A getMethodAnnotation(Type<?> recordClass, String method, Class<A> annotationClass)
A
- genericClassrecordClass
- the record classmethod
- the methodannotationClass
- the annotation classpublic Collection<LifeCycleHook> getTriggers(Type<?> cls, LifeCycleHookBinding.Operation op, LifeCycleHookBinding.TransactionPhase phase, String fieldName)
public Collection<LifeCycleHook> getTriggers(Type<?> cls, LifeCycleHookBinding.Operation op, LifeCycleHookBinding.TransactionPhase phase)
public <A extends Annotation> A getAttributeOrRelationAnnotation(Type<?> entityClass, Class<A> annotationClass, String identifier)
A
- genericClassentityClass
- the entity classannotationClass
- given annotation typeidentifier
- the identifierpublic <A extends Annotation> A[] getAttributeOrRelationAnnotations(Type<?> entityClass, Class<A> annotationClass, String identifier)
A
- the type parameterentityClass
- the entity classannotationClass
- given annotation typeidentifier
- the identifierpublic static Annotation getFirstAnnotation(Type<?> entityClass, List<Class<? extends Annotation>> annotationClassList)
entityClass
- Entity class typeannotationClassList
- List of sought annotationspublic static Annotation getFirstPackageAnnotation(Type<?> entityClass, List<Class<? extends Annotation>> annotationClassList)
entityClass
- Entity class typeannotationClassList
- List of sought annotationspublic boolean isRoot(Type<?> entityClass)
entityClass
- the entity classpublic Type<?> getIdType(Type<?> entityClass)
entityClass
- the entity classpublic Collection<Annotation> getIdAnnotations(Object value)
value
- the valuepublic Type<?> lookupEntityClass(Type<?> objClass)
Entity
annotation.objClass
- provided classpublic Type<?> lookupIncludeClass(Type<?> objClass)
objClass
- provided classpublic static Type<?> lookupAnnotationDeclarationClass(Type<?> objClass, Class<? extends Annotation> annotationClass)
objClass
- The class to start searching.annotationClass
- The annotation to search for.public Type<?> lookupBoundClass(Type<?> objClass)
objClass
- provided classpublic final boolean isJPAEntity(Type<?> objClass)
objClass
- classpublic AccessibleObject getAccessibleObject(Object target, String fieldName)
target
- the object to getfieldName
- the field name to get or invoke equivalent get methodpublic AccessibleObject getAccessibleObject(Type<?> targetClass, String fieldName)
targetClass
- the object to getfieldName
- the field name to get or invoke equivalent get methodpublic Set<String> getFieldsOfType(Type<?> targetClass, Type<?> targetType)
targetClass
- Class to search for fieldstargetType
- Type of fields to findpublic void scanForSecurityChecks()
public void addSecurityChecks(Set<Class<?>> classes)
classes
- Security check classes.public void addSecurityCheck(Class<?> cls)
cls
- Security check class.public void bindTrigger(Class<?> entityClass, String fieldOrMethodName, LifeCycleHookBinding.Operation operation, LifeCycleHookBinding.TransactionPhase phase, LifeCycleHook hook)
entityClass
- The entity that triggers the lifecycle hook.fieldOrMethodName
- The name of the field or method.operation
- CREATE, READ, or UPDATEphase
- PRESECURITY, PRECOMMIT, or POSTCOMMIThook
- The callback to invoke.public void bindTrigger(Type<?> entityClass, String fieldOrMethodName, LifeCycleHookBinding.Operation operation, LifeCycleHookBinding.TransactionPhase phase, LifeCycleHook hook)
entityClass
- The entity that triggers the lifecycle hook.fieldOrMethodName
- The name of the field or method.operation
- CREATE, READ, or UPDATEphase
- PRESECURITY, PRECOMMIT, or POSTCOMMIThook
- The callback to invoke.public void bindTrigger(Class<?> entityClass, LifeCycleHookBinding.Operation operation, LifeCycleHookBinding.TransactionPhase phase, LifeCycleHook hook, boolean allowMultipleInvocations)
allowMultipleInvocations
flag.entityClass
- The entity that triggers the lifecycle hook.operation
- CREATE, READ, or UPDATEphase
- PRESECURITY, PRECOMMIT, or POSTCOMMIThook
- The callback to invoke.allowMultipleInvocations
- Should the same life cycle hook be invoked multiple times for multiple
CRUD actions on the same model.public void bindTrigger(Type<?> entityClass, LifeCycleHookBinding.Operation operation, LifeCycleHookBinding.TransactionPhase phase, LifeCycleHook hook, boolean allowMultipleInvocations)
allowMultipleInvocations
flag.entityClass
- The entity that triggers the lifecycle hook.operation
- CREATE, READ, or UPDATEphase
- PRESECURITY, PRECOMMIT, or POSTCOMMIThook
- The callback to invoke.allowMultipleInvocations
- Should the same life cycle hook be invoked multiple times for multiple
CRUD actions on the same model.public boolean cascadeDeletes(Type<?> targetClass, String fieldName)
targetClass
- The class which owns the relationship.fieldName
- The relationshippublic <T> List<T> walkEntityGraph(Set<Type<?>> entities, Function<Type<?>,T> transform)
T
- The result type.entities
- The roots of the entity graph.transform
- The function to transform each entity class into a result.public boolean hasBinding(Type<?> cls)
cls
- The class to verify.public Object getValue(Object target, String fieldName, RequestScope scope)
target
- the object to getfieldName
- the field name to get or invoke equivalent get methodpublic void setId(Object target, String id)
target
- the object which owns the ID to set.id
- the value to setpublic void setValue(Object target, String fieldName, Object value)
target
- The object which owns the field to setfieldName
- the field name to set or invoke equivalent set methodvalue
- the value to setpublic Object coerce(Object target, Object value, String fieldName, Type<?> fieldType)
target
- The model instance which owns the field being coerced.value
- The value being coerced.fieldName
- the field name in the owning model instance.fieldType
- expected class typepublic <A extends Annotation> boolean attributeOrRelationAnnotationExists(Type<?> cls, String fieldName, Class<A> annotationClass)
A
- The type of the annotationClass
fieldName
- The entity fieldannotationClass
- The provided annotation classtrue
if the field is annotated by the annotationClass
public boolean isValidField(Type<?> cls, String fieldName)
cls
- The entityfieldName
- The provided field to checktrue
if the field exists in the entitypublic void addArgumentsToAttribute(Type<?> cls, String attributeName, Set<ArgumentType> arguments)
cls
- The entityattributeName
- attribute name to which argument has to be addedarguments
- Set of Argument type containing name and type of each argument.public void addArgumentToAttribute(Type<?> cls, String attributeName, ArgumentType argument)
cls
- The entityattributeName
- attribute name to which argument has to be addedargument
- A single argumentpublic void addArgumentToEntity(Type<?> cls, ArgumentType argument)
cls
- The entityargument
- A single argumentpublic Set<ArgumentType> getAttributeArguments(Type<?> cls, String attributeName)
cls
- The entityattributeName
- Name of the argument for ehich arguments are to be retrieved.public Set<ArgumentType> getEntityArguments(Type<?> cls)
cls
- The entitypublic String getAnnotatedColumnName(Type<?> cls, String fieldName)
cls
- The entity class.fieldName
- The entity attribute.public static String getModelVersion(Type<?> modelClass)
modelClass
- The model class to lookup.public static String getEntityName(Type<?> modelClass)
modelClass
- The model class to lookup.public static <T> Type<T> getType(T object)
public void bindLegacyHooks(EntityBinding binding)
Copyright © 2015–2021 Yahoo! Inc.. All rights reserved.