Class NullCounterEntityWrapper
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.NullCounterEntityWrapper
- All Implemented Interfaces:
EntityReference
,Entity
Wrapper for returning null for fields of type 'counter'.
This is used in the entity copy process to reset counters.
Use Entities.nullCounterEntity(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.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, requireKey, requireLong, requireShort, requireString, requireTime, requireValue, requireValue, requireValue, requireValue, requireValue, requireValue, validate
-
Constructor Details
-
NullCounterEntityWrapper
-
-
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
-
getTouchedRelations
- Specified by:
getTouchedRelations
in interfaceEntity
- Overrides:
getTouchedRelations
in classAbstractEntityWrapper
- Returns:
- all touched relations, unmodifiableSet
-