1/**2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17package org.apache.commons.cli2;
1819import java.util.Collections;
20import java.util.HashSet;
21import java.util.Set;
2223/**24 * An enum of possible display settings. These settings are used to control the25 * presence of various features in the String representations of options,26 * CommandLines and usage strings. Usually a Set of DisplaySetting instances27 * will be passed to a method that will lookup the presence of the values.28 */29publicclassDisplaySetting {
3031privatestaticfinal Set all = new HashSet();
3233/**34 * A Set guaranteed to contain all possible DisplaySetting values35 */36publicstaticfinal Set ALL = Collections.unmodifiableSet(all);
3738/**39 * A Set guaranteed to contain no DisplaySetting values40 */41publicstaticfinal Set NONE = Collections.EMPTY_SET;
4243/**44 * Indicates that aliases should be included45 */46publicstaticfinalDisplaySetting DISPLAY_ALIASES =
47newDisplaySetting("DISPLAY_ALIASES");
4849/**50 * Indicates that optionality should be included51 */52publicstaticfinalDisplaySetting DISPLAY_OPTIONAL =
53newDisplaySetting("DISPLAY_OPTIONAL");
5455/**56 * Indicates that optional child groups should be displayed in square57 * brackets.58 */59publicstaticfinalDisplaySetting DISPLAY_OPTIONAL_CHILD_GROUP =
60newDisplaySetting("DISPLAY_OPTIONAL_CHILD_GROUP");
6162/**63 * Indicates that property options should be included64 */65publicstaticfinalDisplaySetting DISPLAY_PROPERTY_OPTION =
66newDisplaySetting("DISPLAY_PROPERTY_OPTION");
6768/**69 * Indicates that switches should be included enabled70 */71publicstaticfinalDisplaySetting DISPLAY_SWITCH_ENABLED =
72newDisplaySetting("DISPLAY_SWITCH_ENABLED");
7374/**75 * Indicates that switches should be included disabled76 */77publicstaticfinalDisplaySetting DISPLAY_SWITCH_DISABLED =
78newDisplaySetting("DISPLAY_SWITCH_DISABLED");
7980/**81 * Indicates that group names should be included82 */83publicstaticfinalDisplaySetting DISPLAY_GROUP_NAME =
84newDisplaySetting("DISPLAY_GROUP_NAME");
8586/**87 * Indicates that groups should be included expanded88 */89publicstaticfinalDisplaySetting DISPLAY_GROUP_EXPANDED =
90newDisplaySetting("DISPLAY_GROUP_EXPANDED");
9192/**93 * Indicates that group arguments should be included94 */95publicstaticfinalDisplaySetting DISPLAY_GROUP_ARGUMENT =
96newDisplaySetting("DISPLAY_GROUP_ARGUMENT");
9798/**99 * Indicates that group outer brackets should be included100 */101publicstaticfinalDisplaySetting DISPLAY_GROUP_OUTER =
102newDisplaySetting("DISPLAY_GROUP_OUTER");
103104/**105 * Indicates that arguments should be included numbered106 */107publicstaticfinalDisplaySetting DISPLAY_ARGUMENT_NUMBERED =
108newDisplaySetting("DISPLAY_ARGUMENT_NUMBERED");
109110/**111 * Indicates that arguments should be included bracketed112 */113publicstaticfinalDisplaySetting DISPLAY_ARGUMENT_BRACKETED =
114newDisplaySetting("DISPLAY_ARGUMENT_BRACKETED");
115116/**117 * Indicates that arguments of Parents should be included118 */119publicstaticfinalDisplaySetting DISPLAY_PARENT_ARGUMENT =
120newDisplaySetting("DISPLAY_PARENT_ARGUMENT");
121122/**123 * Indicates that children of Parents should be included124 */125publicstaticfinalDisplaySetting DISPLAY_PARENT_CHILDREN =
126newDisplaySetting("DISPLAY_PARENT_CHILDREN");
127128/**129 * The name of the setting130 */131privatefinal String name;
132133/**134 * The hashCode of the setting135 */136privatefinalint hashCode;
137138/**139 * Creates a new DisplaySetting with the specified name140 * @param name the name of the setting141 */142privateDisplaySetting(final String name) {
143this.name = name;
144this.hashCode = name.hashCode();
145 all.add(this);
146 }
147148publicint hashCode() {
149return hashCode;
150 }
151152publicboolean equals(final Object that) {
153if (that instanceof DisplaySetting) {
154return name.compareTo(that.toString()) == 0;
155 }
156return false;
157 }
158159public String toString() {
160return name;
161 }
162 }