Package com.helger.commons.mutable
Class MutableByte
- java.lang.Object
-
- java.lang.Number
-
- com.helger.commons.mutable.AbstractMutableNumeric<IMPLTYPE>
-
- com.helger.commons.mutable.AbstractMutableInteger<MutableByte>
-
- com.helger.commons.mutable.MutableByte
-
- All Implemented Interfaces:
IComparable<MutableByte>,ICloneable<MutableByte>,IMutableInteger<MutableByte>,IMutableNumeric<MutableByte>,IMutableObject<MutableByte>,INumber,IGenericImplTrait<MutableByte>,Serializable,Comparable<MutableByte>
@NotThreadSafe public class MutableByte extends AbstractMutableInteger<MutableByte>
Object wrapper around a byte so that it can be passed a final object but is mutable.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableByte(byte nValue)Initialize with a certain value.MutableByte(int nValue)Initialize with a certain int value.MutableByte(Number aValue)Initialize with a certain value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytebyteValue()Returns the value of the specified number as abyte, which may involve rounding or truncation.intcompareTo(MutableByte rhs)intdec()intdec(int nDelta)intdec(Number aDelta)doubledoubleValue()Returns the value of the specified number as adouble, which may involve rounding.booleanequals(Object o)floatfloatValue()Returns the value of the specified number as afloat, which may involve rounding.bytegetAndInc()MutableBytegetClone()inthashCode()intinc()Increment by 1 and return the modified value.intinc(int nDelta)intinc(Number aDelta)byteincAndGet()intintValue()Returns the value of the specified number as anint, which may involve rounding or truncation.booleanis0()booleanisEven()booleanisGE0()booleanisGT0()booleanisLE0()booleanisLT0()longlongValue()Returns the value of the specified number as along, which may involve rounding or truncation.EChangeset(byte nValue)EChangeset(int nValue)EChangeset(Number aValue)StringtoString()-
Methods inherited from class com.helger.commons.mutable.AbstractMutableNumeric
onAfterChange
-
Methods inherited from class java.lang.Number
shortValue
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.compare.IComparable
isEQ, isGE, isGT, isLE, isLT, isNE
-
Methods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Methods inherited from interface com.helger.commons.mutable.IMutableInteger
isOdd
-
Methods inherited from interface com.helger.commons.mutable.IMutableNumeric
getAsBigDecimal, getAsBigInteger, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsShort, isNot0
-
Methods inherited from interface com.helger.commons.mutable.INumber
shortValue
-
-
-
-
Constructor Detail
-
MutableByte
public MutableByte(int nValue)
Initialize with a certain int value. If the value does not fit into a byte, the value is cut!- Parameters:
nValue- The value to be used.
-
MutableByte
public MutableByte(@Nonnull Number aValue)
Initialize with a certain value.- Parameters:
aValue- The value to be used.
-
MutableByte
public MutableByte(byte nValue)
Initialize with a certain value.- Parameters:
nValue- The value to be used.
-
-
Method Detail
-
byteValue
public byte byteValue()
Description copied from interface:INumberReturns the value of the specified number as abyte, which may involve rounding or truncation.This implementation returns the result of
INumber.intValue()cast to abyte.
-
floatValue
public float floatValue()
Description copied from interface:INumberReturns the value of the specified number as afloat, which may involve rounding.- Specified by:
floatValuein interfaceINumber- Specified by:
floatValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
float.
-
doubleValue
public double doubleValue()
Description copied from interface:INumberReturns the value of the specified number as adouble, which may involve rounding.- Specified by:
doubleValuein interfaceINumber- Specified by:
doubleValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
double.
-
intValue
public int intValue()
Description copied from interface:INumberReturns the value of the specified number as anint, which may involve rounding or truncation.
-
longValue
public long longValue()
Description copied from interface:INumberReturns the value of the specified number as along, which may involve rounding or truncation.
-
inc
public int inc()
Increment by 1 and return the modified value.- Returns:
- The by 1 incremented value.
-
inc
public int inc(int nDelta)
-
dec
public int dec()
-
dec
public int dec(int nDelta)
-
is0
public boolean is0()
- Returns:
trueif the value is 0
-
isLT0
public boolean isLT0()
- Returns:
trueif the value is < 0
-
isLE0
public boolean isLE0()
- Returns:
trueif the value is ≤ 0
-
isGT0
public boolean isGT0()
- Returns:
trueif the value is > 0
-
isGE0
public boolean isGE0()
- Returns:
trueif the value is ≥ 0
-
isEven
public boolean isEven()
- Returns:
trueif the value is even
-
getAndInc
public byte getAndInc()
-
incAndGet
public byte incAndGet()
-
compareTo
public int compareTo(@Nonnull MutableByte rhs)
-
getClone
@Nonnull public MutableByte getClone()
- Returns:
- A 100% deep-copy of the implementing class.
-
-