| | |
| | | |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | |
| | | private MenuResult<ManagedObject<?>> result; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | this.dde = null; |
| | | this.mode = null; |
| | | this.monfe = null; |
| | | this.ere = null; |
| | | |
| | | path.serialize(this); |
| | | |
| | |
| | | /** |
| | | * A path serializer which is used to register a sub-command's naming arguments. |
| | | */ |
| | | protected static final class NamingArgumentBuilder implements ManagedObjectPathSerializer { |
| | | private static final class NamingArgumentBuilder implements ManagedObjectPathSerializer { |
| | | |
| | | /** |
| | | * Creates the naming arguments for a given path. |
| | |
| | | * @throws ArgumentException |
| | | * If one or more naming arguments could not be registered. |
| | | */ |
| | | public static List<StringArgument> create(SubCommand subCommand, ManagedObjectPath<?, ?> path, boolean isCreate) |
| | | throws ArgumentException { |
| | | private static List<StringArgument> create(SubCommand subCommand, ManagedObjectPath<?, ?> path, |
| | | boolean isCreate) throws ArgumentException { |
| | | NamingArgumentBuilder builder = new NamingArgumentBuilder(subCommand, path.size(), isCreate); |
| | | path.serialize(builder); |
| | | |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int compareTo(SubCommandHandler o) { |
| | | String s1 = getSubCommand().getName(); |
| | | String s2 = o.getSubCommand().getName(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds one or more tags to this sub-command handler. |
| | | * |
| | | * @param tags |
| | | * The tags to be added to this sub-command handler. |
| | | */ |
| | | protected final void addTags(Tag... tags) { |
| | | addTags(Arrays.asList(tags)); |
| | | } |
| | | |
| | | /** |
| | | * Creates the naming arguments for a given path and registers them. |
| | | * |
| | | * @param subCommand |
| | |
| | | final String value = arg.getValue(); |
| | | if (value == null && !app.isInteractive()) { |
| | | throw ArgumentExceptionFactory.missingMandatoryNonInteractiveArgument(arg); |
| | | } else { |
| | | values.add(value); |
| | | } |
| | | values.add(value); |
| | | } |
| | | return values; |
| | | } |
| | |
| | | * the type of the property to be retrieved. |
| | | * @return the String value to be displayed in the equivalent command-line. |
| | | */ |
| | | protected static <T> String castAndGetArgumentValue(PropertyDefinition<T> propertyDefinition, Object o) { |
| | | static <T> String castAndGetArgumentValue(PropertyDefinition<T> propertyDefinition, Object o) { |
| | | return propertyDefinition.encodeValue(propertyDefinition.castValue(o)); |
| | | } |
| | | |
| | |
| | | * the type of the property to be retrieved. |
| | | * @return the String value to be displayed in the equivalent command-line. |
| | | */ |
| | | protected static <T> String getArgumentValue(PropertyDefinition<T> propertyDefinition, T o) { |
| | | static <T> String getArgumentValue(PropertyDefinition<T> propertyDefinition, T o) { |
| | | return propertyDefinition.encodeValue(o); |
| | | } |
| | | |
| | |
| | | * The managed object definition. |
| | | * @return A mapping of managed object type argument values to their corresponding managed object definitions. |
| | | */ |
| | | protected static <C extends ConfigurationClient, S extends Configuration> SortedMap<String, |
| | | static <C extends ConfigurationClient, S extends Configuration> SortedMap<String, |
| | | ManagedObjectDefinition<? extends C, ? extends S>> getSubTypes( |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | SortedMap<String, ManagedObjectDefinition<? extends C, ? extends S>> map; |
| | |
| | | * The child definition. |
| | | * @return The type short name. |
| | | */ |
| | | protected static <C extends ConfigurationClient, S extends Configuration> String getShortTypeName( |
| | | private static <C extends ConfigurationClient, S extends Configuration> String getShortTypeName( |
| | | AbstractManagedObjectDefinition<C, S> d, AbstractManagedObjectDefinition<?, ?> c) { |
| | | if (c == d) { |
| | | // This is the top-level definition, so use the value "generic" or |
| | |
| | | * The managed object definition. |
| | | * @return A usage string representing the list of possible types for the provided managed object definition. |
| | | */ |
| | | protected static String getSubTypesUsage(AbstractManagedObjectDefinition<?, ?> d) { |
| | | static String getSubTypesUsage(AbstractManagedObjectDefinition<?, ?> d) { |
| | | // Build the -t option usage. |
| | | SortedMap<String, ?> types = getSubTypes(d); |
| | | StringBuilder builder = new StringBuilder(); |