JBBPFieldArrayBit extends JBBPAbstractArrayField<JBBPFieldBit> implements BitEntity, JBBPNumericArray { @Override public Object getValueArrayAsObject(final boolean reverseBits) { final byte[] result; if (reverseBits) { result = this.array.clone(); for (int i = 0; i < result.length; i++) { result[i] = (byte) JBBPFieldBit.reverseBits(result[i], this.bitNumber); } } else { result = this.array.clone(); } return result; } JBBPFieldArrayBit(final JBBPNamedFieldInfo name, final byte[] array, final JBBPBitNumber bitNumber); byte[] getArray(); @Override JBBPBitNumber getBitWidth(); @Override int size(); @Override JBBPFieldBit getElementAt(final int index); @Override int getAsInt(final int index); @Override long getAsLong(final int index); @Override boolean getAsBool(final int index); @Override Object getValueArrayAsObject(final boolean reverseBits); @Override String getTypeAsString();  }
@Test public void testGetValueArrayAsObject() { final byte[] array = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; final JBBPFieldArrayBit test = new JBBPFieldArrayBit(new JBBPNamedFieldInfo("test.field", "field", 999), array, JBBPBitNumber.BITS_4); assertArrayEquals(array, (byte[]) test.getValueArrayAsObject(false)); final byte[] inverted = (byte[]) test.getValueArrayAsObject(true); assertEquals(array.length, inverted.length); for (int i = 0; i < array.length; i++) { assertEquals(JBBPFieldBit.reverseBits(array[i], JBBPBitNumber.BITS_4), inverted[i]); } }