blob: 7a7a88b1b2eaa6835e41842df37203231788de8b (
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
57
58
59
60
61
62
63
64
65
|
/*******************************************************************************
* 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;
import java.util.SortedSet;
import java.util.TreeSet;
public class Select2OptGroup implements Comparable<Select2OptGroup> {
private final String text;
private final SortedSet<Select2DataItem> children;
public Select2OptGroup(String text) {
this.text = text;
this.children = new TreeSet<Select2DataItem>();
}
public String getText() {
return this.text;
}
/**
* Returns the internal SortedSet for data items.
*/
public SortedSet<Select2DataItem> getChildren() {
return this.children;
}
public void addItem(Select2DataItem item) {
this.children.add(item);
}
/**
* Quick hack to test Select2OptGroups for equality. Only the text is
* tested, not the contained children. This might cause issues later, but
* currently not.
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof Select2OptGroup)) {
return false;
}
return this.text.equals(((Select2OptGroup) o).text);
}
/**
* Quick hack to compare Select2OptGroups. Only the text is compared, not
* the contained children. This might cause issues later, but currently not.
*/
@Override
public int compareTo(Select2OptGroup o) {
return this.getText().compareTo(o.getText());
}
}
|