Class BinaryValuesByte
Object
BinaryValuesByte
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionBinaryValuesByte
(byte off, byte on) Creates a newBinaryValuesByte
instance.BinaryValuesByte
(int off, int on) Create withint
values for off and on states. -
Method Summary
Modifier and TypeMethodDescriptionasInt()
Derives aBinaryValuesInt
representation from the current values.boolean
static BinaryValuesByte
Default values to use, if not otherwise specified.byte
getOff()
The byte representation of the value for off.byte
getOn()
The byte representation of the value for on.int
hashCode()
invert()
Inverts the values so off becomes on, and vice-versa.boolean
isOff
(byte value) Does a particular value correspond to the off state?boolean
isOn
(byte value) Does a particular value correspond to the on state?
-
Constructor Details
-
BinaryValuesByte
public BinaryValuesByte(int off, int on) Create withint
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 newBinaryValuesByte
instance.- Parameters:
off
- The byte representation of the value for off.on
- The byte representation of the value for on.
-
-
Method Details
-
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
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
Derives aBinaryValuesInt
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
-
hashCode
public int hashCode() -
getOff
public byte getOff()The byte representation of the value for off. -
getOn
public byte getOn()The byte representation of the value for on.
-