Class MutableByte

  • All Implemented Interfaces:
    Mutable<Byte>, Serializable, Comparable<MutableByte>

    public class MutableByte
    extends Number
    implements Mutable<Byte>, Comparable<MutableByte>
    Mutable class wrapper for byte values. Mutable classes are useful in lambda expressions or anonymous classes which want to alter the content of a variable but are limited to final or effective final variables. Be aware that the hashcode changes if the value is updated resulting in the object not being retrievable in hash collections.
    Since:
    1.0.0 com.github.kilianB
    Author:
    Kilian
    See Also:
    Serialized Form
    • Constructor Detail

      • MutableByte

        public MutableByte()
        Create a mutable Boolean with an initial value of 0
      • MutableByte

        public MutableByte​(byte initialValue)
        Create a mutable Boolean
        Parameters:
        initialValue - the intial value of the byte
    • Method Detail

      • getValue

        public Byte getValue()
        Description copied from interface: Mutable
        Get an object encapsulating the current value
        Specified by:
        getValue in interface Mutable<Byte>
        Returns:
        The current value as an immutable base object
      • setValue

        public void setValue​(Byte newValue)
        Description copied from interface: Mutable
        Set the internal field to the new value
        Specified by:
        setValue in interface Mutable<Byte>
        Parameters:
        newValue - the new value
      • setValue

        public void setValue​(byte newValue)
        Set the internal field to the new value
        Parameters:
        newValue - the new value
        Since:
        1.2.0 com.github.kilianB
      • byteValue

        public byte byteValue()
        Overrides:
        byteValue in class Number
        Returns:
        the current value as byte primitive
      • hashCode

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

        public int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class Number
      • getAndIncrement

        public Byte getAndIncrement()
        Return the internal value and increment it afterwards.
        Returns:
        the value of the internal field before performing the increment operation.
        Since:
        1.2.0 com.github.kilianB
      • incrementAndGet

        public Byte incrementAndGet()
        Increment the internal value and return the result.
        Returns:
        the new value after after performing the increment operation.
        Since:
        1.2.0 com.github.kilianB
      • getAndDecrement

        public Byte getAndDecrement()
        Return the internal value and decrement it afterwards.
        Returns:
        the value of the internal field before performing the decrement operation.
        Since:
        1.2.0 com.github.kilianB
      • decrementAndGet

        public Byte decrementAndGet()
        Decrement the internal value and return the result.
        Returns:
        the new value after after performing the decrement operation.
        Since:
        1.2.0 com.github.kilianB