1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.util;
17
18 import org.apache.commons.lang.builder.CompareToBuilder;
19 import org.apache.commons.lang.builder.EqualsBuilder;
20 import org.apache.commons.lang.builder.HashCodeBuilder;
21 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
22
23 public class VendorGroupingHelper implements Comparable {
24 private Integer vendorHeaderGeneratedIdentifier;
25 private Integer vendorDetailAssignedIdentifier;
26 private String vendorCountry;
27 private String vendorPostalCode;
28
29 public VendorGroupingHelper(PurchasingAccountsPayableDocument doc) {
30 vendorHeaderGeneratedIdentifier = doc.getVendorHeaderGeneratedIdentifier();
31 vendorDetailAssignedIdentifier = doc.getVendorDetailAssignedIdentifier();
32 vendorCountry = doc.getVendorCountryCode();
33 vendorPostalCode = doc.getVendorPostalCode();
34 if (vendorPostalCode != null && vendorPostalCode.length() > 5) {
35 vendorPostalCode = vendorPostalCode.substring(0, 5);
36 }
37 }
38
39 public Integer getVendorHeaderGeneratedIdentifier() {
40 return vendorHeaderGeneratedIdentifier;
41 }
42
43 public Integer getVendorDetailAssignedIdentifier() {
44 return vendorDetailAssignedIdentifier;
45 }
46
47 public String getVendorCountry() {
48 return vendorCountry;
49 }
50
51 public String getVendorPostalCode() {
52 return vendorPostalCode;
53 }
54
55
56
57
58 public String toString() {
59 return vendorHeaderGeneratedIdentifier + "-" + vendorDetailAssignedIdentifier + "-" + vendorCountry + "-" + vendorPostalCode;
60 }
61
62
63
64
65 public boolean equals(Object object) {
66 if (!(object instanceof VendorGroupingHelper)) {
67 return false;
68 }
69 VendorGroupingHelper rhs = (VendorGroupingHelper) object;
70 return new EqualsBuilder().append(
71 this.vendorPostalCode, rhs.vendorPostalCode).append(
72 this.vendorHeaderGeneratedIdentifier, rhs.vendorHeaderGeneratedIdentifier).append(
73 this.vendorDetailAssignedIdentifier, rhs.vendorDetailAssignedIdentifier).append(
74 this.vendorCountry, rhs.vendorCountry).isEquals();
75 }
76
77
78
79
80 public int hashCode() {
81 return new HashCodeBuilder(-999235111, -1951404497).append(this.vendorPostalCode)
82 .append(this.vendorHeaderGeneratedIdentifier)
83 .append(this.vendorDetailAssignedIdentifier).append(this.vendorCountry)
84 .toHashCode();
85 }
86
87
88
89
90 public int compareTo(Object object) {
91 VendorGroupingHelper myClass = (VendorGroupingHelper) object;
92 return new CompareToBuilder().append(this.vendorPostalCode, myClass.vendorPostalCode)
93 .append(this.vendorHeaderGeneratedIdentifier,
94 myClass.vendorHeaderGeneratedIdentifier)
95 .append(this.vendorDetailAssignedIdentifier,
96 myClass.vendorDetailAssignedIdentifier).append(this.vendorCountry,
97 myClass.vendorCountry).toComparison();
98 }
99
100
101 }