@@ -42,6 +42,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
4242 */
4343public class Option implements Cloneable , Serializable {
4444
45+
4546 /**
4647 * Builds {@code Option} instances using descriptive methods.
4748 * <p>
@@ -65,6 +66,12 @@ public static final class Builder {
6566 /** The long representation of the option. */
6667 private String longOption ;
6768
69+ /** Specifies if the option had a previous deprecated long representation of the option. */
70+ private String deprecatedLongOption ;
71+
72+ /** Specifies if the option had a previous deprecated representation of the option. */
73+ private String deprecatedOption ;
74+
6875 /** The name of the argument for this option. */
6976 private String argName ;
7077
@@ -187,6 +194,29 @@ public Builder longOpt(final String longOpt) {
187194 return this ;
188195 }
189196
197+ /**
198+ * Sets the deprecated long name of the Option.
199+ *
200+ * @param deprecatedLongOption the deprecated long name of the Option
201+ * @return this builder.
202+ */
203+ public Builder deprecatedLongOption (final String deprecatedLongOption ) {
204+ this .deprecatedLongOption = deprecatedLongOption ;
205+ return this ;
206+ }
207+ /**
208+ * Sets the deprecated long name of the Option.
209+ *
210+ * @param deprecatedOption the deprecated name of the Option
211+ * @return this builder.
212+ */
213+ public Builder deprecatedOption (final String deprecatedOption ) {
214+ this .deprecatedOption = deprecatedOption ;
215+ return this ;
216+ }
217+
218+
219+
190220 /**
191221 * Sets the number of argument values the Option can take.
192222 *
@@ -332,6 +362,12 @@ public static Builder builder(final String option) {
332362 /** The long representation of the option. */
333363 private String longOption ;
334364
365+ /** Deprecated Long option */
366+ private String deprecatedLongOption ;
367+
368+ /** Deprecated option */
369+ private String deprecatedOption ;
370+
335371 /** The name of the argument for this option. */
336372 private String argName ;
337373
@@ -368,6 +404,8 @@ private Option(final Builder builder) {
368404 this .argName = builder .argName ;
369405 this .description = builder .description ;
370406 this .longOption = builder .longOption ;
407+ this .deprecatedLongOption = builder .deprecatedLongOption ;
408+ this .deprecatedOption = builder .deprecatedOption ;
371409 this .argCount = builder .argCount ;
372410 this .option = builder .option ;
373411 this .optionalArg = builder .optionalArg ;
@@ -608,6 +646,14 @@ public String getOpt() {
608646 return option ;
609647 }
610648
649+ public String getDeprecatedLongOpt () {
650+ return deprecatedLongOption ;
651+ }
652+
653+ public String getDeprecatedOpt () {
654+ return deprecatedOption ;
655+ }
656+
611657 /**
612658 * Gets the type of this Option.
613659 *
@@ -720,6 +766,24 @@ public boolean hasLongOpt() {
720766 return longOption != null ;
721767 }
722768
769+ /**
770+ * Tests whether this Option has a deprecated long name.
771+ *
772+ * @return boolean flag indicating existence of a deprecated long name.
773+ */
774+ public boolean hasDeprecatedLongOpt () {
775+ return deprecatedLongOption != null ;
776+ }
777+
778+ /**
779+ * Tests whether this Option has a deprecated option name.
780+ *
781+ * @return boolean flag indicating existence of a deprecated option name.
782+ */
783+ public boolean hasDeprecatedOption () {
784+ return deprecatedOption != null ;
785+ }
786+
723787 /**
724788 * Tests whether this Option has any values.
725789 *
@@ -861,6 +925,24 @@ public void setLongOpt(final String longOpt) {
861925 this .longOption = longOpt ;
862926 }
863927
928+ /**
929+ * Sets the deprecated long name of this Option.
930+ *
931+ * @param deprecatedLongOption the deprecated long name of this Option.
932+ */
933+ public void setDeprecatedLongOption (final String deprecatedLongOption ) {
934+ this .deprecatedLongOption = deprecatedLongOption ;
935+ }
936+
937+ /**
938+ * Sets the deprecated ame of this Option.
939+ *
940+ * @param deprecatedOption the deprecated name of this Option.
941+ */
942+ public void setDeprecatedOption (final String deprecatedOption ) {
943+ this .deprecatedOption = deprecatedOption ;
944+ }
945+
864946 /**
865947 * Sets whether this Option can have an optional argument.
866948 *
0 commit comments