1
|
package eu.dnetlib.domain;
|
2
|
|
3
|
|
4
|
/**
|
5
|
* An abstract class implementation for the SearchCriteria interface
|
6
|
*
|
7
|
*/
|
8
|
|
9
|
public abstract class SearchCriteriaImpl implements SearchCriteria {
|
10
|
protected String startsWith = null;
|
11
|
protected String endsWith = null;
|
12
|
protected String contains = null;
|
13
|
|
14
|
public String getContains() {
|
15
|
return contains;
|
16
|
}
|
17
|
public void setContains(String contains) {
|
18
|
this.contains = contains;
|
19
|
}
|
20
|
public String getEndsWith() {
|
21
|
return endsWith;
|
22
|
}
|
23
|
public void setEndsWith(String endsWith) {
|
24
|
this.endsWith = endsWith;
|
25
|
}
|
26
|
public String getStartsWith() {
|
27
|
return startsWith;
|
28
|
}
|
29
|
public void setStartsWith(String startsWith) {
|
30
|
this.startsWith = startsWith;
|
31
|
}
|
32
|
|
33
|
public String toString() {
|
34
|
String s = "";
|
35
|
|
36
|
if (contains != null) {
|
37
|
s += "contains: " + contains;
|
38
|
}
|
39
|
|
40
|
if (startsWith != null) {
|
41
|
s += " startsWith: " + startsWith;
|
42
|
}
|
43
|
|
44
|
if (endsWith != null) {
|
45
|
s += " endsWith: " + endsWith;
|
46
|
}
|
47
|
|
48
|
return "[" + s + "]";
|
49
|
}
|
50
|
|
51
|
public boolean equals(Object o) {
|
52
|
if (!(o instanceof SearchCriteriaImpl))
|
53
|
return false;
|
54
|
else
|
55
|
return this.equals((SearchCriteriaImpl) o);
|
56
|
}
|
57
|
|
58
|
public boolean equals(SearchCriteriaImpl crit) {
|
59
|
if (contains != null && crit.contains != null) {
|
60
|
if (!contains.equals(crit.contains))
|
61
|
return false;
|
62
|
} else if ( (contains == null && crit.contains != null) || (contains != null && crit.contains == null)) {
|
63
|
return false;
|
64
|
}
|
65
|
|
66
|
if (startsWith != null && crit.startsWith != null) {
|
67
|
if (!startsWith.equals(crit.startsWith))
|
68
|
return false;
|
69
|
} else if ( (startsWith == null && crit.startsWith != null) || (startsWith != null && crit.startsWith == null)) {
|
70
|
return false;
|
71
|
}
|
72
|
|
73
|
if (endsWith != null && crit.endsWith != null) {
|
74
|
if (!endsWith.equals(crit.endsWith))
|
75
|
return false;
|
76
|
} else if ( (endsWith == null && crit.endsWith != null) || (endsWith != null && crit.endsWith == null)) {
|
77
|
return false;
|
78
|
}
|
79
|
|
80
|
return true;
|
81
|
}
|
82
|
|
83
|
public int hashCode() {
|
84
|
int code = 0;
|
85
|
|
86
|
if (contains != null)
|
87
|
code |= contains.hashCode();
|
88
|
|
89
|
if (startsWith != null)
|
90
|
code |= startsWith.hashCode();
|
91
|
|
92
|
if (endsWith != null)
|
93
|
code |= endsWith.hashCode();
|
94
|
|
95
|
return code;
|
96
|
}
|
97
|
}
|