public abstract class StorageConverter<I,E extends Entity<I,S>,S extends io.spine.base.EntityState>
extends com.google.common.base.Converter<E,io.spine.server.entity.EntityRecord>
implements java.io.Serializable
EntityRecord
.Modifier | Constructor and Description |
---|---|
protected |
StorageConverter(io.spine.type.TypeUrl entityStateType,
EntityFactory<E> factory,
com.google.protobuf.FieldMask fieldMask) |
Modifier and Type | Method and Description |
---|---|
protected E |
doBackward(io.spine.server.entity.EntityRecord entityRecord) |
protected io.spine.server.entity.EntityRecord |
doForward(E entity) |
protected EntityFactory<E> |
entityFactory()
Obtains the entity factory used by the converter.
|
protected io.spine.type.TypeUrl |
entityStateType()
Obtains the type URL of the state of entities which this converter builds.
|
boolean |
equals(@Nullable java.lang.Object obj) |
protected com.google.protobuf.FieldMask |
fieldMask()
Obtains the field mask used by this converter to trim the state of entities before the state
is injected into entities.
|
int |
hashCode() |
protected abstract void |
injectState(E entity,
S state,
io.spine.server.entity.EntityRecord entityRecord)
Derived classes must implement providing state injection into the passed entity.
|
protected void |
updateBuilder(io.spine.server.entity.EntityRecord.Builder builder,
E entity)
Derived classes may override to additionally tune the passed entity builder.
|
abstract StorageConverter<I,E,S> |
withFieldMask(com.google.protobuf.FieldMask fieldMask)
Creates a copy of this converter modified with the passed filed mask.
|
andThen, apply, convert, convertAll, from, identity, reverse
protected StorageConverter(io.spine.type.TypeUrl entityStateType, EntityFactory<E> factory, com.google.protobuf.FieldMask fieldMask)
protected io.spine.type.TypeUrl entityStateType()
protected EntityFactory<E> entityFactory()
protected com.google.protobuf.FieldMask fieldMask()
public abstract StorageConverter<I,E,S> withFieldMask(com.google.protobuf.FieldMask fieldMask)
protected io.spine.server.entity.EntityRecord doForward(E entity)
protected E doBackward(io.spine.server.entity.EntityRecord entityRecord)
protected void updateBuilder(io.spine.server.entity.EntityRecord.Builder builder, E entity)
Default implementation does nothing.
builder
- the entity builder to updateentity
- the entity which data is passed to the EntityRecord
we are buildingprotected abstract void injectState(E entity, S state, io.spine.server.entity.EntityRecord entityRecord)
entity
- the entity into which inject the statestate
- the state message extracted from the recordentityRecord
- the record which may contain additional properties for the entitypublic int hashCode()
hashCode
in class java.lang.Object