Use PojoSerializer and PojoDeserializer to serialize and deserialize the annotated POJO (Plain Old Java Object) to and from Candid payload of type RECORD.
Serializer and Deserializer will use Candid Java annotations to get the Candid Name and Type.
public class LoanApplication{
@Field(Type.NAT)
public BigInteger id;
public Double amount;
@Field(Type.NAT16)
public Short term;
@Name("firstname")
public String firstName;
@Name("lastname")
public String lastName;
public String ssn;
public String zipcode;
public BigInteger created;
}
LoanOffer.java
public class LoanOffer{
@Field(Type.PRINCIPAL)
@Name("providerid")
public String providerId;
@Name("providername")
public String providerName;
@Field(Type.PRINCIPAL)
@Name("userid")
public Principal userId;
@Field(Type.NAT)
@Name("applicationid")
public Integer applicationId;
public Double apr;
@Field(Type.INT)
public Long created;
}
By default, PojoSerializer and PojoDeserializer will use Java to Candid type mapping and use the Java member variable name as the name of the Candid RECORD field.
Use Candid annotations @Field to override the default type and @Name to override the default name.
To skip serialization and deserialization of certain member variables, use the @Ignore annotation.
ProxyBuilder will implicitly use PojoSerializer and PojoDeserializer to convert Candid RECORD to a Java object.