Class BitwiseOperationBuilderImpl

    • 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​()
      protected static boolean isBitwiseMaskable​(int aValue, int aMask)
      Tests if the bits set in the parameter mask are also set in the parameter value.
      boolean isMaskable​(Integer 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").
      boolean isTrueAt​(int aPosition)
      Checks if is true at.
      protected 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 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 ValueAccessor.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 ValueAccessor.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 ValueAccessor.getValue() method.
      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 ValueAccessor.getValue() method.
      • Methods inherited from interface org.refcodes.mixin.ValueAccessor

        getValueOr
    • Constructor Detail

      • BitwiseOperationBuilderImpl

        public BitwiseOperationBuilderImpl​()
    • 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 ValueAccessor.getValue() method.
        Specified by:
        withAnd in interface BitwiseOperationBuilder
        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 ValueAccessor.getValue() method.
        Specified by:
        withOr in interface BitwiseOperationBuilder
        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 ValueAccessor.getValue() method.
        Specified by:
        withXor in interface BitwiseOperationBuilder
        Parameters:
        aOperand - The operand to be applied to the value property.
        Returns:
        The BitwiseOperationBuilder as of the Builder-Pattern to chain multiple operations.
      • isMaskable

        public boolean isMaskable​(Integer 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.
        Specified by:
        isMaskable in interface BitwiseOperationBuilder
        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)
        Checks if is true at.
        Specified by:
        isTrueAt in interface BitwiseOperationBuilder
        Parameters:
        aPosition - the position
        Returns:
        true, if is true at
      • 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.
      • isBitwiseMaskable

        protected static boolean isBitwiseMaskable​(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!
      • isTrueAt

        protected 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.