E
- The type of the container classT
- The type of the value of the propertypublic abstract class Property<E,T> extends Object
EntityClass
.Modifier | Constructor and Description |
---|---|
protected |
Property(AttributeAccessor attribute)
Creates a new instance of a property.
|
Modifier and Type | Method and Description |
---|---|
void |
addInsertExpression(E entity,
InsertStatement statement)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
List<EntityStatement> |
createPostInsertStatements(E entity)
Creates additional SQL statements that are necessary after this property is written (e.g. for mapping tables) .
|
List<? extends EntityStatement> |
createPreInsertStatements(E entity)
Creates SQL statements that are necessary before this property is written (e.g. for updating the table
generator).
|
protected void |
failIfRequired()
Throws an IllegalArgumentException if the field was not filled.
|
Collection<?> |
findReferencedEntities(E entity)
Finds all entities in the current property, that are referenced.
|
List<EntityStatement> |
generatePendingStatements(E entity,
Object writtenEntity,
Object... arguments)
Generates the update statements for an entity that are required after another entity was generated.
|
String |
getExpression(E entity,
boolean whereExpression)
Creates the expression for the current value of the given entity in SQL.
|
String |
getName()
The name of this property.
|
String |
getPredicate(E entity)
Creates an SQL predicate that references all entities that have the same value as the given entity.
|
T |
getValue(E entity)
Resolves the current value for this property on the given entity.
|
boolean |
isRequired()
Indicates if this property is an required field in the database (needs to exist when the insert statement is
written).
|
abstract boolean |
isTableColumn()
Indicates that this property maps to a column from the parent table.
|
protected void |
setValue(E entity,
T value)
Sets a new value for this property on the given entity.
|
String |
toString() |
protected Property(AttributeAccessor attribute)
attribute
- the accessor of the target attributepublic void addInsertExpression(E entity, InsertStatement statement)
entity
- the inspected entitystatement
- the created statementpublic List<EntityStatement> createPostInsertStatements(E entity)
entity
- the inspected entitypublic List<? extends EntityStatement> createPreInsertStatements(E entity)
entity
- the inspected entityprotected void failIfRequired()
public Collection<?> findReferencedEntities(E entity)
entity
- the inspected entitypublic List<EntityStatement> generatePendingStatements(E entity, Object writtenEntity, Object... arguments)
EntityClass.markPendingUpdates(E, V, org.fastnate.generator.context.Property<V, ?>, java.lang.Object...)
was called before for writtenEntity
entity
- the entity that needs to be updatedwrittenEntity
- the entity that exists now in the databasearguments
- additional arguments that where given to markPendingUpdatespublic String getExpression(E entity, boolean whereExpression)
entity
- the entitywhereExpression
- indicates that the expression is used in a "where" statementnull
if no existspublic String getName()
public String getPredicate(E entity)
entity
- the entitynull
if no such expression is availablepublic T getValue(E entity)
entity
- the entity to inspectnull
if entity is null
public boolean isRequired()
true
if the field is requiredpublic abstract boolean isTableColumn()
true
if addInsertExpression(Object, InsertStatement)
will add the corresponding value to
the given statementprotected void setValue(E entity, T value)
entity
- the entity to inspectvalue
- the new valueCopyright © 2016 fastnate.org. All rights reserved.