public class EntityRegistration extends Object implements DataProvider
Modifier and Type | Class and Description |
---|---|
private static class |
EntityRegistration.InvokeLaterHandle<E> |
private static class |
EntityRegistration.UniqueKey |
Modifier and Type | Field and Description |
---|---|
private GeneratorContext |
context
The generation context contains the description of the entity classes, especially unique properties.
|
private Map<Class<?>,Map<EntityRegistration.UniqueKey,Object>> |
entities
Mapping from the type of the entity to the name of the uniqe properties with their values and entities.
|
Constructor and Description |
---|
EntityRegistration(GeneratorContext context) |
Modifier and Type | Method and Description |
---|---|
private <E> void |
addEntity(Map<EntityRegistration.UniqueKey,Object> uniqueEntities,
E entity,
String[] propertyNames,
Object[] propertyValues) |
void |
buildEntities()
Builds the entities that are accessed later using
DataProvider.writeEntities(EntitySqlGenerator) . |
<E> E |
findEntity(Class<E> entityClass,
Object uniqueValue)
Find an entity, that was registered with
registerEntity(Object) before. |
<E> E |
findEntity(Class<E> entityClass,
String[] uniqueProperties,
Object[] uniqueValues)
Find an entity, that was registered with
registerEntity(Object) before. |
<E> E |
findEntity(Class<E> entityClass,
String uniqueProperty,
Object uniqueValue)
Find an entity, that was registered with
registerEntity(Object) before. |
<E> void |
invokeOnEntity(Class<E> entityClass,
Object uniqueValue,
Consumer<E> invoker)
Invokes an action on a specific entity as soon as this entity was
registered . |
<E> void |
invokeOnEntity(Class<E> entityClass,
String[] uniqueProperties,
Object[] uniqueValues,
Consumer<E> invoker)
Invokes an action on a specific entity as soon as this entity was
registered . |
<E> void |
invokeOnEntity(Class<E> entityClass,
String uniqueProperty,
Object uniqueValue,
Consumer<E> invoker)
Invokes an action on a specific entity as soon as this entity was
registered . |
<E> void |
invokeOnEntity(E templateEntity,
Consumer<E> invoker)
Invokes an action on a specific entity as soon as this entity was
registered . |
<E> void |
invokeOnEntity(EntityClass<E> entityClass,
Object uniqueValue,
Consumer<E> invoker)
Invokes an action on a specific entity as soon as this entity was
registered . |
<E> void |
registerEntity(E entity)
Registers the entity under all of its unique properties.
|
<E> void |
registerEntity(E entity,
String[] propertyNames,
Object[] propertyValues)
Registers the entity under the given unique combination of properties.
|
void |
writeEntities(EntitySqlGenerator sqlGenerator)
Adds all
entities to the SQL file using the given generator. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOrder
private final GeneratorContext context
private final Map<Class<?>,Map<EntityRegistration.UniqueKey,Object>> entities
@ConstructorProperties(value="context") @Generated(value="lombok") public EntityRegistration(GeneratorContext context)
private <E> void addEntity(Map<EntityRegistration.UniqueKey,Object> uniqueEntities, E entity, String[] propertyNames, Object[] propertyValues)
public void buildEntities() throws IOException
DataProvider
DataProvider.writeEntities(EntitySqlGenerator)
.buildEntities
in interface DataProvider
IOException
- if something happens during any possible import of the generated entitiespublic <E> E findEntity(Class<E> entityClass, Object uniqueValue)
registerEntity(Object)
before.entityClass
- the class of the required entityuniqueValue
- the value from the propertynull
if not foundIllegalArgumentException
- if more than one unique property existspublic <E> E findEntity(Class<E> entityClass, String uniqueProperty, Object uniqueValue)
registerEntity(Object)
before.entityClass
- the class of the required entityuniqueProperty
- the name of the unique propertyuniqueValue
- the value of the unique propertynull
if not foundpublic <E> E findEntity(Class<E> entityClass, String[] uniqueProperties, Object[] uniqueValues)
registerEntity(Object)
before.entityClass
- the class of the required entityuniqueProperties
- the names of the set of unique propertiesuniqueValues
- the values of the set of unique propertiesnull
if not foundpublic <E> void invokeOnEntity(Class<E> entityClass, Object uniqueValue, Consumer<E> invoker)
registered
.
Use only if just one unique property exists - otherwise use
invokeOnEntity(Class, String, Object, Consumer)
.entityClass
- the class of the required entityuniqueValue
- the value from the unique propertyinvoker
- the action to call on the entity as soon as it is registeredIllegalArgumentException
- if more than one unique property existspublic <E> void invokeOnEntity(Class<E> entityClass, String uniqueProperty, Object uniqueValue, Consumer<E> invoker)
registered
.entityClass
- the class of the required entityuniqueProperty
- the name of the unique propertyuniqueValue
- the value from the unique propertyinvoker
- the action to call on the entity as soon as it is registeredpublic <E> void invokeOnEntity(Class<E> entityClass, String[] uniqueProperties, Object[] uniqueValues, Consumer<E> invoker)
registered
.entityClass
- the class of the required entityuniqueProperties
- the names of the set of unique propertiesuniqueValues
- the values of the set of unique propertiesinvoker
- the action to call on the entity as soon as it is registeredpublic <E> void invokeOnEntity(E templateEntity, Consumer<E> invoker)
registered
.templateEntity
- the template that describes the referenced entity (contains a value in at least one set of unique
properties)invoker
- the action to call on the entity as soon as it is registeredpublic <E> void invokeOnEntity(EntityClass<E> entityClass, Object uniqueValue, Consumer<E> invoker)
registered
.
Use only if just one unique property exists - otherwise use
invokeOnEntity(Class, String, Object, Consumer)
.entityClass
- describes the class of the required entityuniqueValue
- the value from the unique propertyinvoker
- the action to call on the entity as soon as it is registeredIllegalArgumentException
- if more than one unique property existspublic <E> void registerEntity(E entity)
entity
- the entitypublic <E> void registerEntity(E entity, String[] propertyNames, Object[] propertyValues)
entity
- the entity to registerpropertyNames
- the names of the properties that are (in combination) uniquepropertyValues
- the values of the propertiespublic void writeEntities(EntitySqlGenerator sqlGenerator) throws IOException
DataProvider
entities
to the SQL file using the given generator.writeEntities
in interface DataProvider
sqlGenerator
- the SQL file generatorIOException
- if the generator throws oneCopyright © 2022 fastnate.org. All rights reserved.