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
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.datatypes.select2;
14 import java.util.SortedSet;
15 import java.util.TreeSet;
17 public class Select2OptGroup implements Comparable<Select2OptGroup> {
19 private final String text;
20 private final SortedSet<Select2DataItem> children;
23 public Select2OptGroup(String text) {
25 this.children = new TreeSet<Select2DataItem>();
28 public String getText() {
33 * Returns the internal SortedSet for data items.
35 public SortedSet<Select2DataItem> getChildren() {
39 public void addItem(Select2DataItem item) {
40 this.children.add(item);
44 * Quick hack to test Select2OptGroups for equality. Only the text is
45 * tested, not the contained children. This might cause issues later, but
49 public boolean equals(Object o) {
50 if (!(o instanceof Select2OptGroup)) {
53 return this.text.equals(((Select2OptGroup) o).text);
57 * Quick hack to compare Select2OptGroups. Only the text is compared, not
58 * the contained children. This might cause issues later, but currently not.
61 public int compareTo(Select2OptGroup o) {
62 return this.getText().compareTo(o.getText());