public class EnumValueModelConverter extends Object implements ModelConverter
| Constructor and Description |
|---|
EnumValueModelConverter(Class enumClass,
SourceTransformer sourceTransformer) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterDetach(Object model,
ModelContext ctx)
This method is executed after the given
model is attached from the given
ModelContext |
void |
beforeAttach(Object model,
ModelContext ctx)
This method is executed before the given
model is attached to the given
ModelContext |
Object |
create(String type)
Creates a new empty model instance.
|
protected boolean |
exists(HybrisEnumValue enumValue) |
boolean |
exists(Object model)
Returns
true if for the given model a source Item exists and if this item Item#isAlive() |
Object |
getAttributeValue(Object model,
String attributeQualifier)
Generic attribute value getter to read attribute data from arbitrary model instances.
|
Map<String,Set<Locale>> |
getDirtyAttributes(Object model)
Returns a map with all modified attribute qualifiers for the given model.
|
Class |
getEnumClass() |
Object |
getLocalizedAttributeValue(Object model,
String attributeQualifier,
Locale locale)
Generic attribute value getter to read attribute data from arbitrary model instances.
|
PersistenceObject |
getPersistenceSource(Object model) |
Object |
getSource(Object model)
Returns underlying source for given model.
|
String |
getType(Object model)
Returns the exact type of the given model.
|
protected Method |
getValueOfMethod() |
Set<String> |
getWritablePartOfAttributes(TypeService typeService)
Returns a collection of writable partof atrributes
|
void |
init(ConverterRegistry registry)
Called once before using the converter the first time.
|
boolean |
isJavaEnum() |
boolean |
isModified(Object model)
Returns
true if the given model is new or the ModelValueHistory of the model contains changed
attributes. |
boolean |
isModified(Object model,
String attribute)
Returns
true if the given model is new or the ModelValueHistory for the given attribute
(qualifier) was changed. |
boolean |
isModified(Object model,
String attribute,
Locale loc)
Returns
true if the given model is new or the ModelValueHistory for the given attribute
(qualifier) was changed. |
boolean |
isNew(Object model)
Returns
true if the given model was not persisted yet. |
boolean |
isRemoved(Object model)
Returns
true if for the given model no source Item exists or this item is not Item#isAlive() |
boolean |
isUpToDate(Object model)
The given model is not up-to-date (returns
false) when:
the model is new (see ModelConverter.isNew(Object)) or
the model was removed (see ModelConverter.isRemoved(Object)) or
the model was locally modified or
the Item in the database is newer as the source item of the model
|
Object |
load(Object source)
Creates a new model instance and fills its attributes with data from given source object
|
void |
reload(Object model)
Fills the attributes of passed model new using mapped source object.
|
void |
remove(Object model)
Tries to remove the source of the given model.
|
void |
save(Object model,
Collection<String> excluded)
Saves all attribute values from the model to the wrapped source object or creates a new one if no source is mapped
yet.
|
void |
setAttributeValue(Object model,
String attributeQualifier,
Object value)
Generic attribute value setter to modify attribute data on arbitrary model instances.
|
public EnumValueModelConverter(Class enumClass, SourceTransformer sourceTransformer)
public Class getEnumClass()
protected Method getValueOfMethod()
protected boolean exists(HybrisEnumValue enumValue)
public boolean isJavaEnum()
public Object create(String type)
ModelConvertercreate in interface ModelConverterpublic String getType(Object model)
ModelConvertergetType in interface ModelConverterpublic PersistenceObject getPersistenceSource(Object model)
getPersistenceSource in interface ModelConverterpublic Object getSource(Object model)
ModelConvertergetSource in interface ModelConvertermodel - the model for which to return the sourcepublic void init(ConverterRegistry registry)
ModelConverterinit in interface ModelConverterregistry - the registry holding this converter.public Object load(Object source)
ModelConverterload in interface ModelConvertersource - object which will be used for filling new modelpublic void reload(Object model)
ModelConverterreload in interface ModelConvertermodel - model which will be filled from scratch using mapped sourcepublic void remove(Object model)
ModelConverterremove in interface ModelConvertermodel - the model for which to remove the sourcepublic void save(Object model, Collection<String> excluded)
ModelConvertersave in interface ModelConvertermodel - the model to savepublic boolean isModified(Object model)
ModelConvertertrue if the given model is new or the ModelValueHistory of the model contains changed
attributes.isModified in interface ModelConvertermodel - the modelfalse otherwisepublic boolean isModified(Object model, String attribute)
ModelConvertertrue if the given model is new or the ModelValueHistory for the given attribute
(qualifier) was changed. If the attribute is localized the current session data Locale (see
LocaleProvider#getCurrentDataLocale()) is used.isModified in interface ModelConvertermodel - the modelattribute - the attribute qualifierfalse if the attribute was not modified.public boolean isModified(Object model, String attribute, Locale loc)
ModelConvertertrue if the given model is new or the ModelValueHistory for the given attribute
(qualifier) was changed. For localized attributes the given Locale is used to check for modifications. If
the Locale is null then all Locales will be checked for modifications. For non-localized attributes
the given Locale will be ignored.isModified in interface ModelConvertermodel - the modelattribute - the attribute qualifierloc - the Locale. Can be null.false otherwise.public boolean exists(Object model)
ModelConvertertrue if for the given model a source Item exists and if this item Item#isAlive()exists in interface ModelConvertermodel - the modelfalse if the model was not persisted yet (no underlying item) or the item was removed.public boolean isRemoved(Object model)
ModelConvertertrue if for the given model no source Item exists or this item is not Item#isAlive()isRemoved in interface ModelConvertermodel - the modelfalse if the model ModelConverter.isNew(Object) or the item is alive.public boolean isNew(Object model)
ModelConvertertrue if the given model was not persisted yet.isNew in interface ModelConvertermodel - the modelfalse if an AttributeProvider for the given model exists.public boolean isUpToDate(Object model)
ModelConverterfalse) when:
ModelConverter.isNew(Object)) orModelConverter.isRemoved(Object)) orisUpToDate in interface ModelConvertermodel - the modeltrue if the model is up-to-datepublic Object getAttributeValue(Object model, String attributeQualifier)
ModelConvertergetAttributeValue in interface ModelConvertermodel - the model instanceattributeQualifier - the attribute qualifierpublic Object getLocalizedAttributeValue(Object model, String attributeQualifier, Locale locale)
ModelConvertergetLocalizedAttributeValue in interface ModelConvertermodel - the model instanceattributeQualifier - the attribute qualifierlocale - Locale for which value will be returnedpublic void setAttributeValue(Object model, String attributeQualifier, Object value)
ModelConvertersetAttributeValue in interface ModelConvertermodel - the modelattributeQualifier - the attribute qualifiervalue - the attribute valuepublic void beforeAttach(Object model, ModelContext ctx)
ModelConvertermodel is attached to the given
ModelContextbeforeAttach in interface ModelConverterpublic void afterDetach(Object model, ModelContext ctx)
ModelConvertermodel is attached from the given
ModelContextafterDetach in interface ModelConverterpublic Set<String> getWritablePartOfAttributes(TypeService typeService)
ModelConvertergetWritablePartOfAttributes in interface ModelConverterpublic Map<String,Set<Locale>> getDirtyAttributes(Object model)
ModelConverternull the key is a
non-localized attribute qualifier else the map value contains the locale in which language the localized attribute
was modified.getDirtyAttributes in interface ModelConvertermodel - the new (not saved) modelCopyright © 2017 SAP SE. All Rights Reserved.