我有
class P{
@ProtoField(number=1, CollectionImplementation=ArrayList.class)
List<? extends Account> accounts;
@ProtoField(number=2)
ZonedDateTime fromDate;
@ProtoFactory
P(List<? extends Account> accounts, ZonedDateTime fromDate) {
this.accounts=accounts;
this.fromDate=fromDate;
}
}
Proto 模式构建器为
@AutoProtoBuilder(
basePackages="com.domain",
schemaFileName="abc.proto",
schemaFilePath="proto/",
schemaPackageName="pkg_abc")
Public interface ProtoInitializer extends GeneratedSchema {
}
账户可以
SavingAccount extends Account{
name_sa;
}
ChequingAccount extends Account{
holder_ca;
}
在建设的同时 Org.infinispan.protostream.annotations.ProtoSchemaBuilderExveption:类 java .time.ZonedDateTime 必须可以使用可访问的无参构造函数来实例化
和 java.lang.IllegalStateException:意外的类型种类:WILDCARD
如何为这些生成架构
以下适配器应该可以工作:
@ProtoAdapter(ZonedDateTime.class)
public final class ZonedDateTimeAdapter {
@ProtoFactory
ZonedDateTime create(long epochSecond, String zoneId) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(epochSecond), ZoneId.of(zoneId));
}
@ProtoField(number = 1, type = Type.UINT64)
long getEpochSecond(ZonedDateTime zdt) {
return zdt.toEpochSecond();
}
@ProtoField(number = 2, type = Type.STRING)
String getZoneId(ZonedDateTime zdt) {
return zdt.getZone().getId();
}
}