Java 8 機能を備えた dropwizard 1.1.0 を使用しています。Immutables パッケージも使用しています。利益センターのリスト (文字列リスト) を JSON から同等の Java に変換しようとすると、デシリアライゼーションの問題に直面しています。
エラー
非具体的なコレクション タイプ [コレクション タイプ; クラス com.google.common.collect.ImmutableList、[単純型、クラス java.lang.String]] を含む
不変の Java クラス
@Value.Immutable
@JsonSerialize(as = ImmutableReconciliationInputDTO.class)
@JsonDeserialize(as = ImmutableReconciliationInputDTO.class)
public interface ReconciliationInputDTO extends Serializable {
@JsonProperty("date")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
LocalDate asOfDate();
@JsonProperty("label")
String label();
@JsonProperty("entityId")
String entityId();
@JsonProperty("entityName")
String entityName();
@JsonProperty("departments")
List<String> departments();
イミュータブルは、上記の DTO を以下の属性を持つ最終クラスに生成しました
public final class ImmutableReconciliationInputDTO
implements ReconciliationInputDTO {
private final LocalDate asOfDate;
private final String label;
private final String entityId;
private final String entityName;
private final ImmutableList<String> departments;
私のdropwizardアプリケーションのブートストラップでは、以下のモジュールを登録しました
bootstrap.getObjectMapper().registerModule(new JavaTimeModule());
bootstrap.getObjectMapper().registerModule(new Jdk8Module());
bootstrap.getObjectMapper().registerModule(new ParameterNamesModule());
私のPOM.xmlでは、依存関係として以下を設定しています
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.7</version>
</dependency>