blob: f4f1f8bc255f2ef36cd90e166b255cfe177cf34b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*******************************************************************************
* Copyright (c) 2010 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.p2.discovery.model;
/**
* Provides means to tag items in the catalog.
*
* @author David Green
* @author Steffen Pingel
*/
public class Tag extends AbstractCatalogItem {
private final Object classifier;
private final String value;
private final String label;
public Tag(String value, String label) {
this(null, value, label);
}
public Tag(Object tagClassifier, String value, String label) {
this.classifier = tagClassifier;
this.value = value;
this.label = label;
}
/**
* the classifier, which places the tag in a logical category
*
* @return the classifier or null if this tag is not in any category
*/
public Object getTagClassifier() {
return classifier;
}
/**
* Returns the value of the tag, not intended for display.
*/
public String getValue() {
return value;
}
/**
* Returns a short user-visible value that is used by the user to identify the tag.
*/
public String getLabel() {
return label;
}
@Override
public String toString() {
return "Tag [classifier=" + classifier + ", value=" + value + ", label=" + label + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
public int hashCode() {
// we don't include the label here
final int prime = 31;
int result = 1;
result = prime * result + ((classifier == null) ? 0 : classifier.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
// we don't consider the label when comparing equality
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Tag other = (Tag) obj;
if (classifier == null) {
if (other.classifier != null) {
return false;
}
} else if (!classifier.equals(other.classifier)) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
|