Class NullKeyEntityWrapper
java.lang.Object
ch.tocco.nice2.persist.core.api.entity.entitywrappers.AbstractEntityWrapper
ch.tocco.nice2.persist.core.api.entity.entitywrappers.ConditionalEntityWrapper
ch.tocco.nice2.persist.core.api.entity.entitywrappers.NullKeyEntityWrapper
- All Implemented Interfaces:
EntityReference
,Entity
Wrapper for not returning any primary key info.
All getters that would normally return a value of a pk field return null instead, no matter the real value.
Use Entities.nullKeyEntity(myEntity)
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.persist.core.api.entity.Entity
Entity.State
-
Field Summary
Fields inherited from class ch.tocco.nice2.persist.core.api.entity.entitywrappers.AbstractEntityWrapper
entity
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable PrimaryKey
getKey()
Implementing this may be tricky.protected <T> T
getSubstitute
(FieldModel fieldModel, Type<T> type) Requests the substitute value on a field.protected boolean
isCondition
(FieldModel fieldModel) Checks the condition on a field.Get the primary key of this already persisted entity.Methods inherited from class ch.tocco.nice2.persist.core.api.entity.entitywrappers.ConditionalEntityWrapper
getValue, getValue, getValue, getValue, getValue, getValue, getValueMap
Methods inherited from class ch.tocco.nice2.persist.core.api.entity.entitywrappers.AbstractEntityWrapper
delete, getAutoFieldsDisabled, getChangedFields, getContext, getFieldModel, getLogger, getManager, getModel, getOldValue, getRelatedEntity, getRelatedEntityOrNull, getState, getTouchedFields, isFieldChanged, isFieldTouched, isUpdatable, joinTx, resolve, setAutoFieldsDisabled, setValue, unwrap, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.entity.Entity
getBool, getDate, getDateTime, getDecimal, getDouble, getFloat, getInt, getLong, getShort, getString, getTime, hasKey, requireBool, requireDate, requireDateTime, requireDecimal, requireDouble, requireFloat, requireInt, requireLong, requireShort, requireString, requireTime, requireValue, requireValue, requireValue, requireValue, requireValue, requireValue, validate
-
Constructor Details
-
NullKeyEntityWrapper
-
-
Method Details
-
isCondition
Description copied from class:ConditionalEntityWrapper
Checks the condition on a field.- Specified by:
isCondition
in classConditionalEntityWrapper
- Parameters:
fieldModel
- The field for which the condition is checked.- Returns:
true
if your condition is true, and thus the value is overridden by callingConditionalEntityWrapper.getSubstitute(ch.tocco.nice2.model.entity.api.FieldModel, ch.tocco.nice2.types.api.Type<T>)
.- See Also:
-
getSubstitute
Description copied from class:ConditionalEntityWrapper
Requests the substitute value on a field.- Specified by:
getSubstitute
in classConditionalEntityWrapper
- Type Parameters:
T
- The data type of the field.- Parameters:
fieldModel
- The field for which the substitute is asked.type
- The data type of the field. Can also be accessed by fieldModel.getType(), but is required as param for the generics (checking correct method return type).- Returns:
- The substitute value, or pass through to the wrapped entity using
entity.getValue(fieldModel, type);
- See Also:
-
getKey
Description copied from class:ConditionalEntityWrapper
Implementing this may be tricky. Decide for yourself if you- just pass through to the wrapped entity using
entity.getKey();
- or if you blank it all out by returning null
- or if you try to just modify parts of it.
- Specified by:
getKey
in interfaceEntity
- Specified by:
getKey
in interfaceEntityReference
- Specified by:
getKey
in classConditionalEntityWrapper
- Returns:
- The primary key of this entity, or null if in CONCEPTION state.
- See Also:
- just pass through to the wrapped entity using
-
requireKey
Description copied from interface:Entity
Get the primary key of this already persisted entity.Like
Entity.getKey()
but throws if the key is null (state CONCEPTION). Use this if you know the key has been set (ie the entity has been stored before).- Returns:
- The primary key of this entity.
- Throws:
IllegalStateException
- if the pk is [still] null.
-
getTouchedRelations
- Specified by:
getTouchedRelations
in interfaceEntity
- Overrides:
getTouchedRelations
in classAbstractEntityWrapper
- Returns:
- all touched relations, unmodifiableSet
-