src/jdk.internal.opt/share/classes/jdk/internal/joptsimple/AbstractOptionSpec.java
author jlahoda
Wed, 06 Jun 2018 15:36:29 +0200
changeset 50428 8c88df2e8a78
parent 47216 71c04702a3d5
permissions -rw-r--r--
8203891: Upgrade JOpt Simple to 5.0.4 Reviewed-by: alanb, chegar, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     1
/*
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     2
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     4
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    10
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    15
 * accompanied this code).
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    16
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    20
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    23
 * questions.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    24
 */
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    25
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    26
/*
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    27
 * This file is available under and governed by the GNU General Public
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    28
 * License version 2 only, as published by the Free Software Foundation.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    29
 * However, the following notice accompanied the original version of this
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    30
 * file:
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    31
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    32
 * The MIT License
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    33
 *
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    34
 * Copyright (c) 2004-2015 Paul R. Holser, Jr.
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    35
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    36
 * Permission is hereby granted, free of charge, to any person obtaining
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    37
 * a copy of this software and associated documentation files (the
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    38
 * "Software"), to deal in the Software without restriction, including
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    39
 * without limitation the rights to use, copy, modify, merge, publish,
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    40
 * distribute, sublicense, and/or sell copies of the Software, and to
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    41
 * permit persons to whom the Software is furnished to do so, subject to
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    42
 * the following conditions:
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    43
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    44
 * The above copyright notice and this permission notice shall be
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    45
 * included in all copies or substantial portions of the Software.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    46
 *
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    47
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    48
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    49
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    50
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    51
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    52
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    53
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    54
 */
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    55
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    56
package jdk.internal.joptsimple;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    57
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    58
import java.util.ArrayList;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    59
import java.util.List;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    60
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    61
import static java.util.Collections.*;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    62
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    63
import jdk.internal.joptsimple.internal.Reflection;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    64
import jdk.internal.joptsimple.internal.ReflectionException;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    65
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    66
import static jdk.internal.joptsimple.internal.Strings.*;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    67
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    68
/**
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    69
 * @param <V> represents the type of the arguments this option accepts
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    70
 * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    71
 */
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    72
public abstract class AbstractOptionSpec<V> implements OptionSpec<V>, OptionDescriptor {
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    73
    private final List<String> options = new ArrayList<>();
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    74
    private final String description;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    75
    private boolean forHelp;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    76
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    77
    AbstractOptionSpec( String option ) {
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    78
        this( singletonList( option ), EMPTY );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    79
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    80
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    81
    AbstractOptionSpec( List<String> options, String description ) {
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    82
        arrangeOptions( options );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    83
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    84
        this.description = description;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    85
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    86
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
    87
    public final List<String> options() {
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    88
        return unmodifiableList( options );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    89
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    90
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    91
    public final List<V> values( OptionSet detectedOptions ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    92
        return detectedOptions.valuesOf( this );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    93
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    94
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    95
    public final V value( OptionSet detectedOptions ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    96
        return detectedOptions.valueOf( this );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    97
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    98
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
    99
    public String description() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   100
        return description;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   101
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   102
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   103
    public final AbstractOptionSpec<V> forHelp() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   104
        forHelp = true;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   105
        return this;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   106
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   107
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   108
    public final boolean isForHelp() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   109
        return forHelp;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   110
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   111
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   112
    public boolean representsNonOptions() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   113
        return false;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   114
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   115
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   116
    protected abstract V convert( String argument );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   117
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   118
    protected V convertWith( ValueConverter<V> converter, String argument ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   119
        try {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   120
            return Reflection.convertWith( converter, argument );
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
   121
        } catch ( ReflectionException | ValueConversionException ex ) {
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
   122
            throw new OptionArgumentConversionException( this, argument, ex );
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   123
        }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   124
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   125
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   126
    protected String argumentTypeIndicatorFrom( ValueConverter<V> converter ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   127
        if ( converter == null )
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   128
            return null;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   129
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   130
        String pattern = converter.valuePattern();
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   131
        return pattern == null ? converter.valueType().getName() : pattern;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   132
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   133
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   134
    abstract void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions,
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   135
        String detectedArgument );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   136
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
   137
    private void arrangeOptions( List<String> unarranged ) {
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   138
        if ( unarranged.size() == 1 ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   139
            options.addAll( unarranged );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   140
            return;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   141
        }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   142
50428
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
   143
        List<String> shortOptions = new ArrayList<>();
8c88df2e8a78 8203891: Upgrade JOpt Simple to 5.0.4
jlahoda
parents: 47216
diff changeset
   144
        List<String> longOptions = new ArrayList<>();
35377
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   145
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   146
        for ( String each : unarranged ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   147
            if ( each.length() == 1 )
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   148
                shortOptions.add( each );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   149
            else
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   150
                longOptions.add( each );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   151
        }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   152
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   153
        sort( shortOptions );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   154
        sort( longOptions );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   155
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   156
        options.addAll( shortOptions );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   157
        options.addAll( longOptions );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   158
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   159
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   160
    @Override
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   161
    public boolean equals( Object that ) {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   162
        if ( !( that instanceof AbstractOptionSpec<?> ) )
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   163
            return false;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   164
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   165
        AbstractOptionSpec<?> other = (AbstractOptionSpec<?>) that;
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   166
        return options.equals( other.options );
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   167
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   168
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   169
    @Override
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   170
    public int hashCode() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   171
        return options.hashCode();
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   172
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   173
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   174
    @Override
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   175
    public String toString() {
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   176
        return options.toString();
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   177
    }
462f93ab37f2 8148154: Integrate JOpt Simple for internal usage by JDK tools
chegar
parents:
diff changeset
   178
}