Class BitwiseOperationBuilder

  • All Implemented Interfaces:
    org.refcodes.mixin.ValueAccessor<Integer>, org.refcodes.mixin.ValueAccessor.ValueBuilder<Integer,​BitwiseOperationBuilder>, org.refcodes.mixin.ValueAccessor.ValueMutator<Integer>, org.refcodes.mixin.ValueAccessor.ValueProperty<Integer>

    public class BitwiseOperationBuilder
    extends Object
    implements org.refcodes.mixin.ValueAccessor.ValueProperty<Integer>, org.refcodes.mixin.ValueAccessor.ValueBuilder<Integer,​BitwiseOperationBuilder>
    The bitwise operation builder applies bitwise operations to a given value being set via setValue(Integer) or (as of the Builder-Pattern) withValue(Integer).
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor

        org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends Object,​B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,​B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends Object>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Integer getValue()
      boolean isMaskable​(int aMask)
      Tests if the bits set in the mask argument are also set in the value property ("the value property is maskable with the given mask").
      static boolean isMaskable​(int aValue, int aMask)
      Tests if the bits set in the parameter mask are also set in the parameter value.
      boolean isTrueAt​(int aPosition)
      Tests f the value is true at the given position.
      static boolean isTrueAt​(int aValue, int aPos)
      Tests whether the bit at the given position is set in the parameter value and returns true if this is the case.
      void setValue​(Integer aValue)
      protected static String[] toBitStrings​(int aValueA, int aValueB)
      Returns an array of binary strings as a representation of the integer input values in base 2.
      protected static int toBitwiseAND​(int aValueA, int aValueB)
      The result of this method is a contransceiver of the parameters valueA and valueB.
      protected static int toBitwiseNOT​(int aValue)
      The result of this method is the negation of the given value.
      protected static int toBitwiseOR​(int aValueA, int aValueB)
      The result of this method is a distransceiver of the parameters valueA and valueB.
      protected static int toBitwiseXOR​(int aValueA, int aValueB)
      The result of this method is an exclusive distransceiver of the parameters valueA and valueB.
      BitwiseOperationBuilder withAnd​(Integer aOperand)
      Applies a bitwise AND operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
      BitwiseOperationBuilder withNot()
      Applies a bitwise NOT operation to the value property ; the value is updated accordingly and the result can be retrieved with the getValue() method.
      BitwiseOperationBuilder withOr​(Integer aOperand)
      Applies a bitwise OR operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
      BitwiseOperationBuilder withValue​(Integer aValue)
      BitwiseOperationBuilder withXor​(Integer aOperand)
      Applies a bitwise XOR operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
      • Methods inherited from interface org.refcodes.mixin.ValueAccessor

        getValueOr
      • Methods inherited from interface org.refcodes.mixin.ValueAccessor.ValueProperty

        letValue
    • Constructor Detail

      • BitwiseOperationBuilder

        public BitwiseOperationBuilder()
    • Method Detail

      • getValue

        public Integer getValue()
        Specified by:
        getValue in interface org.refcodes.mixin.ValueAccessor<Integer>
      • setValue

        public void setValue​(Integer aValue)
        Specified by:
        setValue in interface org.refcodes.mixin.ValueAccessor.ValueMutator<Integer>
      • withAnd

        public BitwiseOperationBuilder withAnd​(Integer aOperand)
        Applies a bitwise AND operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
        Parameters:
        aOperand - The operand to be applied to the value property.
        Returns:
        The BitwiseOperationBuilder as of the Builder-Pattern to chain multiple operations.
      • withOr

        public BitwiseOperationBuilder withOr​(Integer aOperand)
        Applies a bitwise OR operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
        Parameters:
        aOperand - The operand to be applied to the value property.
        Returns:
        The BitwiseOperationBuilder as of the Builder-Pattern to chain multiple operations.
      • withXor

        public BitwiseOperationBuilder withXor​(Integer aOperand)
        Applies a bitwise XOR operation to the value property with the given operand; the value is updated accordingly and the result can be retrieved with the getValue() method.
        Parameters:
        aOperand - The operand to be applied to the value property.
        Returns:
        The BitwiseOperationBuilder as of the Builder-Pattern to chain multiple operations.
      • withNot

        public BitwiseOperationBuilder withNot()
        Applies a bitwise NOT operation to the value property ; the value is updated accordingly and the result can be retrieved with the getValue() method.
        Returns:
        The BitwiseOperationBuilder as of the Builder-Pattern to chain multiple operations.
      • isMaskable

        public boolean isMaskable​(int aMask)
        Tests if the bits set in the mask argument are also set in the value property ("the value property is maskable with the given mask"). If this is the case true is returned. Else false is returned. Additionally bits set in the value property are not considered in the result. The bit-length of the mask may not be the same as the bit-length of the value.
        Parameters:
        aMask - The mask which's true bits are to be verified against the value property.
        Returns:
        True in case the value property is maskable by the given mask.
      • isTrueAt

        public boolean isTrueAt​(int aPosition)
        Tests f the value is true at the given position.
        Parameters:
        aPosition - The bit position to test.
        Returns:
        True, if the value is true at the given position.
      • isTrueAt

        public static boolean isTrueAt​(int aValue,
                                       int aPos)
        Tests whether the bit at the given position is set in the parameter value and returns true if this is the case. Else false is returned. Also Returns false if an index out of range is provided. CATION: This method may not be very optimized!
        Parameters:
        aValue - The value interpreted as a bit-field.
        aPos - The position of the bit-field to be tested.
        Returns:
        True in case the bit in the bit-field at the given position is true.
      • isMaskable

        public static boolean isMaskable​(int aValue,
                                         int aMask)
        Tests if the bits set in the parameter mask are also set in the parameter value. If this is the case true is returned. Else false is returned. Additionally bits set in the parameter value are not considered in the result. The bit-length of the mask may not be the same as the bit-length of the value. CATION: This method may not be very optimized!
        Parameters:
        aValue - The value to see if the true values in the mask are also true in the value.
        aMask - The mask which's true values are to be verified against the provided value.
        Returns:
        Description is currently not available!
      • toBitwiseAND

        protected static int toBitwiseAND​(int aValueA,
                                          int aValueB)
        The result of this method is a contransceiver of the parameters valueA and valueB. The operation is a bitwise logical AND.
        Parameters:
        aValueA - Value A to be used.
        aValueB - Value B to be used.
        Returns:
        The boolean result of the bitwise AND.
      • toBitwiseNOT

        protected static int toBitwiseNOT​(int aValue)
        The result of this method is the negation of the given value. The operation is a bitwise logical NOT.
        Parameters:
        aValue - Value to be used.
        Returns:
        The boolean result of the bitwise NOT.
      • toBitwiseOR

        protected static int toBitwiseOR​(int aValueA,
                                         int aValueB)
        The result of this method is a distransceiver of the parameters valueA and valueB. The operation is a bitwise logical OR.
        Parameters:
        aValueA - Value A to be used.
        aValueB - Value B to be used.
        Returns:
        The boolean result of the bitwise OR.
      • toBitwiseXOR

        protected static int toBitwiseXOR​(int aValueA,
                                          int aValueB)
        The result of this method is an exclusive distransceiver of the parameters valueA and valueB. The operation is a bitwise logical XOR.
        Parameters:
        aValueA - Value A to be used.
        aValueB - Value B to be used.
        Returns:
        The boolean result of the bitwise XOR.
      • toBitStrings

        protected static String[] toBitStrings​(int aValueA,
                                               int aValueB)
        Returns an array of binary strings as a representation of the integer input values in base 2.
        Parameters:
        aValueA - The first value for which to get the string.
        aValueB - The second value for which to get the string.
        Returns:
        The array with the strings containing the according bit-fields.