* @return An instance of a Storeable implementation
*/
@Override
- public Storeable toStoreable (final Map<String, String> map) {
- throw new UnsupportedOperationException("Not supported yet: map=" + map);
+ public Storeable toStoreable (final Map<String, String> 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<Map.Entry<String, String>> iterator = map.entrySet().iterator();
+
+ // Init object instance
+ Storeable instance = new PizzaProduct();
+
+ // Iterate over all
+ while (iterator.hasNext()) {
+ // Get next entry
+ Map.Entry<String, String> 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
* @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 () {
}
/**