/** * Defines the generics bridge method with untyped args to the type specific read method. */ private void defineReadBridgeMethod() { Parameter protocol = arg("protocol", TProtocolReader.class); MethodDefinition method = new MethodDefinition( classDefinition, a(PUBLIC, BRIDGE, SYNTHETIC), "read", type(Object.class), protocol) .addException(Exception.class); method.getBody().append(method.getThis() .invoke("read", structType, ImmutableList.of(protocol)) .ret()); classDefinition.addMethod(method); }
/** * Defines the generics bridge method with untyped args to the type specific write method. */ private void defineWriteBridgeMethod() { Parameter struct = arg("struct", Object.class); Parameter protocol = arg("protocol", TProtocolWriter.class); MethodDefinition method = new MethodDefinition( classDefinition, a(PUBLIC, BRIDGE, SYNTHETIC), "write", null, struct, protocol) .addException(Exception.class); method.getBody().append(method.getThis() .invoke("write", type(void.class), ImmutableList.of(structType, protocol.getType()), ImmutableList.of(struct.cast(structType), protocol)) .ret()); classDefinition.addMethod(method); }