org.springframework.beans.support

## 类 PropertyComparator<T>

- java.lang.Object
- - org.springframework.beans.support.PropertyComparator<T>

- 所有已实现的接口:
    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`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger`

  - ### 构造器概要

    构造器
    构造器和说明
    `PropertyComparator(SortDefinition sortDefinition)` Create a new PropertyComparator for the given SortDefinition.
    `PropertyComparator(String property, boolean ignoreCase, boolean ascending)` Create a PropertyComparator for the given settings.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `int` | `compare(T o1, T o2)`
    `SortDefinition` | `getSortDefinition()` Return the SortDefinition that this comparator uses.
    `static void` | `sort(List<?> source, SortDefinition sortDefinition)` Sort the given List according to the given sort definition.
    `static void` | `sort(Object[] source, SortDefinition sortDefinition)` Sort the given source according to the given sort definition.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### 从接口继承的方法 java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### PropertyComparator

          public PropertyComparator(SortDefinition sortDefinition)

      Create a new PropertyComparator for the given SortDefinition.
      另请参阅:
        `MutableSortDefinition`

    - #### 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)

  - ### 方法详细资料

    - #### getSortDefinition

          public final SortDefinition getSortDefinition()

      Return the SortDefinition that this comparator uses.

    - #### compare

          public int compare(T o1,
                             T o2)

      指定者:
        `compare` 在接口中 `Comparator<T>`

    - #### 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`