We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When mapping multiple fields to a map AND one of those fields is null all members listed before this field in class are lost (map is set to null).
`public class Source {
@JMap("map") private String id; @JMap("map") private Integer quantity; @JMap("map") private Date purchase; public String getId() { return id; } public void setId(String id) { this.id = id; } public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } public Date getPurchase() { return purchase; } public void setPurchase(Date purchase) { this.purchase = purchase; } @JMapConversion(from = { "id", "quantity", "purchase" }, to = "map", type = Type.DYNAMIC) public static String toAttributeConversion() { return " ${destination} = (${destination} != null ? ${destination} : new java.util.HashMap());" + " System.out.println(\"Converting: \" + \"${source.name}\"); " + " ${destination}.put(\"${source.name}\", ${source}); " + " return ${destination}; "; }
}
public class Destination {
private HashMap<String, Object> map; public HashMap<String, Object> getMap() { return map; } public void setMap(HashMap<String, Object> map) { this.map = map; }
public class Main {
public static void main(String[] args) { Source s = new Source(); s.setId("Id"); s.setPurchase(new Date()); JMapper<Destination, Source> mapper = new JMapper<Destination, Source>(Destination.class, Source.class); Destination d = mapper.getDestination(s); System.out.println(d.getMap().toString()); }
} ` Output: Converting: id Converting: purchase {purchase=Thu Oct 12 14:04:53 CEST 2017}
Perhaps that is the wrong way to do it?
Thx for your help. Kevin
The text was updated successfully, but these errors were encountered:
Hi @khirschmann,
I need to do a test, let you know as soon as possible
Sorry, something went wrong.
Hi @khirschmann, I need to do a test, let you know as soon as possible
Have you done this test?
No branches or pull requests
When mapping multiple fields to a map AND one of those fields is null all members listed before this field in class are lost (map is set to null).
`public class Source {
}
public class Destination {
}
public class Main {
}
`
Output:
Converting: id
Converting: purchase
{purchase=Thu Oct 12 14:04:53 CEST 2017}
Perhaps that is the wrong way to do it?
Thx for your help.
Kevin
The text was updated successfully, but these errors were encountered: