use of eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType in project dwoss by gg-net.
the class ProductFormater method toSource.
public static String toSource(Product product) {
String var = randomVar();
String re = product.getClass().getSimpleName() + " " + var + " = new " + product.getClass().getName() + "();\n";
for (TradeName id : product.getAdditionalPartNos().keySet()) {
re += var + ".setAdditionalPartNo(TradeName." + id + ",\"" + product.getAdditionalPartNo(id) + "\");\n";
}
for (PriceType id : product.getPrices().keySet()) {
re += var + ".setPrice(PriceType." + id + "," + product.getPrice(id) + ",\"formToSource\");\n";
}
if (!product.getFlags().isEmpty()) {
re += var + ".setFlags(EnumSet.of(";
for (Iterator<Product.Flag> it = product.getFlags().iterator(); it.hasNext(); ) {
Product.Flag flag = it.next();
re += "Product.Flag." + flag;
if (it.hasNext())
re += ",";
}
re += "));\n";
}
if (product.getName() != null)
re += var + ".setName(\"" + product.getName() + "\");\n";
if (product.getDescription() != null)
re += var + ".setDescription(\"" + product.getDescription() + "\");\n";
if (product.getPartNo() != null)
re += var + ".setPartNo(\"" + product.getPartNo() + "\");\n";
re += var + ".setGroup(ProductGroup." + product.getGroup() + ");\n";
re += var + ".setTradeName(TradeName." + product.getTradeName() + ");\n";
re += var + ".setGtin(" + product.getGtin() + ");\n";
return re;
}
Aggregations