I
- the type of the primary keyE
- the type of entities being referencedR
- the type of the reference itselfpublic abstract class BaseEntityRefProperty<I,E extends BaseEntity<I>,R extends BaseEntityRef<I,E>> extends Property
BaseEntityRef
.Modifier and Type | Field and Description |
---|---|
protected R |
entityRef |
protected static Mixing |
mixing |
protected EntityDescriptor |
referencedDescriptor |
protected Class<? extends BaseEntity<?>> |
referencedType |
accessPath, alternativePropertyKey, defaultValue, descriptor, field, label, length, name, nameAsMapping, nullable, propertyKey, propertyName
Modifier | Constructor and Description |
---|---|
protected |
BaseEntityRefProperty(EntityDescriptor descriptor,
AccessPath accessPath,
Field field) |
Modifier and Type | Method and Description |
---|---|
protected abstract Optional<E> |
find(Class<E> type,
sirius.kernel.commons.Value value)
Actually resolves the the type and value into an entity.
|
protected R |
getEntityRef(Object entity) |
EntityDescriptor |
getReferencedDescriptor()
Returns the
EntityDescriptor of the referenced entity. |
Class<? extends BaseEntity<?>> |
getReferencedType()
Returns the entity class of the referenced type.
|
protected Object |
getValueFromField(Object target)
Obtains the value from the field in the given target object
|
void |
link()
Links this property.
|
protected void |
onBeforeSaveChecks(Object entity)
Invoked before an entity is written to the database.
|
protected void |
onDeleteCascade(Object e) |
protected void |
onDeleteReject(Object e) |
protected void |
onDeleteSetNull(Object e) |
protected void |
setValueToField(Object value,
Object target)
Applies the given value to the field in the given target object
|
protected Object |
transformFromDatasource(Class<? extends BaseMapper<?,?,?>> mapperType,
sirius.kernel.commons.Value object)
Converts the database value to the appropriate field value.
|
protected Object |
transformToDatasource(Class<? extends BaseMapper<?,?,?>> mapperType,
Object object)
Converts the Java object which resides in the associated field to the database value which is to be
written into the database.
|
Object |
transformValue(sirius.kernel.commons.Value value)
Converts the given value, which most probably contains user input as string into the target type of this
property.
|
checkNullability, checkUniqueness, determineDefaultValue, determineLengths, determineNullability, equals, getAnnotation, getDefaultValue, getDefinition, getDescriptor, getField, getLabel, getLength, getName, getPropertyName, getValue, getValueAsCopy, getValueForDatasource, hashCode, illegalFieldValue, isNullable, onAfterDelete, onAfterSave, onBeforeDelete, onBeforeSave, parseValue, setValue, setValueFromDatasource, toString, transformFromElastic, transformFromJDBC, transformFromMongo, transformToElastic, transformToJDBC, transformToMongo
is, makeNewInstance, tryAs
protected static Mixing mixing
protected R extends BaseEntityRef<I,E> entityRef
protected Class<? extends BaseEntity<?>> referencedType
protected EntityDescriptor referencedDescriptor
protected BaseEntityRefProperty(EntityDescriptor descriptor, AccessPath accessPath, Field field)
public Class<? extends BaseEntity<?>> getReferencedType()
public EntityDescriptor getReferencedDescriptor()
EntityDescriptor
of the referenced entity.protected Object getValueFromField(Object target)
Property
getValueFromField
in class Property
target
- the target object determined by the access pathpublic Object transformValue(sirius.kernel.commons.Value value)
Property
transformValue
in class Property
value
- the value to convertprotected Object transformFromDatasource(Class<? extends BaseMapper<?,?,?>> mapperType, sirius.kernel.commons.Value object)
Property
transformFromDatasource
in class Property
mapperType
- the mapper which is currently active. This can be used to determine which kind of database is
active and therefore which data format will be available.object
- the database valueprotected Object transformToDatasource(Class<? extends BaseMapper<?,?,?>> mapperType, Object object)
Property
transformToDatasource
in class Property
mapperType
- the mapper which is currently active. This can be used to determine which kind of database is
active and therefore which data format will be required.object
- the current field valueprotected abstract Optional<E> find(Class<E> type, sirius.kernel.commons.Value value)
type
- the type to resolvevalue
- the id to resolveprotected void setValueToField(Object value, Object target)
Property
setValueToField
in class Property
value
- the database value to storetarget
- the target object determined by the access pathprotected void onBeforeSaveChecks(Object entity)
Property
This method is intended to be overwritten with custom logic.
onBeforeSaveChecks
in class Property
entity
- the entity to checkpublic void link()
Property
This is invoked once all EntityDescriptors are loaded and can be used to build references to other descriptors / properties.
protected void onDeleteSetNull(Object e)
protected void onDeleteCascade(Object e)
protected void onDeleteReject(Object e)
Copyright © 2018. All rights reserved.