Class EnumMapper
java.lang.Object
com.thoughtworks.xstream.mapper.MapperWrapper
com.thoughtworks.xstream.mapper.EnumMapper
Mapper that handles the special case of polymorphic enums in Java 1.5. This renames MyEnum$1 to MyEnum making it less
bloaty in the XML and avoiding the need for an alias per enum value to be specified. Additionally every enum is
treated automatically as immutable and non-refrenceable type that can be written as attribute.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AttributeMapperprivate Map<Class, SingleValueConverter> -
Constructor Summary
ConstructorsConstructorDescriptionEnumMapper(Mapper wrapped) EnumMapper(Mapper wrapped, ConverterLookup lookup) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetConverterFromAttribute(Class definedIn, String attribute, Class type) Returns which converter to use for an specific attribute in a type.getConverterFromItemType(String fieldName, Class type, Class definedIn) Returns a single value converter to be used in a specific field.private SingleValueConvertergetLocalConverter(String fieldName, Class type, Class definedIn) booleanisImmutableValueType(Class type) Whether this type is a simple immutable value (int, boolean, String, URL, etc).booleanisReferenceable(Class type) Whether this type is referenceable in a stream.private ObjectserializedClass(Class type) How a class name should be represented in its serialized form.Methods inherited from class MapperWrapper
aliasForAttribute, aliasForAttribute, aliasForSystemAttribute, attributeForAlias, attributeForAlias, defaultImplementationOf, getConverterFromAttribute, getConverterFromAttribute, getConverterFromItemType, getConverterFromItemType, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, getLocalConverter, isIgnoredElement, lookupMapperOfType, realClass, realMember, serializedMember, shouldSerializeMember
-
Field Details
-
attributeMapper
-
enumConverterMap
-
-
Constructor Details
-
EnumMapper
Deprecated.As of 1.3.1, useEnumMapper(Mapper) -
EnumMapper
-
-
Method Details
-
serializedClass
Description copied from interface:MapperHow a class name should be represented in its serialized form.- Specified by:
serializedClassin interfaceMapper- Overrides:
serializedClassin classMapperWrapper
-
isImmutableValueType
Description copied from interface:MapperWhether this type is a simple immutable value (int, boolean, String, URL, etc). Immutable types will be repeatedly written in the serialized stream, instead of using object references.- Specified by:
isImmutableValueTypein interfaceMapper- Overrides:
isImmutableValueTypein classMapperWrapper
-
isReferenceable
Description copied from interface:MapperWhether this type is referenceable in a stream.- Specified by:
isReferenceablein interfaceMapper- Overrides:
isReferenceablein classMapperWrapper
-
getConverterFromItemType
Description copied from interface:MapperReturns a single value converter to be used in a specific field.- Specified by:
getConverterFromItemTypein interfaceMapper- Overrides:
getConverterFromItemTypein classMapperWrapper- Parameters:
fieldName- the field nametype- the field typedefinedIn- the type which defines this field- Returns:
- a SingleValueConverter or null if there no such converter should be used for this field.
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(Class definedIn, String attribute, Class type) Description copied from interface:MapperReturns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttributein interfaceMapper- Overrides:
getConverterFromAttributein classMapperWrapper- Parameters:
definedIn- the field's parentattribute- the attribute nametype- the type the converter should create
-
getLocalConverter
-
flushCache
public void flushCache()- Specified by:
flushCachein interfaceCaching
-
readResolve
-
EnumMapper(Mapper)