Merge "Fix build errors in autorelease full clean build"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / datatypes / select2 / Select2OptGroup.java
1 /*******************************************************************************
2  * Copyright (c) 2014 University of Stuttgart.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and the Apache License 2.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.datatypes.select2;
13
14 import java.util.SortedSet;
15 import java.util.TreeSet;
16
17 public class Select2OptGroup implements Comparable<Select2OptGroup> {
18         
19         private final String text;
20         private final SortedSet<Select2DataItem> children;
21         
22         
23         public Select2OptGroup(String text) {
24                 this.text = text;
25                 this.children = new TreeSet<Select2DataItem>();
26         }
27         
28         public String getText() {
29                 return this.text;
30         }
31         
32         /**
33          * Returns the internal SortedSet for data items.
34          */
35         public SortedSet<Select2DataItem> getChildren() {
36                 return this.children;
37         }
38         
39         public void addItem(Select2DataItem item) {
40                 this.children.add(item);
41         }
42         
43         /**
44          * Quick hack to test Select2OptGroups for equality. Only the text is
45          * tested, not the contained children. This might cause issues later, but
46          * currently not.
47          */
48         @Override
49         public boolean equals(Object o) {
50                 if (!(o instanceof Select2OptGroup)) {
51                         return false;
52                 }
53                 return this.text.equals(((Select2OptGroup) o).text);
54         }
55         
56         /**
57          * Quick hack to compare Select2OptGroups. Only the text is compared, not
58          * the contained children. This might cause issues later, but currently not.
59          */
60         @Override
61         public int compareTo(Select2OptGroup o) {
62                 return this.getText().compareTo(o.getText());
63         }
64         
65 }