You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2017/06/08 17:38:23 UTC
[34/40] commons-cli git commit: Remove deprecated constructor (OK as
code has not been released)
Remove deprecated constructor (OK as code has not been released)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/branches/avalon-implementation@539920 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-cli/commit/00aab5d6
Tree: http://git-wip-us.apache.org/repos/asf/commons-cli/tree/00aab5d6
Diff: http://git-wip-us.apache.org/repos/asf/commons-cli/diff/00aab5d6
Branch: refs/heads/avalon-implementation
Commit: 00aab5d694a86ee5d710e107ff4e9236c28c3320
Parents: 8fc39d0
Author: Sebastian Bazley <se...@apache.org>
Authored: Sun May 20 19:41:25 2007 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Sun May 20 19:41:25 2007 +0000
----------------------------------------------------------------------
.../commons/cli/avalon/CLOptionDescriptor.java | 55 ++++++++------------
1 file changed, 22 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-cli/blob/00aab5d6/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java b/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java
index 4daddd8..07c7537 100644
--- a/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java
+++ b/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java
@@ -59,9 +59,15 @@ public final class CLOptionDescriptor
final int id,
final String description )
{
- this( name, flags, id, description,
- ((flags & CLOptionDescriptor.DUPLICATES_ALLOWED) > 0)
- ? new int[0] : new int[]{id} );
+
+ checkFlags(flags);
+
+ m_id = id;
+ m_name = name;
+ m_flags = flags;
+ m_description = description;
+ m_incompatible = ((flags & DUPLICATES_ALLOWED) > 0)
+ ? new int[0] : new int[] { id };
}
/**
@@ -71,21 +77,30 @@ public final class CLOptionDescriptor
* @param flags the flags
* @param id the id/character option
* @param description description of option usage
- * @param incompatible an array listing the ids of all incompatible options
- * @deprecated use the version with the array of CLOptionDescriptor's
+ * @param incompatible an array listing the descriptors of all incompatible options
*/
public CLOptionDescriptor( final String name,
final int flags,
final int id,
final String description,
- final int[] incompatible )
+ final CLOptionDescriptor[] incompatible )
{
+
+ checkFlags(flags);
+
m_id = id;
m_name = name;
m_flags = flags;
m_description = description;
- m_incompatible = incompatible;
+ m_incompatible = new int[incompatible.length];
+ for (int i = 0; i < incompatible.length; i++) {
+ m_incompatible[i] = incompatible[i].getId();
+ }
+ }
+
+ // helper method - check for invalid flag combinations
+ private void checkFlags(final int flags) {
int modeCount = 0;
if( (ARGUMENT_REQUIRED & flags) == ARGUMENT_REQUIRED )
{
@@ -117,32 +132,6 @@ public final class CLOptionDescriptor
}
/**
- * Constructor.
- *
- * @param name the name/long option
- * @param flags the flags
- * @param id the id/character option
- * @param description description of option usage
- */
- public CLOptionDescriptor( final String name,
- final int flags,
- final int id,
- final String description,
- final CLOptionDescriptor[] incompatible )
- {
- m_id = id;
- m_name = name;
- m_flags = flags;
- m_description = description;
-
- m_incompatible = new int[incompatible.length];
- for( int i = 0; i < incompatible.length; i++ )
- {
- m_incompatible[i] = incompatible[i].getId();
- }
- }
-
- /**
* Get the array of incompatible option ids.
*
* @return the array of incompatible option ids