Top Description Fields Constructors Methods
com.thoughtworks.xstream.converters.javabean

public Class ComparingPropertySorter

extends Object
implements PropertySorter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.javabean.PropertySorter
Imports
java.util.Comparator, .Map, .TreeMap

A sorter that uses a comparator to determine the order of the bean properties.
Author
Jörg Schaible
Since
1.4

Field Summary

Modifier and TypeField and Description
private final Comparator<T>

Constructor Summary

AccessConstructor and Description
public
ComparingPropertySorter(final Comparator<T> propertyNameComparator)

Method Summary

Modifier and TypeMethod and Description
public Map<K, V>
sort(final Class<T>
the bean class that contains all the properties
type
,
final Map<K, V>
the map to sort, key is the property name, value the PropertyDescriptor
nameMap
)

Implements com.thoughtworks.xstream.converters.javabean.PropertySorter.sort.

Sort the properties of a bean type.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

comparatorback to summary
private final Comparator<T> comparator

Constructor Detail

ComparingPropertySorterback to summary
public ComparingPropertySorter(final Comparator<T> propertyNameComparator)

Method Detail

sortback to summary
public Map<K, V> sort(final Class<T> type, final Map<K, V> nameMap)

Implements com.thoughtworks.xstream.converters.javabean.PropertySorter.sort.

Doc from com.thoughtworks.xstream.converters.javabean.PropertySorter.sort.

Sort the properties of a bean type. The method will be called with the class type that contains all the properties 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 properties. An implementation may create a different Map with similar semantic, add all elements of the original map and return the new one.

Parameters
type:Class<T>

the bean class that contains all the properties

nameMap:Map<K, V>

the map to sort, key is the property name, value the PropertyDescriptor

Returns:Map<K, V>

the sorted nameMap