Class ComparingPropertySorter

  • All Implemented Interfaces:
    PropertySorter

    public class ComparingPropertySorter
    extends java.lang.Object
    implements PropertySorter
    A sorter that uses a comparator to determine the order of the bean properties.
    Since:
    1.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Comparator comparator  
    • Constructor Summary

      Constructors 
      Constructor Description
      ComparingPropertySorter​(java.util.Comparator propertyNameComparator)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map sort​(java.lang.Class type, java.util.Map nameMap)
      Sort the properties of a bean type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • comparator

        private final java.util.Comparator comparator
    • Constructor Detail

      • ComparingPropertySorter

        public ComparingPropertySorter​(java.util.Comparator propertyNameComparator)
    • Method Detail

      • sort

        public java.util.Map sort​(java.lang.Class type,
                                  java.util.Map nameMap)
        Description copied from interface: PropertySorter
        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.
        Specified by:
        sort in interface PropertySorter
        Parameters:
        type - the bean class that contains all the properties
        nameMap - the map to sort, key is the property name, value the PropertyDescriptor
        Returns:
        the sorted nameMap