BrightSide Workbench Full Report + Source Code
IProductKey.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.financials.product;
20 
21 import org.turro.util.CompareUtil;
22 
27 public class IProductKey implements Comparable<IProductKey> {
28 
29  private long productId, providerId, providerProductId;
30  private String productDescription;
31 
32  public IProductKey() {
33  }
34 
35  public IProductKey(long productId, long providerId, long providerProductId, String productDescription) {
36  this.productId = productId;
37  this.providerId = providerId;
38  this.providerProductId = providerProductId;
39  this.productDescription = productDescription;
40  }
41 
42  public long getProductId() {
43  return productId;
44  }
45 
46  public long getProviderId() {
47  return providerId;
48  }
49 
50  public long getProviderProductId() {
51  return providerProductId;
52  }
53 
54  public String getProductDescription() {
55  return productDescription;
56  }
57 
58  public void setProductId(long productId) {
59  this.productId = productId;
60  }
61 
62  public void setProviderId(long providerId) {
63  this.providerId = providerId;
64  }
65 
66  public void setProviderProductId(long providerProductId) {
67  this.providerProductId = providerProductId;
68  }
69 
70  public void setProductDescription(String productDescription) {
71  this.productDescription = productDescription;
72  }
73 
74  @Override
75  public int compareTo(IProductKey o) {
76  int result = CompareUtil.compare(productId, o.productId);
77  if(result == 0) {
78  result = CompareUtil.compare(providerId, o.providerId);
79  }
80  if(result == 0) {
81  result = CompareUtil.compare(providerProductId, o.providerProductId);
82  }
83  if(result == 0) {
84  result = CompareUtil.compare(productDescription, o.productDescription);
85  }
86  return result;
87  }
88 
89  @Override
90  public int hashCode() {
91  int hash = 5;
92  hash = 89 * hash + (int) (this.productId ^ (this.productId >>> 32));
93  hash = 89 * hash + (int) (this.providerId ^ (this.providerId >>> 32));
94  hash = 89 * hash + (int) (this.providerProductId ^ (this.providerProductId >>> 32));
95  hash = 89 * hash + (this.productDescription != null ? this.productDescription.hashCode() : 0);
96  return hash;
97  }
98 
99  @Override
100  public boolean equals(Object obj) {
101  if (obj == null) {
102  return false;
103  }
104  if (getClass() != obj.getClass()) {
105  return false;
106  }
107  final IProductKey other = (IProductKey) obj;
108  if (this.productId != other.productId) {
109  return false;
110  }
111  if (this.providerId != other.providerId) {
112  return false;
113  }
114  if (this.providerProductId != other.providerProductId) {
115  return false;
116  }
117  if ((this.productDescription == null) ? (other.productDescription != null) : !this.productDescription.equals(other.productDescription)) {
118  return false;
119  }
120  return true;
121  }
122 
123 }
void setProviderProductId(long providerProductId)
IProductKey(long productId, long providerId, long providerProductId, String productDescription)
void setProductDescription(String productDescription)