1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.api.service.lsid.impl;
|
11
|
|
12
|
/**
|
13
|
* simple struct for patterns
|
14
|
* <p>
|
15
|
* <p>
|
16
|
*/
|
17
|
public class Pattern {
|
18
|
public static final Pattern NO_LSID_PATTERN = new Pattern();
|
19
|
public static final String WILDCARD = "*";
|
20
|
public static final String SEPARATOR = ":";
|
21
|
|
22
|
@Override
|
23
|
public boolean equals(Object other) {
|
24
|
if (this == other) {
|
25
|
return true;
|
26
|
}
|
27
|
if (!(other instanceof Pattern)) {
|
28
|
return false;
|
29
|
}
|
30
|
|
31
|
final Pattern pattern = (Pattern) other;
|
32
|
|
33
|
if (!toString().equals(pattern.toString())) {
|
34
|
return false;
|
35
|
}
|
36
|
|
37
|
return true;
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
public int hashCode() {
|
42
|
return this.toString().hashCode();
|
43
|
}
|
44
|
|
45
|
private String authority;
|
46
|
private String namespace;
|
47
|
|
48
|
@Override
|
49
|
public String toString() {
|
50
|
if (authority == null) {
|
51
|
return "NO_LSID_PATTERN";
|
52
|
}
|
53
|
return authority + Pattern.SEPARATOR + namespace;
|
54
|
}
|
55
|
|
56
|
public String getAuthority() {
|
57
|
return authority;
|
58
|
}
|
59
|
|
60
|
public String getNamespace() {
|
61
|
return namespace;
|
62
|
}
|
63
|
|
64
|
public void setAuthority(String authority) {
|
65
|
this.authority = authority.toLowerCase();
|
66
|
}
|
67
|
|
68
|
public void setNamespace(String namespace) {
|
69
|
this.namespace = namespace.toLowerCase();
|
70
|
}
|
71
|
}
|