使用ReflectData生成Avro模式的行为不一致

时间:2019-04-18 22:03:43

标签: java avro

我创建了POJO类来生成Avro模式,但是我注意到第一个Calendar类型定义与其余的没有区别。

最热门的POJO类AssetDebtDto包含:

    private Issuer issuer;
    private Instrument instrument;
    private InstrumentDebt instrumentDebt;

Issuer类具有以下私有字段:

    private String subissuerTaxableCommercialPaperIndicator;
    private Calendar issuerFiscalYearEndDate; <--- Where the definition is different
    private Calendar issuerIncorporatedDate;
    private Calendar issuerPassiveForeignInvestmentCompanyEffectiveDate;

然后在程序主体中,我有:

Schema schema = ReflectData.AllowNull.get()
                           .getSchema(AssetDebtDto.class);
String asJson = schema.toString(true);
System.out.println(asJson);

然后在输出结果中:

  }, {
    "name" : "subissuerTaxableCommercialPaperIndicator",
    "type" : [ "null", "string" ],
    "default" : null
  }, {
    "name" : "issuerFiscalYearEndDate",
    "type" : [ "null", {"type" : "record", "name" : "Calendar", "namespace" : "java.util", "fields" : [ ] } ],
    "default" : null
  }, {
    "name" : "issuerIncorporatedDate",
    "type" : [ "null", "java.util.Calendar" ],
    "default" : null
  }, {
    "name" : "issuerPassiveForeignInvestmentCompanyEffectiveDate",
    "type" : [ "null", "java.util.Calendar" ],
    "default" : null
  }, {

我注意到issuerFiscalYearEndDate类型定义(恰好是架构文档中的第一个类型)与其余java.util.Calendar字段不同。

0 个答案:

没有答案