]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/product/BaseProduct.java
Moved stuff around + added dist.sh
[jcustomer-core.git] / src / org / mxchange / jshopcore / model / product / BaseProduct.java
1 /*
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.
5  */
6 package org.mxchange.jshopcore.model.product;
7
8 import java.text.MessageFormat;
9 import java.util.Objects;
10 import org.mxchange.jshopcore.BaseShopCore;
11
12 /**
13  *
14  * @author Roland Haeder
15  */
16 public class BaseProduct extends BaseShopCore implements Product {
17         /**
18          * Availability of product
19          */
20         private Boolean available;
21
22         /**
23          * Product category
24          */
25         private Long categoryId;
26
27         /**
28          * Id number of product item
29          */
30         private Long itemId;
31
32         /**
33          * Price of product
34          */
35         private Float price;
36
37         /**
38          * Title of product
39          */
40         private String title;
41
42         @Override
43         public int compareTo (final Product product) {
44                 // Trace message
45                 this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
46                 
47                 // category should not be null
48                 if (null == product) {
49                         throw new NullPointerException("product is null"); //NOI18N
50                 }
51                 
52                 // Debug message
53                 this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getItemId(), product.getItemId())); //NOI18N
54                 
55                 // Is the id the same?
56                 if (Objects.equals(this.getItemId(), product.getItemId())) {
57                         // Same id, means same category
58                         return 0;
59                 } else if (this.getItemId() > product.getItemId()) {
60                         // This id is larger than compared to
61                         return 1;
62                 }
63                 
64                 // The other id is larger
65                 return -1;
66         }
67
68         @Override
69         public final Boolean getAvailable () {
70                 return this.available;
71         }
72
73         @Override
74         public final void setAvailable (final Boolean available) {
75                 this.available = available;
76         }
77
78         @Override
79         public final Long getCategoryId () {
80                 return this.categoryId;
81         }
82
83         @Override
84         public final void setCategoryId (final Long categoryId) {
85                 this.categoryId = categoryId;
86         }
87
88         @Override
89         public final Long getItemId () {
90                 return this.itemId;
91         }
92
93         @Override
94         public final void setItemId (final Long itemId) {
95                 this.itemId = itemId;
96         }
97
98         @Override
99         public final Float getPrice () {
100                 return this.price;
101         }
102
103         @Override
104         public final void setPrice (final Float price) {
105                 this.price = price;
106         }
107
108         @Override
109         public final String getTitle () {
110                 return this.title;
111         }
112
113         @Override
114         public final void setTitle (final String title) {
115                 this.title = title;
116         }
117 }