E
- The type of the container classT
- The type of the value of the propertypublic abstract class Property<E,T> extends Object
EntityClass
.Modifier and Type | Field and Description |
---|---|
private AttributeAccessor |
attribute
Used to access the value of the property.
|
Modifier | Constructor and Description |
---|---|
protected |
Property(AttributeAccessor attribute)
Creates a new instance of a property.
|
Modifier and Type | Method and Description |
---|---|
void |
addInsertExpression(TableStatement statement,
E entity)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
void |
createPostInsertStatements(StatementsWriter writer,
E entity)
Creates additional SQL statements that are necessary after this property is written (e.g. for mapping tables).
|
void |
createPreInsertStatements(StatementsWriter writer,
E entity)
Creates SQL statements that are necessary before this property is written (e.g. for updating the table
generator).
|
protected void |
failIfRequired(E entity)
Throws an IllegalArgumentException if the field was not filled.
|
Collection<?> |
findReferencedEntities(E entity)
Finds all entities in the current property, that are referenced.
|
void |
generatePendingStatements(StatementsWriter writer,
E entity,
Object writtenEntity,
Object... arguments)
Generates the update statements for an entity that are required after another entity was generated.
|
AttributeAccessor |
getAttribute()
Used to access the value of the property.
|
ColumnExpression |
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.
|
Class<T> |
getType()
The type of the property.
|
T |
getValue(E entity)
Resolves the current value for this property on the given entity.
|
protected static boolean |
isComposition(javax.persistence.CascadeType[] cascades)
Indicates that the property is a composition according to the given cascade types.
|
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.
|
void |
setValue(E entity,
T value)
Sets a new value for this property on the given entity.
|
String |
toString() |
private final AttributeAccessor attribute
protected Property(AttributeAccessor attribute)
attribute
- the accessor of the target attributeprotected static boolean isComposition(javax.persistence.CascadeType[] cascades)
cascades
- the "cascade" attribute of the mapping annotation.true
if we are on the owning side of a composition relationship, false
if we are on the
child side or if this is an associationpublic void addInsertExpression(TableStatement statement, E entity)
statement
- the created statemententity
- the inspected entitypublic void createPostInsertStatements(StatementsWriter writer, E entity) throws IOException
writer
- the target of the created statementsentity
- the inspected entityIOException
- if the writer throws onepublic void createPreInsertStatements(StatementsWriter writer, E entity) throws IOException
entity
- the inspected entitywriter
- the target of the created statementsIOException
- if the writer throws an exceptionprotected void failIfRequired(E entity)
entity
- the entity that does not contain a value for this propertypublic Collection<?> findReferencedEntities(E entity)
entity
- the inspected entitypublic void generatePendingStatements(StatementsWriter writer, E entity, Object writtenEntity, Object... arguments) throws IOException
EntityClass.markPendingUpdates(E, V, org.fastnate.generator.context.Property<V, ?>, java.lang.Object...)
was called before for writtenEntity
writer
- the target of the generated statementsentity
- the entity that needs to be updatedwrittenEntity
- the entity that exists now in the databasearguments
- additional arguments that where given to markPendingUpdatesIOException
- if the writer throws onepublic ColumnExpression 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 Class<T> getType()
type of the attribute
public 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(org.fastnate.generator.statements.TableStatement, E)
will add the corresponding value to the given statementpublic void setValue(E entity, T value)
entity
- the entity to inspectvalue
- the new value@Generated(value="lombok") public AttributeAccessor getAttribute()
Copyright © 2022 fastnate.org. All rights reserved.