类 PropertyComparator<T>

  • 类型参数:
    T - the type of objects that may be compared by this comparator
    所有已实现的接口:
    Comparator<T>

    public class PropertyComparator<T>
    extends Object
    implements Comparator<T>
    PropertyComparator performs a comparison of two beans, evaluating the specified bean property via a BeanWrapper.
    从以下版本开始:
    19.05.2003
    作者:
    Juergen Hoeller, Jean-Pierre Pawlak
    另请参阅:
    BeanWrapper
    • 字段详细资料

    • 构造器详细资料

      • PropertyComparator

        public PropertyComparator​(String property,
                                  boolean ignoreCase,
                                  boolean ascending)
        Create a PropertyComparator for the given settings.
        参数:
        property - the property to compare
        ignoreCase - whether upper and lower case in String values should be ignored
        ascending - whether to sort ascending (true) or descending (false)
    • 方法详细资料

      • sort

        public static void sort​(List<?> source,
                                SortDefinition sortDefinition)
                         throws BeansException
        Sort the given List according to the given sort definition.

        Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.

        参数:
        source - the input List
        sortDefinition - the parameters to sort by
        抛出:
        IllegalArgumentException - in case of a missing propertyName
        BeansException
      • sort

        public static void sort​(Object[] source,
                                SortDefinition sortDefinition)
                         throws BeansException
        Sort the given source according to the given sort definition.

        Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.

        参数:
        source - input source
        sortDefinition - the parameters to sort by
        抛出:
        IllegalArgumentException - in case of a missing propertyName
        BeansException