Class SortableFieldKeySorter
- java.lang.Object
-
- com.thoughtworks.xstream.converters.reflection.SortableFieldKeySorter
-
- All Implemented Interfaces:
FieldKeySorter,Caching
public class SortableFieldKeySorter extends java.lang.Object implements FieldKeySorter, Caching
The default implementation for sorting fields. Invoke registerFieldOrder in order to set the field order for an specific type.- Since:
- 1.2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSortableFieldKeySorter.FieldComparator
-
Field Summary
Fields Modifier and Type Field Description private static FieldKey[]EMPTY_FIELD_KEY_ARRAYprivate java.util.Mapmap
-
Constructor Summary
Constructors Constructor Description SortableFieldKeySorter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflushCache()voidregisterFieldOrder(java.lang.Class type, java.lang.String[] fields)Registers the field order to use for a specific type.java.util.Mapsort(java.lang.Class type, java.util.Map keyedByFieldKey)Sort the fields of a type.
-
-
-
Field Detail
-
EMPTY_FIELD_KEY_ARRAY
private static final FieldKey[] EMPTY_FIELD_KEY_ARRAY
-
map
private final java.util.Map map
-
-
Method Detail
-
sort
public java.util.Map sort(java.lang.Class type, java.util.Map keyedByFieldKey)Description copied from interface:FieldKeySorterSort the fields of a type. The method will be called with the class type that contains all the fields and a Map that retains the order in which the elements have been added. The sequence in which elements are returned by an iterator defines the processing order of the fields. An implementation may create a different Map with similar semantic, add all elements of the original map and return the new one.- Specified by:
sortin interfaceFieldKeySorter- Parameters:
type- the class that contains all the fieldskeyedByFieldKey- a Map containing aFieldKeyas key element and aFieldas value.- Returns:
- a Map with all the entries of the original Map
-
registerFieldOrder
public void registerFieldOrder(java.lang.Class type, java.lang.String[] fields)Registers the field order to use for a specific type. This will not affect any of the type's super or sub classes. If you skip a field which will be serialized, XStream will thrown aConversionExceptionduring the serialization process.- Parameters:
type- the typefields- the field order
-
flushCache
public void flushCache()
- Specified by:
flushCachein interfaceCaching
-
-