2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
6 package org.mxchange.pizzaapplication.product;
8 import java.lang.reflect.InvocationTargetException;
9 import java.text.MessageFormat;
10 import java.util.Objects;
11 import org.mxchange.jcore.BaseFrameworkSystem;
17 public class BaseProduct extends BaseFrameworkSystem implements Product {
19 * Availability of product
21 private Boolean available;
26 private Long category;
29 * Id number of product
44 * Getter for product availability
46 * @return Product availability
49 public final Boolean getAvailable () {
50 return this.available;
54 * Setter for product availability
56 * @param available Product availability
59 public final void setAvailable (final Boolean available) {
60 this.available = available;
64 * Getter for product category
66 * @return Product category
69 public final Long getCategory () {
74 * Setter for product category
76 * @param category Product category
79 public final void setCategory (final Long category) {
80 this.category = category;
88 public final Long getId () {
93 * Id number of product
94 * @param id the id number to set
97 public final void setId (final Long id) {
106 public final float getPrice () {
112 * @param price the price to set
115 public final void setPrice (final float price) {
124 public final String getTitle () {
130 * @param title the title to set
133 public final void setTitle (final String title) {
138 * Compares two categories with each other
140 * @param product Product comparator
141 * @return Comparison value
144 public int compareTo (final Product product) {
146 this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product));
148 // category should not be null
149 if (product == null) {
150 throw new NullPointerException("product is null");
154 this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getId(), product.getId()));
156 // Is the id the same?
157 if (Objects.equals(this.getId(), product.getId())) {
158 // Same id, means same category
160 } else if (this.getId() > product.getId()) {
161 // This id is larger than compared to
165 // The other id is larger
170 public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
172 this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName));
175 Object value = this.getValueInStoreableFromColumn(this, "BaseProduct", columnName);
178 this.getLogger().trace("value=" + value + " - EXIT!");
185 public void setValueFromColumn (final String columnName, final String value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
187 this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value));
190 this.setValueInStoreableFromColumn(this, "BaseProduct", columnName, value);
193 this.getLogger().trace("EXIT!");