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 newBinaryValuesByteinstance.BinaryValuesByte(int off, int on) Create withintvalues for off and on states. -
Method Summary
Modifier and TypeMethodDescriptionasInt()Derives aBinaryValuesIntrepresentation from the current values.booleanstatic BinaryValuesByteDefault values to use, if not otherwise specified.bytegetOff()The byte representation of the value for off.bytegetOn()The byte representation of the value for on.inthashCode()invert()Inverts the values so off becomes on, and vice-versa.booleanisOff(byte value) Does a particular value correspond to the off state?booleanisOn(byte value) Does a particular value correspond to the on state?
-
Constructor Details
-
BinaryValuesByte
public BinaryValuesByte(int off, int on) Create withintvalues 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 newBinaryValuesByteinstance.- 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
BinaryValuesBytewith 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
BinaryValuesBytewith the off and on values switched.
-
asInt
Derives aBinaryValuesIntrepresentation 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.
-