package org.realityforge.getopt4j;

import java.util.Arrays;

/**
 * Basic class describing an instance of option.
 */
public final class CLOption
{
  /**
   * Value of {@link #getId} when the option is a text argument.
   */
  public static final int TEXT_ARGUMENT = 0;

  private String[] m_arguments;
  private CLOptionDescriptor m_descriptor;

  /**
   * Retrieve argument to option if it takes arguments.
   *
   * @return the (first) argument
   */
  public final String getArgument()
  {
    return getArgument(0);
  }

  /**
   * Retrieve indexed argument to option if it takes arguments.
   *
   * @param index The argument index, from 0 to
   *              {@link #getArgumentCount()}-1.
   * @return the argument
   */
  public final String getArgument(final int index)
  {
    if (null == m_arguments || index < 0 || index >= m_arguments.length)
    {
      return null;
    }
    else
    {
      return m_arguments[index];
    }
  }

  /**
   * Retrieve id of option.
   *
   * The id is eqivalent to character code if it can be a single letter option.
   *
   * @return the id
   */
  public final int getId()
  {
    return m_descriptor == null ? TEXT_ARGUMENT : m_descriptor.getId();
  }

  public final CLOptionDescriptor getDescriptor()
  {
    return m_descriptor;
  }

  /**
   * Constructor taking an descriptor
   *
   * @param descriptor the descriptor
   */
  public CLOption(final CLOptionDescriptor descriptor)
  {
    m_descriptor = descriptor;
  }

  /**
   * Constructor taking argument for option.
   *
   * @param argument the argument
   */
  public CLOption(final String argument)
  {
    this((CLOptionDescriptor) null);
    addArgument(argument);
  }

  /**
   * Mutator of Argument property.
   *
   * @param argument the argument
   */
  public final void addArgument(final String argument)
  {
    if (null == m_arguments)
    {
      m_arguments = new String[]{argument};
    }
    else
    {
      final String[] arguments = new String[m_arguments.length + 1];
      System.arraycopy(m_arguments, 0, arguments, 0, m_arguments.length);
      arguments[m_arguments.length] = argument;
      m_arguments = arguments;
    }
  }

  /**
   * Get number of arguments.
   *
   * @return the number of arguments
   */
  public final int getArgumentCount()
  {
    if (null == m_arguments)
    {
      return 0;
    }
    else
    {
      return m_arguments.length;
    }
  }

  /**
   * Convert to String.
   *
   * @return the string value
   */
  public final String toString()
  {
    return "[Option " +
           (char) m_descriptor.getId() +
           ( null != m_arguments ? ", " + Arrays.asList( m_arguments ) : "" ) +
           " ]";
  }
}

@@ -449,38 +449,32 @@
 %0A   */%0A  public 
-final 
 String getArgume
@@ -474,24 +474,24 @@
 tArgument()%0A
+
   %7B%0A    retu
@@ -723,30 +723,24 @@
 */%0A  public 
-final 
 String getAr
@@ -1085,30 +1085,24 @@
 */%0A  public 
-final 
 int getId()%0A
@@ -1191,22 +1191,16 @@
  public 
-final 
 CLOption
@@ -1753,22 +1753,16 @@
  public 
-final 
 void add
@@ -2223,22 +2223,16 @@
  public 
-final 
 int getA
@@ -2433,24 +2433,24 @@
 value%0A   */%0A
+
   public fin
@@ -2446,22 +2446,16 @@
  public 
-final 
 String t

Remove unnecessary final qualifiers