@Override public T read(TProtocol protocol) throws Exception { Object thriftValue = codec.read(protocol); T javaValue = (T) typeCoercion.getFromThrift().invoke(null, thriftValue); return javaValue; }
private static boolean needsCastAfterRead(ThriftFieldMetadata field, Method readMethod) { Class<?> methodReturn = readMethod.getReturnType(); Class<?> fieldType; if (field.getCoercion().isPresent()) { fieldType = field.getCoercion().get().getFromThrift().getParameterTypes()[0]; } else { fieldType = TypeToken.of(field.getThriftType().getJavaType()).getRawType(); } boolean needsCast = !fieldType.isAssignableFrom(methodReturn); return needsCast; }
read.invokeStatic(field.getCoercion().get().getFromThrift());
read.invokeStatic(field.getCoercion().get().getFromThrift());