blob: 1b8fb9a05295eff94d16407a8eb39d93e7925a4b (
plain)
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
|
/*******************************************************************************
* Copyright (c) 2014 University of Stuttgart.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v10.html
* and http://www.apache.org/licenses/LICENSE-2.0
*
* Contributors:
* Oliver Kopp - initial API and implementation
*******************************************************************************/
package org.eclipse.winery.repository.datatypes.select2;
/**
* Models a data item for select2. In case optgroups have to be returned, use
* this element in a TreeMap
*/
public class Select2DataItem implements Comparable<Select2DataItem> {
private final String id;
private final String text;
public Select2DataItem(String id, String text) {
this.id = id;
this.text = text;
}
public String getId() {
return this.id;
}
public String getText() {
return this.text;
}
/**
* Sort order is based on text
*/
@Override
public int compareTo(Select2DataItem o) {
return this.getText().compareTo(o.getText());
}
/**
* Equality is checked at id level
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof Select2DataItem)) {
return false;
}
return this.getId().equals(((Select2DataItem) o).getId());
}
}
|