de.caff.generics.function

## Interface ByteOrdering

- All Known Subinterfaces:
    ByteOrdering.Serial, IntOrdering, IntOrdering.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 ByteOrdering

  Define an order for two primitive byte values.

  Compared to a `Comparator<Byte>` this can avoid boxing and unboxing in various situations.

  Since:
    January 23, 2023
  Author:
    Rammi

- - ### Nested Class Summary

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

  - ### Field Summary

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

  - ### Method Summary

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

- - ### Field Detail

    - #### ASCENDING

          static final ByteOrdering ASCENDING

      Natural order of ascending `byte` values.

    - #### DESCENDING

          static final ByteOrdering DESCENDING

      Inverse natural order of `byte` values.

    - #### UNSIGNED_ASCENDING

          static final ByteOrdering UNSIGNED_ASCENDING

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

    - #### UNSIGNED_DESCENDING

          static final ByteOrdering UNSIGNED_DESCENDING

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

  - ### Method Detail

    - #### checkByte

          @NotNull
          Order checkByte(byte v1,
                                   byte v2)

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

    - #### ascending

          default boolean ascending(byte v1,
                                    byte 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(byte, byte)`, `ascendingOrSame(byte, byte)`, `descendingOrSame(byte, byte)`, `same(byte, byte)`, `different(byte, byte)`

    - #### ascendingOrSame

          default boolean ascendingOrSame(byte v1,
                                          byte 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(byte, byte)`, `descending(byte, byte)`, `descendingOrSame(byte, byte)`, `same(byte, byte)`, `different(byte, byte)`

    - #### descending

          default boolean descending(byte v1,
                                     byte 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(byte, byte)`, `ascendingOrSame(byte, byte)`, `descendingOrSame(byte, byte)`, `same(byte, byte)`, `different(byte, byte)`

    - #### descendingOrSame

          default boolean descendingOrSame(byte v1,
                                           byte 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(byte, byte)`, `descending(byte, byte)`, `ascendingOrSame(byte, byte)`, `same(byte, byte)`, `different(byte, byte)`

    - #### same

          default boolean same(byte v1,
                               byte 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(byte, byte)`, `descending(byte, byte)`, `ascendingOrSame(byte, byte)`, `descendingOrSame(byte, byte)`, `different(byte, byte)`

    - #### different

          default boolean different(byte v1,
                                    byte 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(byte, byte)`, `descending(byte, byte)`, `ascendingOrSame(byte, byte)`, `descendingOrSame(byte, byte)`, `same(byte, byte)`

    - #### inverse

          @NotNull
          default ByteOrdering inverse()

      Invert this order.
      Returns:
        inverse order

    - #### asByteComparator

          @NotNull
          default java.util.Comparator<java.lang.Byte> asByteComparator()

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

    - #### asNumberComparator

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

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

    - #### asByteOrdering

          @NotNull
          default Ordering<java.lang.Byte> asByteOrdering()

      Get this ordering as a generic byte ordering.
      Returns:
        generic ordering for bytes

    - #### fromComparator

          @NotNull
          static ByteOrdering fromComparator(@NotNull
                                                      java.util.Comparator<java.lang.Byte> comparator)

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