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