From: Roland Haeder Date: Fri, 14 Aug 2015 22:47:29 +0000 (+0200) Subject: toStoreable() is now "basicly finished" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a89ac369ea17d356130c01cf019f12297c0b3732;p=pizzaservice-war.git toStoreable() is now "basicly finished" Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java index decfe147..993d10a8 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -309,8 +309,45 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement * @return An instance of a Storeable implementation */ @Override - public Storeable toStoreable (final Map map) { - throw new UnsupportedOperationException("Not supported yet: map=" + map); + public Storeable toStoreable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + // Trace message + this.getLogger().trace("map=" + map + " - CALLED!"); + + // Is map null? + if (map == null) { + // Is null + throw new NullPointerException("map is null"); + } else if (map.isEmpty()) { + // Map is empty + throw new IllegalArgumentException("map is empty."); + } + + // Debug message + this.getLogger().debug("Has to handle " + map.size() + " entries"); + + // Get iterator on all entries + Iterator> iterator = map.entrySet().iterator(); + + // Init object instance + Storeable instance = new PizzaProduct(); + + // Iterate over all + while (iterator.hasNext()) { + // Get next entry + Map.Entry entry = iterator.next(); + + // Debug message + this.getLogger().debug("entry:" + entry.getKey() + "=" + entry.getValue()); + + // Try to set value + instance.setValueFromColumn(entry.getKey(), entry.getValue()); + } + + // Trace message + this.getLogger().trace("instance=" + instance + " - EXIT!"); + + // Return it + return instance; } @Override diff --git a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java index c6881a7f..7070029d 100644 --- a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java +++ b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java @@ -25,24 +25,10 @@ import org.mxchange.pizzaapplication.product.Product; * @author Roland Haeder */ public class PizzaProduct extends BaseProduct implements Product { - /** - * Constructor for products with a name and a price. - * - * @param id Id number of product - * @param title Name of product - * @param price Price - * @deprecated Please use constructor with category and available + * Default constructor */ - @Deprecated - public PizzaProduct (final Long id, final String title, final Float price) { - // Trace message - this.getLogger().trace("id=" + id + ",title=" + title + ",price=" + price + " - CALLED!"); - - // Set all - this.setId(id); - this.setTitle(title); - this.setPrice(price); + public PizzaProduct () { } /**