Получение ошибки ниже при попытке построить класс mapper.
Error:(20,48) java: The type of parameter "quote" has no property named "quote_type".
Error:(15,53) java: Unknown property "quote_type" in return type.
Error:(20,48) java: Property "type" has no write accessor.
Класс Mapper указан ниже
@Mapper(componentModel = "spring")
public interface SourceDestinationMapper {
@Mappings({
@Mapping(target = "quote_type", source= "quoteFromSource.type")
})
Quote sourceToDestination(QuoteFromSource quoteFromSource);
@Mappings({
@Mapping(target = "type", source = "quote.quote_type")
})
QuoteFromSource destinationToSource(Quote quote);
Value sourceValueToDestinationValue(ValueFromSource valueFromSource);
ValueFromSource sourceValueToDestinationValue(Value value);
}
Класс Source указан ниже
public class Quote {
@JsonProperty("quote_type")
private String type;
@JsonProperty("quote_value")
private Value value;
}
Класс Destination указан ниже
public class QuoteFromSource {
@JsonProperty("type")
private String type;
@JsonProperty("value")
private ValueFromSource value;
}
исходный класс
public class Value {
@JsonProperty("quote_id")
private Integer id;
@JsonProperty("quote_description")
private String quote;
}
целевой класс
public class ValueFromSource {
@JsonProperty("id")
private Integer id;
@JsonProperty("quote")
private String quote;
}
Пример JSON для десериализации:
{
"quote_type": "auto",
"quote_value": {
"quote_id": 10,
"quote_description": "This is my first quote"
}
}