Class BinaryValuesByte

Object
BinaryValuesByte
All Implemented Interfaces:
Serializable

public final class BinaryValuesByte extends Object implements Serializable
Two values representing byte binary states in an UnsignedByteBuffer.

By default, these states are 0 for off and -1 (identical to 255) for on.

This class is immutable.

See BinaryValuesInt for an equivalent class that stores these states as int.

Author:
Owen Feehan
See Also:
  • Constructor Details

    • BinaryValuesByte

      public BinaryValuesByte(int off, int on)
      Create with int values for off and on states.
      Parameters:
      off - value for the off state.
      on - value for the on state.
    • BinaryValuesByte

      public BinaryValuesByte(byte off, byte on)
      Creates a new BinaryValuesByte instance.
      Parameters:
      off - The byte representation of the value for off.
      on - The byte representation of the value for on.
  • Method Details

    • getDefault

      public static BinaryValuesByte getDefault()
      Default values to use, if not otherwise specified.
      Returns:
      a static instance BinaryValuesByte with default values (see class description).
    • isOn

      public boolean isOn(byte value)
      Does a particular value correspond to the on state?
      Parameters:
      value - the value to check.
      Returns:
      true iff it's identical to the on value.
    • isOff

      public boolean isOff(byte value)
      Does a particular value correspond to the off state?
      Parameters:
      value - the value to check.
      Returns:
      true iff it's identical to the off value.
    • invert

      public BinaryValuesByte invert()
      Inverts the values so off becomes on, and vice-versa.

      This is an immutable operation.

      Returns:
      a BinaryValuesByte with the off and on values switched.
    • asInt

      public BinaryValuesInt asInt()
      Derives a BinaryValuesInt representation from the current values.

      This is a similar structure but holds unsigned int values rather than byte values.

      Returns:
      a newly derived BinaryValuesByte.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getOff

      public byte getOff()
      The byte representation of the value for off.
    • getOn

      public byte getOn()
      The byte representation of the value for on.