org.springframework.util.comparator

## 类 InstanceComparator<T>

- java.lang.Object
- - org.springframework.util.comparator.InstanceComparator<T>

- 类型参数:
    `T` - the type of objects being compared
  所有已实现的接口:
    Comparator<T>

      public class InstanceComparator<T>
      extends Object
      implements Comparator<T>

  Compares objects based on an arbitrary class order. Allows objects to be sorted based on the types of class that they inherit, for example: this comparator can be used to sort a list `Number`s such that `Long`s occur before `Integer`s.

  Only the specified `instanceOrder` classes are considered during comparison. If two objects are both instances of the ordered type this comparator will return a `0`. Consider combining with `Comparator.thenComparing(Comparator)` if additional sorting is required.

  从以下版本开始:
    3.2
  作者:
    Phillip Webb
  另请参阅:
    `Comparator.thenComparing(Comparator)`

- - ### 构造器概要

    构造器
    构造器和说明
    `InstanceComparator(Class<?>... instanceOrder)` Create a new `InstanceComparator` instance.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `int` | `compare(T o1, T o2)`

    - ### 从类继承的方法 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`

- - ### 构造器详细资料

    - #### InstanceComparator

          public InstanceComparator(Class<?>... instanceOrder)

      Create a new `InstanceComparator` instance.
      参数:
        `instanceOrder` - the ordered list of classes that should be used when comparing objects. Classes earlier in the list will be given a higher priority.

  - ### 方法详细资料

    - #### compare

          public int compare(T o1,
                             T o2)

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