@Test public void testStaticBytes() { Bytes staticBytes = new Bytes6(new byte[] { 0, 1, 2, 3, 4, 5 }); assertThat(TypeEncoder.encodeBytes(staticBytes), is("0001020304050000000000000000000000000000000000000000000000000000")); Bytes empty = new Bytes1(new byte[] { 0 }); assertThat(TypeEncoder.encodeBytes(empty), is("0000000000000000000000000000000000000000000000000000000000000000")); Bytes dave = new Bytes4("dave".getBytes()); assertThat(TypeEncoder.encodeBytes(dave), is("6461766500000000000000000000000000000000000000000000000000000000")); }
static String encodeBytes(BytesType bytesType) { byte[] value = bytesType.getValue(); int length = value.length; int mod = length % Type.MAX_BYTE_LENGTH; byte[] dest; if (mod != 0) { int padding = Type.MAX_BYTE_LENGTH - mod; dest = new byte[length + padding]; System.arraycopy(value, 0, dest, 0, length); } else { dest = value; } return Numeric.toHexStringNoPrefix(dest); }
TypeEncoder { static String encodeBytes(BytesType bytesType) { byte[] value = bytesType.getValue(); int length = value.length; int mod = length % Type.MAX_BYTE_LENGTH; byte[] dest; if (mod != 0) { int padding = Type.MAX_BYTE_LENGTH - mod; dest = new byte[length + padding]; System.arraycopy(value, 0, dest, 0, length); } else { dest = value; } return Numeric.toHexStringNoPrefix(dest); } }
TypeEncoder { static String encodeBytes(BytesType bytesType) { byte[] value = bytesType.getValue(); int length = value.length; int mod = length % Type.MAX_BYTE_LENGTH; byte[] dest; if (mod != 0) { int padding = Type.MAX_BYTE_LENGTH - mod; dest = new byte[length + padding]; System.arraycopy(value, 0, dest, 0, length); } else { dest = value; } return Numeric.toHexStringNoPrefix(dest); } private  TypeEncoder(); }
TypeEncoder { static String encodeBytes(BytesType bytesType) { byte[] value = bytesType.getValue(); int length = value.length; int mod = length % Type.MAX_BYTE_LENGTH; byte[] dest; if (mod != 0) { int padding = Type.MAX_BYTE_LENGTH - mod; dest = new byte[length + padding]; System.arraycopy(value, 0, dest, 0, length); } else { dest = value; } return Numeric.toHexStringNoPrefix(dest); } private  TypeEncoder(); @SuppressWarnings("unchecked") static String encode(Type parameter); }
TypeEncoder { static String encodeBytes(BytesType bytesType) { byte[] value = bytesType.getValue(); int length = value.length; int mod = length % Type.MAX_BYTE_LENGTH; byte[] dest; if (mod != 0) { int padding = Type.MAX_BYTE_LENGTH - mod; dest = new byte[length + padding]; System.arraycopy(value, 0, dest, 0, length); } else { dest = value; } return Numeric.toHexStringNoPrefix(dest); } private  TypeEncoder(); @SuppressWarnings("unchecked") static String encode(Type parameter);  }