ColorCodec implements BlockCodec<Color> { @Override public byte[] encode(Color data, int bitLength) throws BlockCodecException { return new byte[] { (byte) data.getRed(), (byte) data.getGreen(), (byte) data.getBlue() }; }  @Override Color zeroValue(); @Override Color decode(byte[] data, int bitLength); @Override byte[] encode(Color data, int bitLength); @Override void reset(); @Override String getValueType();  }
@Test public void testEncode() throws BlockCodecException { ColorCodec codec = new ColorCodec(); byte[] rgb = codec.encode(Color.blue, 24); Assert.assertArrayEquals(new byte[] { 0x00, 0x00, (byte) 0xff }, rgb); }