Package org.refcodes.numerical
Class BitwiseOperationBuilderImpl
- java.lang.Object
-
- org.refcodes.numerical.BitwiseOperationBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.ValueAccessor<java.lang.Integer>
,org.refcodes.mixin.ValueAccessor.ValueBuilder<java.lang.Integer,BitwiseOperationBuilder>
,org.refcodes.mixin.ValueAccessor.ValueMutator<java.lang.Integer>
,org.refcodes.mixin.ValueAccessor.ValueProperty<java.lang.Integer>
,BitwiseOperationBuilder
public class BitwiseOperationBuilderImpl extends java.lang.Object implements BitwiseOperationBuilder
The Class BitwiseOperationBuilderImpl.- Author:
- steiner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor
org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends java.lang.Object,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends java.lang.Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description BitwiseOperationBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.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(java.lang.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(java.lang.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(java.lang.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 theValueAccessor.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 theValueAccessor.getValue()
method.BitwiseOperationBuilder
withOr(java.lang.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 theValueAccessor.getValue()
method.BitwiseOperationBuilder
withXor(java.lang.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 theValueAccessor.getValue()
method.-
Methods inherited from interface org.refcodes.numerical.BitwiseOperationBuilder
withValue
-
-
-
-
Method Detail
-
getValue
public java.lang.Integer getValue()
- Specified by:
getValue
in interfaceorg.refcodes.mixin.ValueAccessor<java.lang.Integer>
-
setValue
public void setValue(java.lang.Integer aValue)
- Specified by:
setValue
in interfaceorg.refcodes.mixin.ValueAccessor.ValueMutator<java.lang.Integer>
-
withAnd
public BitwiseOperationBuilder withAnd(java.lang.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 theValueAccessor.getValue()
method.- Specified by:
withAnd
in interfaceBitwiseOperationBuilder
- 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(java.lang.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 theValueAccessor.getValue()
method.- Specified by:
withOr
in interfaceBitwiseOperationBuilder
- 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(java.lang.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 theValueAccessor.getValue()
method.- Specified by:
withXor
in interfaceBitwiseOperationBuilder
- 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 theValueAccessor.getValue()
method.- Specified by:
withNot
in interfaceBitwiseOperationBuilder
- Returns:
- The
BitwiseOperationBuilder
as of the Builder-Pattern to chain multiple operations.
-
isMaskable
public boolean isMaskable(java.lang.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 interfaceBitwiseOperationBuilder
- 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 interfaceBitwiseOperationBuilder
- 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.
-
-