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
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable PrimaryKeygetKey()Implementing this may be tricky.protected <T> TgetSubstitute(FieldModel fieldModel, Type<T> type) Requests the substitute value on a field.protected booleanisCondition(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, getValueMapMethods inherited from class ch.tocco.nice2.persist.core.api.entity.entitywrappers.AbstractEntityWrapper
delete, getAutoFieldsDisabled, getChangedFields, getContext, getFieldModel, getLogger, getManager, getModel, getOldValue, getRelatedEntity, getRelatedEntityOrNull, getState, isFieldChanged, isUpdatable, joinTx, resolve, setAutoFieldsDisabled, setValue, unwrap, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, requireOldValue, requireShort, requireString, requireTime, requireValue, requireValue, requireValue, requireValue, requireValue, requireValue, validate
-
Constructor Details
-
NullKeyEntityWrapper
-
-
Method Details
-
isCondition
Description copied from class:ConditionalEntityWrapperChecks the condition on a field.- Specified by:
isConditionin classConditionalEntityWrapper- Parameters:
fieldModel- The field for which the condition is checked.- Returns:
trueif 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:ConditionalEntityWrapperRequests the substitute value on a field.- Specified by:
getSubstitutein 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:ConditionalEntityWrapperImplementing 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:
getKeyin interfaceEntity- Specified by:
getKeyin interfaceEntityReference- Specified by:
getKeyin 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:EntityGet 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:
getTouchedRelationsin interfaceEntity- Overrides:
getTouchedRelationsin classAbstractEntityWrapper- Returns:
- all touched relations, unmodifiableSet
-