2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jshopcore.model.category;
19 import java.text.MessageFormat;
20 import java.util.Objects;
21 import org.mxchange.jcoreee.BaseEeSystem;
24 * A general product category class
26 * @author Roland Haeder
28 public abstract class BaseCategory extends BaseEeSystem implements Category {
32 private static final long serialVersionUID = 38_472_937_685_901L;
35 * Id number of category
37 private Long categoryId;
40 * Parent category categoryId
42 private Long parentId;
50 * Constructor which accepts all database fields
52 * @param categoryId Id number of database record
53 * @param title Category title
54 * @param parentId Parent categoryId
56 protected BaseCategory (final Long categoryId, final String title, final Long parentId) {
58 this.categoryId = categoryId;
60 this.parentId = parentId;
66 protected BaseCategory () {
70 * Compares two categories with each other
72 * @param category Category comparator
73 * @return Comparison value
76 public int compareTo (final Category category) {
78 this.getLogger().logTrace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N
80 // category should not be null
81 if (null == category) {
82 throw new NullPointerException("category is null"); //NOI18N
86 this.getLogger().logDebug(MessageFormat.format("this.id={0},category.id={1}", this.getCategoryId(), category.getCategoryId())); //NOI18N
88 // Is the categoryId the same?
89 if (Objects.equals(this.getCategoryId(), category.getCategoryId())) {
90 // Same categoryId, means same category
92 } else if (this.getCategoryId() > category.getCategoryId()) {
93 // This categoryId is larger than compared to
97 // The other categoryId is larger
102 * Id number of category
104 * @return the categoryId
107 public Long getCategoryId () {
108 return this.categoryId;
112 * Id number of category
114 * @param categoryId the categoryId to set
117 public void setCategoryId (final Long categoryId) {
118 this.categoryId = categoryId;
122 * Parent category categoryId
124 * @return the parentId
127 public Long getParentId () {
128 return this.parentId;
132 * Parent category categoryId
134 * @param parentId the parentId to set
137 public void setParentId (final Long parentId) {
138 this.parentId = parentId;
147 public String getTitle () {
154 * @param title the title to set
157 public void setTitle (final String title) {