私はアプリケーションを開発して春にしています。オブジェクトマッピングにはModelMapperライブラリを使用しています。
基本的なクラス マッピングをマップすることはできますが、2 つのコレクション要素をマップしようとすると、ソースは名前や説明などの追加プロパティを持つ列挙のセットになり、宛先は ID、名前、説明を持つ pojo になります。
マッピング プロファイルで typemap とコンバーターを試しましたが、マッパーの例外が発生しています。
ソースクラスは他のアプリケーションからのものです(その依存関係は pom.xml に追加されています)。また、宛先のセッターの引数としてソースタイプを使用したくありません。
元。
ソース:
public class VType{
private int id;
private String name;
private String description;
}
public class VDTO{
private Set<VType> vTypes;
public Set<VType> getVTypes(){
return this.vTypes;
}
public void setVType() { //here I don't want to pass source type as an argument
//code stuff that I don't know what to do here
}
}
ソース列挙:
public enum SourceVType{
V1(1, "Name1", "Desc1");
V2(2, "Name2", "Desc2");
private Integer id;
private String name;
private String description;
SourceVType(Integer id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
}
//getter-setter
}