Package com.exedio.cope.pattern
Class EnumMapField<K extends Enum<K>,V>
- java.lang.Object
-
- com.exedio.cope.Feature
-
- com.exedio.cope.Pattern
-
- com.exedio.cope.pattern.EnumMapField<K,V>
-
- All Implemented Interfaces:
MapFieldInterface<K,V>
,Settable<EnumMap<K,V>>
,Serializable
public final class EnumMapField<K extends Enum<K>,V> extends Pattern implements Settable<EnumMap<K,V>>, MapFieldInterface<K,V>
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <K extends Enum<K>,V>
EnumMapField<K,V>create(Class<K> keyClass, FunctionField<V> value)
EnumMapField<K,V>
defaultTo(K key, V value)
SetValue<?>[]
execute(EnumMap<K,V> value, Item exceptionItem)
EnumMapField<K,V>
fallback()
EnumMapField<K,V>
fallbackTo(K key)
V
get(Item item, K key)
Returns value associated with given key for item.FunctionField<V>
getAttribute(K key)
Deprecated.renamed togetField(Enum)
.K
getFallback()
FunctionField<V>
getField(K key)
Function<V>
getFunctionWithFallback(K key)
Set<Class<? extends Throwable>>
getInitialExceptions()
Returns the exceptions possibly thrown, when setting a value for this settable.Type
getInitialType()
Class<K>
getKeyClass()
Returns the Key Class of this.Map<K,V>
getMap(Item item)
Returns the map for given item.Map<K,V>
getMapWithFallback(Item item)
Class<V>
getValueClass()
Returns the Value Class of this.FunctionField<V>
getValueTemplate()
V
getWithFallback(Item item, K key)
boolean
hasFallbacks()
boolean
isFinal()
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later.boolean
isInitial()
Returns true, if a value for the settable should be specified on the creation of an item.boolean
isMandatory()
static <K extends Enum<K>,V>
EnumMapField<K,V>newMap(Class<K> keyClass, FunctionField<V> value)
Deprecated.Usecreate(Class,FunctionField)
insteadvoid
set(Item item, K key, V value)
Sets value associated with given key for item.void
setMap(Item item, Map<? extends K,? extends V> map)
Sets the map for given item.-
Methods inherited from class com.exedio.cope.Pattern
addSource, addSource, addSource, addSource, addSourceFeature, addSourceFeature, addSourceFeature, annotationField, equals, getGeneratedTypes, getSourceFeatures, getSourceFeaturesGather, getSourceFields, getSources, getSourceTypes, getType, hashCode, initialize, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newType, newType, onMount, registerSource
-
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
-
-
-
Method Detail
-
create
public static <K extends Enum<K>,V> EnumMapField<K,V> create(Class<K> keyClass, FunctionField<V> value)
-
fallbackTo
public EnumMapField<K,V> fallbackTo(K key)
-
fallback
public EnumMapField<K,V> fallback()
- See Also:
CopeEnumFallback
,fallbackTo(Enum)
-
defaultTo
public EnumMapField<K,V> defaultTo(K key, V value)
-
getKeyClass
public Class<K> getKeyClass()
Description copied from interface:MapFieldInterface
Returns the Key Class of this.- Specified by:
getKeyClass
in interfaceMapFieldInterface<K extends Enum<K>,V>
-
getField
public FunctionField<V> getField(K key)
-
getValueTemplate
public FunctionField<V> getValueTemplate()
-
getValueClass
public Class<V> getValueClass()
Description copied from interface:MapFieldInterface
Returns the Value Class of this.- Specified by:
getValueClass
in interfaceMapFieldInterface<K extends Enum<K>,V>
-
get
public V get(@Nonnull Item item, @Nonnull K key)
Description copied from interface:MapFieldInterface
Returns value associated with given key for item.
-
set
public void set(@Nonnull Item item, @Nonnull K key, V value)
Description copied from interface:MapFieldInterface
Sets value associated with given key for item.
-
getMap
@Nonnull public Map<K,V> getMap(@Nonnull Item item)
Description copied from interface:MapFieldInterface
Returns the map for given item.
-
setMap
public void setMap(@Nonnull Item item, @Nonnull Map<? extends K,? extends V> map)
Description copied from interface:MapFieldInterface
Sets the map for given item.
-
isFinal
public boolean isFinal()
Description copied from interface:Settable
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later.
-
isMandatory
public boolean isMandatory()
- Specified by:
isMandatory
in interfaceSettable<K extends Enum<K>>
-
getInitialType
public Type getInitialType()
- Specified by:
getInitialType
in interfaceSettable<K extends Enum<K>>
-
isInitial
public boolean isInitial()
Description copied from interface:Settable
Returns true, if a value for the settable should be specified on the creation of an item.
-
getInitialExceptions
public Set<Class<? extends Throwable>> getInitialExceptions()
Description copied from interface:Settable
Returns the exceptions possibly thrown, when setting a value for this settable.- Specified by:
getInitialExceptions
in interfaceSettable<K extends Enum<K>>
-
hasFallbacks
public boolean hasFallbacks()
-
getFallback
public K getFallback()
-
newMap
@Deprecated public static <K extends Enum<K>,V> EnumMapField<K,V> newMap(Class<K> keyClass, FunctionField<V> value)
Deprecated.Usecreate(Class,FunctionField)
instead
-
getAttribute
@Deprecated public FunctionField<V> getAttribute(K key)
Deprecated.renamed togetField(Enum)
.
-
-