Interface Ranked

All Known Implementing Classes:
Bean, Id

public interface Ranked
An interface whose implementations can be ranked numerically in descending order (highest rank wins, or comes first).

In addition, an implementation may be designated as an alternate, which may affect the interpretation of the implementation's rank.

Given a series of Ranked implementations sorted by rank, the first element of the series will bear the greatest rank.

Author:
Laird Nelson
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default rank (0) when returned by an implementation of the rank() method.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Returns true if this Ranked is to be considered an alternate, which may have an effect on how the return value of the rank() method is interpreted in some situations.
    default boolean
    outranks(int j)
    Returns true if this Ranked bears a rank that outranks the rank represented by j according to the rules described in the specification for the outranks(int, int) method.
    static boolean
    outranks(int i, int j)
    Returns true if and only if a rank represented by i outranks a rank represented by j.
    default boolean
    Returns true if this Ranked outranks the supplied Ranked according to the rules described in the specification for the outranks(int, int) method.
    static boolean
    Returns true if and only if r0 is non-null and outranks r1.
    default int
    Returns the rank of this Ranked implementation.
  • Field Details

  • Method Details

    • rank

      default int rank()
      Returns the rank of this Ranked implementation.

      Implementations of this method may return any integer: positive, zero, or negative.

      The default implementation of this method returns the value of the DEFAULT_RANK field (0).

      Overrides of this method must return a determinate value.

      Returns:
      the rank of this Ranked implementation
      See Also:
    • alternate

      default boolean alternate()
      Returns true if this Ranked is to be considered an alternate, which may have an effect on how the return value of the rank() method is interpreted in some situations.

      The default implementation of this method returns false.

      Overrides of this method must be idempotent and return a determinate value.

      Returns:
      true if this Ranked is to be considered an alternate
    • outranks

      default boolean outranks(Ranked other)
      Returns true if this Ranked outranks the supplied Ranked according to the rules described in the specification for the outranks(int, int) method.

      Overriding this method, while possible and permitted, is discouraged.

      Parameters:
      other - a Ranked; may be null (in which case this method will return true)
      Returns:
      true if this Ranked outranks the supplied Ranked
      See Also:
    • outranks

      default boolean outranks(int j)
      Returns true if this Ranked bears a rank that outranks the rank represented by j according to the rules described in the specification for the outranks(int, int) method.

      Overriding this method, while possible and permitted, is discouraged.

      Parameters:
      j - a rank
      Returns:
      true if this Ranked bears a rank that outranks the supplied rank
      See Also:
    • outranks

      static boolean outranks(Ranked r0, Ranked r1)
      Returns true if and only if r0 is non-null and outranks r1.
      Parameters:
      r0 - a Ranked; may be null in which case false will be returned
      r1 - a Ranked; may be null
      Returns:
      true if and only if r0 is non-null and outranks r1
      See Also:
    • outranks

      static boolean outranks(int i, int j)
      Returns true if and only if a rank represented by i outranks a rank represented by j.

      Given two ranks, i and j, i outranks j if and only if i is greater than (>) j.

      Parameters:
      i - an int representing a rank
      j - an int representing a rank
      Returns:
      true if and only if i outranks j
      Idempotency:
      This method is idempotent and deterministic.
      Thread Safety:
      This method is safe for concurrent use by multiple threads.