Couchbase响应未映射到实体

时间:2019-01-25 04:01:33

标签: java json jackson couchbase

我有一个如下的文档。每当我获取我的文档并将其映射到实体模型时,它都无法正确映射。我在实体模型中使用了Immutable。我希望我的文档返回countryConfigMap。它给了我countryCountMap的空值,尽管如果我仅获得CountryConfig时我得到的是正确的值。好像杰克逊无法将我的文档映射到我的实体模型图。

CouchbaseOperationResult<CountryConfigMap> result = couchbaseDAO.getByKey(key);
        OperationStatus.StatusCode status = result.getStatusCode();

结果:

CountryConfigMap{countryConfig={}}

Couchbase文档:

{
  "USD": {
    "functionalCurrency": "sfd",
    "dataCenter": "safds",
    "licenseType": "asdsf"
  },
  "EUR": {
    "functionalCurrency": "sfd",
    "dataCenter": "safds",
    "licenseType": "asdsf"
  }
}

CountryConfig.java

@Value.Immutable
@JsonSerialize
@JsonDeserialize(as = ImmutableCountryConfig.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public interface CountryConfig {

    /**
     * Functional currency code for country
     *
     * @return
     */
    @Value.Parameter
    String getFunctionalCurrency();

    /**
     *
     * data center for country
     *
     * @return
     */
    @Value.Parameter
    String getDataCenter();

    /**
     *
     * license type for country
     *
     */
    @Value.Parameter
    String getLicenseType();


}

CountryConfigMap.java

@Value.Immutable
@JsonSerialize
@JsonDeserialize(as = ImmutableCountryConfigMap.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class CountryConfigMap {


    /**
     *
     * Country Config Map
     *
     * @return
     */
    @Nonnull
    @Value.Parameter
    abstract Map<String, CountryConfig> getCountryConfig();


}

0 个答案:

没有答案