You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2011/12/15 11:36:42 UTC

Re: svn commit: r1214691 - in /commons/proper/cli/trunk/src/main/java/org/apache/commons/cli: HelpFormatter.java Parser.java

On 15 December 2011 10:30,  <eb...@apache.org> wrote:
> Author: ebourg
> Date: Thu Dec 15 10:30:01 2011
> New Revision: 1214691
>
> URL: http://svn.apache.org/viewvc?rev=1214691&view=rev
> Log:
> Removed unnecessary final modifiers

Why?

> Modified:
>    commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/HelpFormatter.java
>    commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/Parser.java
>
> Modified: commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/HelpFormatter.java
> URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/HelpFormatter.java?rev=1214691&r1=1214690&r2=1214691&view=diff
> ==============================================================================
> --- commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/HelpFormatter.java (original)
> +++ commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/HelpFormatter.java Thu Dec 15 10:30:01 2011
> @@ -537,7 +537,7 @@ public class HelpFormatter
>         StringBuffer buff = new StringBuffer(getSyntaxPrefix()).append(app).append(" ");
>
>         // create a list for processed option groups
> -        final Collection<OptionGroup> processedGroups = new ArrayList<OptionGroup>();
> +        Collection<OptionGroup> processedGroups = new ArrayList<OptionGroup>();

-1

final should always be used where possible on fields.

Both to document that the field is not intended to be entirely
replaced, and also to help with safe data publication across threads.

>
>         List<Option> optList = new ArrayList<Option>(options.getOptions());
>         if (getOptionComparator() != null)
> @@ -596,7 +596,7 @@ public class HelpFormatter
>      * @param group the group to append
>      * @see #appendOption(StringBuffer,Option,boolean)
>      */
> -    private void appendOptionGroup(final StringBuffer buff, final OptionGroup group)
> +    private void appendOptionGroup(StringBuffer buff, OptionGroup group)

It's not as essential for parameters, but again is useful as documentation.

>     {
>         if (!group.isRequired())
>         {
> @@ -633,7 +633,7 @@ public class HelpFormatter
>      * @param option the Option to append
>      * @param required whether the Option is required or not
>      */
> -    private void appendOption(final StringBuffer buff, final Option option, final boolean required)
> +    private void appendOption(StringBuffer buff, Option option, boolean required)
>     {
>         if (!required)
>         {
>
> Modified: commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/Parser.java
> URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/Parser.java?rev=1214691&r1=1214690&r2=1214691&view=diff
> ==============================================================================
> --- commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/Parser.java (original)
> +++ commons/proper/cli/trunk/src/main/java/org/apache/commons/cli/Parser.java Thu Dec 15 10:30:01 2011
> @@ -43,7 +43,7 @@ public abstract class Parser implements
>     /** list of required options strings */
>     private List requiredOptions;
>
> -    protected void setOptions(final Options options)
> +    protected void setOptions(Options options)
>     {
>         this.options = options;
>         this.requiredOptions = new ArrayList(options.getRequiredOptions());
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1214691 - in /commons/proper/cli/trunk/src/main/java/org/apache/commons/cli: HelpFormatter.java Parser.java

Posted by sebb <se...@gmail.com>.
On 15 December 2011 10:56, Emmanuel Bourg <eb...@apache.org> wrote:
> Le 15/12/2011 11:36, sebb a écrit :
>
>
>>> Removed unnecessary final modifiers
>>
>>
>> Why?
>
>
> As stated, because these method parameters don't need to be final.
>
>
>
>> final should always be used where possible on fields.
>>
>> Both to document that the field is not intended to be entirely
>> replaced, and also to help with safe data publication across threads.
>
>
> This is a local variable, not a field.

Ah, OK then.

> Also keep in mind that CLI is generally not used in a multi thread context,
> the command line is only parsed by the main application thread.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1214691 - in /commons/proper/cli/trunk/src/main/java/org/apache/commons/cli: HelpFormatter.java Parser.java

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 15/12/2011 11:36, sebb a écrit :

>> Removed unnecessary final modifiers
>
> Why?

As stated, because these method parameters don't need to be final.


> final should always be used where possible on fields.
>
> Both to document that the field is not intended to be entirely
> replaced, and also to help with safe data publication across threads.

This is a local variable, not a field.

Also keep in mind that CLI is generally not used in a multi thread 
context, the command line is only parsed by the main application thread.

Emmanuel Bourg