ProtoStream annotations with Java 17 Records #10805
Answered
by
tristantarrant
davidmestr
asked this question in
Q&A
-
We are testing to use Infinispan cache with java records. It is working with java serialisation marshaller and records implementing Serializable, bu we want to know if is posible to use protobuf, more specifically if java records can be annotated with protostream annotations. |
Beta Was this translation helpful? Give feedback.
Answered by
tristantarrant
Apr 12, 2023
Replies: 1 comment 1 reply
-
We made it work adding the annotated constructor and the annotated getters (or standard record access methods) to the record. public record ProductVipRcd(String id, String name, Double price, Integer discount) {
@ProtoFactory
public ProductVipRcd(String id, String name, Double price, Integer discount) {
this.id = id;
this.name = name;
this.price = price;
this.discount = discount;
}
@ProtoField(1)
public String id() {
return this.id;
}
@ProtoField(2)
public String name() {
return this.name;
}
@ProtoField(3)
public Double price() {
return this.price;
}
@ProtoField(4)
public Integer discount() {
return this.discount;
}
} Although it works, it's a bit strange and unnatural. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey David, we plan to add this in Protostream 5, once we can move fully to JDK 17