59
|
1 package cl.maps.penta;
|
|
2
|
|
3
|
|
4 public class PentaKey <A, B, C, D, E> {
|
|
5 private A aKey;
|
|
6 private B bKey;
|
|
7 private C cKey;
|
|
8 private D dKey;
|
|
9 private E ownKey;
|
|
10
|
|
11 public PentaKey(A aKey, B bKey, C cKey, D dKey, E ownKey){
|
|
12 this.aKey = aKey;
|
|
13 this.bKey = bKey;
|
|
14 this.cKey = cKey;
|
|
15 this.dKey = dKey;
|
|
16 this.ownKey = ownKey;
|
|
17 }
|
|
18
|
|
19 public boolean equalsAKey(A key){
|
|
20 if(aKey != null && key != null){
|
|
21 return aKey.equals(key);
|
|
22 }else if(aKey == null && key == null){
|
|
23 return true;
|
|
24 }
|
|
25 return false;
|
|
26 }
|
|
27
|
|
28 public boolean equalsBKey(B key){
|
|
29 if(bKey != null && key != null){
|
|
30 return bKey.equals(key);
|
|
31 }else if(bKey == null && key == null){
|
|
32 return true;
|
|
33 }
|
|
34 return false;
|
|
35 }
|
|
36
|
|
37 public boolean equalsCKey(C key){
|
|
38 if(cKey != null && key != null){
|
|
39 return cKey.equals(key);
|
|
40 }else if(cKey == null && key == null){
|
|
41 return true;
|
|
42 }
|
|
43 return false;
|
|
44 }
|
|
45
|
|
46 public boolean equalsDKey(D key){
|
|
47 if(dKey != null && key != null){
|
|
48 return dKey.equals(key);
|
|
49 }else if(dKey == null && key == null){
|
|
50 return true;
|
|
51 }
|
|
52 return false;
|
|
53 }
|
|
54
|
|
55 public boolean equalsOwnKey(E key){
|
|
56 if(ownKey != null && key != null){
|
|
57 return ownKey.equals(key);
|
|
58 }else if(ownKey == null && key == null){
|
|
59 return true;
|
|
60 }
|
|
61 return false;
|
|
62 }
|
|
63
|
|
64 public A getAKey() {
|
|
65 return aKey;
|
|
66 }
|
|
67
|
|
68 public void setAKey(A aKey) {
|
|
69 this.aKey = aKey;
|
|
70 }
|
|
71
|
|
72 public B getBKey() {
|
|
73 return bKey;
|
|
74 }
|
|
75
|
|
76 public void setBKey(B bKey) {
|
|
77 this.bKey = bKey;
|
|
78 }
|
|
79
|
|
80 public D getDKey() {
|
|
81 return dKey;
|
|
82 }
|
|
83
|
|
84 public void setDKey(D dKey) {
|
|
85 this.dKey = dKey;
|
|
86 }
|
|
87
|
|
88 public C getCKey() {
|
|
89 return cKey;
|
|
90 }
|
|
91
|
|
92 public void setCKey(C cKey) {
|
|
93 this.cKey = cKey;
|
|
94 }
|
|
95
|
|
96 public E getOwnKey() {
|
|
97 return ownKey;
|
|
98 }
|
|
99
|
|
100 public void setOwnKey(E ownKey) {
|
|
101 this.ownKey = ownKey;
|
|
102 }
|
|
103
|
|
104 @Override
|
|
105 public boolean equals(Object o){
|
|
106 if(o instanceof PentaKey){
|
|
107 try {
|
|
108 PentaKey<A, B, C, D, E> other = (PentaKey<A, B, C, D, E>)o;
|
|
109
|
|
110 if(this.equalsDKey(other.getDKey()) &&
|
|
111 this.equalsAKey(other.getAKey()) &&
|
|
112 this.equalsBKey(other.getBKey()) &&
|
|
113 this.equalsCKey(other.getCKey())){
|
|
114 return true;
|
|
115 }
|
|
116 } catch (Exception e) {}
|
|
117 }
|
|
118 return false;
|
|
119 }
|
|
120
|
|
121 @Override
|
|
122 public int hashCode() {
|
|
123 final int prime = 31;
|
|
124 int result = 1;
|
|
125 result = prime * result + ((aKey == null) ? 0 : aKey.hashCode());
|
|
126 result = prime * result + ((bKey == null) ? 0 : bKey.hashCode());
|
|
127 result = prime * result + ((cKey == null) ? 0 : cKey.hashCode());
|
|
128 result = prime * result + ((dKey == null) ? 0 : dKey.hashCode());
|
|
129 result = prime * result + ((ownKey == null) ? 0 : ownKey.hashCode());
|
|
130
|
|
131 return result;
|
|
132 }
|
|
133
|
|
134 @Override
|
|
135 public String toString() {
|
|
136 if (aKey == null || bKey == null || cKey == null || dKey == null || ownKey == null) {
|
|
137 return super.toString();
|
|
138 }
|
|
139 return "PentaKey [" +
|
|
140 aKey.toString() + ", " +
|
|
141 bKey.toString() + ", " +
|
|
142 cKey.toString() + ", " +
|
|
143 dKey.toString() + ", " +
|
|
144 ownKey.toString() + "]";
|
|
145 }
|
|
146 }
|