public class EntityModel extends Object implements Entity
| Modifier and Type | Class and Description |
|---|---|
static class |
EntityModel.EntityState
Represents the state of the entity.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CLIENT_LOCK_STAMP_FIELD_NAME
Field that keeps track if the entity has changed on the server vs what is being sent from the client
If it's contained in the entity model, it should always be sent back to the server (always dirty)
This prevents users to overwrite other people's changes from their client side cached entity
|
static String |
ID_FIELD_NAME
ID field, should always be sent to the server (always dirty)
|
| Constructor and Description |
|---|
EntityModel()
Creates a new EntityModel object
All fields set after using this constructor will be considered "dirty"
|
EntityModel(Set<FieldModel> values)
Creates a new EntityModel object with given field models
Use this when create entity model with mass of fields.
|
EntityModel(Set<FieldModel> values,
EntityModel.EntityState entityState)
Creates a new EntityModel object with given field models
Use this when create entity model with mass of fields.
|
EntityModel(String key,
String value)
Creates a new EntityModel object with solo string field
The entity will be considered dirty and thus these fields will be updated
|
| Modifier and Type | Method and Description |
|---|---|
String |
getId()
Returns the ID of the entity.
|
String |
getType()
Returns the type of the entity.
|
FieldModel |
getValue(String key)
getter of single field
|
Set<FieldModel> |
getValues()
getter of entity value
|
void |
removeValue(String key)
Remove a value from completely, different from setting the value to null
|
EntityModel |
setValue(FieldModel fieldModel)
setter of single field, update if field exists
|
EntityModel |
setValues(Set<FieldModel> values)
setter of new entity value, all old fields are cleared
|
String |
toString() |
public static final String ID_FIELD_NAME
public static final String CLIENT_LOCK_STAMP_FIELD_NAME
public EntityModel()
public EntityModel(Set<FieldModel> values)
values - - a collection of field modelspublic EntityModel(Set<FieldModel> values, EntityModel.EntityState entityState)
values - - a collection of field modelsentityState - The initial state of the entity when constructing. Once these fields have been initialised
the entity is considered to be dirtypublic Set<FieldModel> getValues()
public FieldModel getValue(String key)
key - the fieldNamepublic void removeValue(String key)
key - the fieldNamepublic EntityModel setValues(Set<FieldModel> values)
values - - a collection of field modelspublic EntityModel setValue(FieldModel fieldModel)
fieldModel - the single field to updatepublic final String getType()
Entitypublic final String getId()
EntityCopyright © 2021 Micro Focus. All rights reserved.