de.caff.generics.function

## Interface LongOrdering

- All Known Subinterfaces:
    LongOrdering.Serial
  Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

      @FunctionalInterface
      public interface LongOrdering

  Define an order for two primitive long values.

  Compared to a `Comparator<Long>` this can avoid boxing and unboxing in various situations. For this use the `checkLong(long, long)` method, the `check(Long, Long)` method is only for situations where this is used as a generic ordering (which requires boxing and unboxing).

  Since:
    January 23, 2023
  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `LongOrdering.Serial` A long ordering which is serializable.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static LongOrdering` | `ASCENDING` Natural order of ascending `long` values.
    `static LongOrdering` | `DESCENDING` Inverse natural order of `long` values.
    `static LongOrdering` | `UNSIGNED_ASCENDING` Natural order of ascending unsigned `long` values.
    `static LongOrdering` | `UNSIGNED_DESCENDING` Natural order of ascending unsigned `long` values.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default boolean` | `ascending(long v1, long v2)` Are the two values represented in strictly ascending order?
    `default boolean` | `ascendingOrSame(long v1, long v2)` Are the two values represented in ascending order?
    `default java.util.Comparator<java.lang.Long>` | `asLongComparator()` Use this ordering as a comparator.
    `default Ordering<java.lang.Long>` | `asLongOrdering()` Get this ordering as a generic long ordering.
    `default java.util.Comparator<java.lang.Number>` | `asNumberComparator()` View this ordering as a number comparator.
    `default Order` | `check(java.lang.Long v1, java.lang.Long v2)`
    `Order` | `checkLong(long v1, long v2)` Get the order of the two values.
    `default boolean` | `descending(long v1, long v2)` Are the two values represented in strictly descending order?
    `default boolean` | `descendingOrSame(long v1, long v2)` Are the two values represented in descending order?
    `default boolean` | `different(long v1, long v2)` Are the two values considered different by this order?
    `static LongOrdering` | `fromComparator(java.util.Comparator<java.lang.Long> comparator)` Convert a standard comparator of `Double` into a double ordering.
    `default LongOrdering` | `inverse()` Invert this order.
    `default boolean` | `same(long v1, long v2)` Are the two values considered equal by this order?

- - ### Field Detail

    - #### ASCENDING

          static final LongOrdering ASCENDING

      Natural order of ascending `long` values.

    - #### DESCENDING

          static final LongOrdering DESCENDING

      Inverse natural order of `long` values.

    - #### UNSIGNED_ASCENDING

          static final LongOrdering UNSIGNED_ASCENDING

      Natural order of ascending unsigned `long` values. This handles long values as if they are unsigned and not signed.

    - #### UNSIGNED_DESCENDING

          static final LongOrdering UNSIGNED_DESCENDING

      Natural order of ascending unsigned `long` values. This handles long values as if they are unsigned and not signed.

  - ### Method Detail

    - #### checkLong

          @NotNull
          Order checkLong(long v1,
                                   long v2)

      Get the order of the two values.
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        order of the two values

    - #### check

          @NotNull
          default Order check(java.lang.Long v1,
                                       java.lang.Long v2)

    - #### ascending

          default boolean ascending(long v1,
                                    long v2)

      Are the two values represented in strictly ascending order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 < v2` according to this ordering
        `false` if `v1 >= v2` according to this ordering
      See Also:
        `descending(long, long)`, `ascendingOrSame(long, long)`, `descendingOrSame(long, long)`, `same(long, long)`, `different(long, long)`

    - #### ascendingOrSame

          default boolean ascendingOrSame(long v1,
                                          long v2)

      Are the two values represented in ascending order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 <= v2` according to this ordering
        `false` if `v1 > v2` according to this ordering
      See Also:
        `ascending(long, long)`, `descending(long, long)`, `descendingOrSame(long, long)`, `same(long, long)`, `different(long, long)`

    - #### descending

          default boolean descending(long v1,
                                     long v2)

      Are the two values represented in strictly descending order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 > v2` according to this ordering
        `false` if `v1 <= v2` according to this ordering
      See Also:
        `ascending(long, long)`, `ascendingOrSame(long, long)`, `descendingOrSame(long, long)`, `same(long, long)`, `different(long, long)`

    - #### descendingOrSame

          default boolean descendingOrSame(long v1,
                                           long v2)

      Are the two values represented in descending order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 >= v2` according to this ordering
        `false` if `v1 < v2` according to this ordering
      See Also:
        `ascending(long, long)`, `descending(long, long)`, `ascendingOrSame(long, long)`, `same(long, long)`, `different(long, long)`

    - #### same

          default boolean same(long v1,
                               long v2)

      Are the two values considered equal by this order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 == v2` according to this order
        `false` if `v1 != v2` according to this ordering
      See Also:
        `ascending(long, long)`, `descending(long, long)`, `ascendingOrSame(long, long)`, `descendingOrSame(long, long)`, `different(long, long)`

    - #### different

          default boolean different(long v1,
                                    long v2)

      Are the two values considered different by this order?
      Parameters:
        `v1` - first value
        `v2` - second value
      Returns:
        `true` if `v1 != v2` according to this order
        `false` if `v1 == v2` according to this ordering
      See Also:
        `ascending(long, long)`, `descending(long, long)`, `ascendingOrSame(long, long)`, `descendingOrSame(long, long)`, `same(long, long)`

    - #### inverse

          @NotNull
          default LongOrdering inverse()

      Invert this order.
      Returns:
        inverse order

    - #### asLongComparator

          @NotNull
          default java.util.Comparator<java.lang.Long> asLongComparator()

      Use this ordering as a comparator.
      Returns:
        comparator of `Long`

    - #### asNumberComparator

          @NotNull
          default java.util.Comparator<java.lang.Number> asNumberComparator()

      View this ordering as a number comparator.
      Returns:
        comparator of `Number`

    - #### asLongOrdering

          @NotNull
          default Ordering<java.lang.Long> asLongOrdering()

      Get this ordering as a generic long ordering.
      Returns:
        generic ordering for longs

    - #### fromComparator

          @NotNull
          static LongOrdering fromComparator(@NotNull
                                                      java.util.Comparator<java.lang.Long> comparator)

      Convert a standard comparator of `Double` into a double ordering.
      Parameters:
        `comparator` - comparator of `Double`
      Returns:
        ordering