@Test public void testBoolDecodeGivenOffset() { assertThat(TypeDecoder.decode( "0000000000000000000000000000000000000000000000007fffffffffffffff" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000007fffffffffffffff", 64, Bool.class), is(new Bool(false))); assertThat(TypeDecoder.decode( "0000000000000000000000000000000000000000000000007fffffffffffffff" + "0000000000000000000000000000000000000000000000000000000000000001" + "0000000000000000000000000000000000000000000000007fffffffffffffff", 64, Bool.class), is(new Bool(true))); }
@SuppressWarnings("unchecked") static <T extends Type> T decode(String input, int offset, Class<T> type) { if (NumericType.class.isAssignableFrom(type)) { return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type); } else if (Address.class.isAssignableFrom(type)) { return (T) decodeAddress(input.substring(offset)); } else if (Bool.class.isAssignableFrom(type)) { return (T) decodeBool(input, offset); } else if (Bytes.class.isAssignableFrom(type)) { return (T) decodeBytes(input, offset, (Class<Bytes>) type); } else if (DynamicBytes.class.isAssignableFrom(type)) { return (T) decodeDynamicBytes(input, offset); } else if (Utf8String.class.isAssignableFrom(type)) { return (T) decodeUtf8String(input, offset); } else if (Array.class.isAssignableFrom(type)) { throw new UnsupportedOperationException( "Array types must be wrapped in a TypeReference"); } else { throw new UnsupportedOperationException( "Type cannot be encoded: " + type.getClass()); } }
TypeDecoder { @SuppressWarnings("unchecked") static <T extends Type> T decode(String input, int offset, Class<T> type) { if (NumericType.class.isAssignableFrom(type)) { return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type); } else if (Address.class.isAssignableFrom(type)) { return (T) decodeAddress(input.substring(offset)); } else if (Bool.class.isAssignableFrom(type)) { return (T) decodeBool(input, offset); } else if (Bytes.class.isAssignableFrom(type)) { return (T) decodeBytes(input, offset, (Class<Bytes>) type); } else if (DynamicBytes.class.isAssignableFrom(type)) { return (T) decodeDynamicBytes(input, offset); } else if (Utf8String.class.isAssignableFrom(type)) { return (T) decodeUtf8String(input, offset); } else if (Array.class.isAssignableFrom(type)) { throw new UnsupportedOperationException( "Array types must be wrapped in a TypeReference"); } else { throw new UnsupportedOperationException( "Type cannot be encoded: " + type.getClass()); } } }
TypeDecoder { @SuppressWarnings("unchecked") static <T extends Type> T decode(String input, int offset, Class<T> type) { if (NumericType.class.isAssignableFrom(type)) { return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type); } else if (Address.class.isAssignableFrom(type)) { return (T) decodeAddress(input.substring(offset)); } else if (Bool.class.isAssignableFrom(type)) { return (T) decodeBool(input, offset); } else if (Bytes.class.isAssignableFrom(type)) { return (T) decodeBytes(input, offset, (Class<Bytes>) type); } else if (DynamicBytes.class.isAssignableFrom(type)) { return (T) decodeDynamicBytes(input, offset); } else if (Utf8String.class.isAssignableFrom(type)) { return (T) decodeUtf8String(input, offset); } else if (Array.class.isAssignableFrom(type)) { throw new UnsupportedOperationException( "Array types must be wrapped in a TypeReference"); } else { throw new UnsupportedOperationException( "Type cannot be encoded: " + type.getClass()); } }  }
TypeDecoder { @SuppressWarnings("unchecked") static <T extends Type> T decode(String input, int offset, Class<T> type) { if (NumericType.class.isAssignableFrom(type)) { return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type); } else if (Address.class.isAssignableFrom(type)) { return (T) decodeAddress(input.substring(offset)); } else if (Bool.class.isAssignableFrom(type)) { return (T) decodeBool(input, offset); } else if (Bytes.class.isAssignableFrom(type)) { return (T) decodeBytes(input, offset, (Class<Bytes>) type); } else if (DynamicBytes.class.isAssignableFrom(type)) { return (T) decodeDynamicBytes(input, offset); } else if (Utf8String.class.isAssignableFrom(type)) { return (T) decodeUtf8String(input, offset); } else if (Array.class.isAssignableFrom(type)) { throw new UnsupportedOperationException( "Array types must be wrapped in a TypeReference"); } else { throw new UnsupportedOperationException( "Type cannot be encoded: " + type.getClass()); } }  static T decode(
            String input, int offset, TypeReference<T> typeReference); }
TypeDecoder { @SuppressWarnings("unchecked") static <T extends Type> T decode(String input, int offset, Class<T> type) { if (NumericType.class.isAssignableFrom(type)) { return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type); } else if (Address.class.isAssignableFrom(type)) { return (T) decodeAddress(input.substring(offset)); } else if (Bool.class.isAssignableFrom(type)) { return (T) decodeBool(input, offset); } else if (Bytes.class.isAssignableFrom(type)) { return (T) decodeBytes(input, offset, (Class<Bytes>) type); } else if (DynamicBytes.class.isAssignableFrom(type)) { return (T) decodeDynamicBytes(input, offset); } else if (Utf8String.class.isAssignableFrom(type)) { return (T) decodeUtf8String(input, offset); } else if (Array.class.isAssignableFrom(type)) { throw new UnsupportedOperationException( "Array types must be wrapped in a TypeReference"); } else { throw new UnsupportedOperationException( "Type cannot be encoded: " + type.getClass()); } }  static T decode(
            String input, int offset, TypeReference<T> typeReference);  }