BitCodec implements BlockCodec<Boolean> { @Override public byte[] encode(Boolean data, int bitLength) throws BlockCodecException { return data ? new byte[] { (byte) 0x80 } : new byte[] { 0x00 }; }  @Override Boolean zeroValue(); @Override Boolean decode(byte[] data, int bitLength); @Override byte[] encode(Boolean data, int bitLength); @Override void reset(); @Override String getValueType();  }
@Test public void testEncode() throws BlockCodecException { BitCodec codec = new BitCodec(); Assert.assertArrayEquals(new byte[] { (byte) 0x80 }, codec.encode(true, 1)); Assert.assertArrayEquals(new byte[] { (byte) 0x00 }, codec.encode(false, 1)); }