Apache Commons CLI:替换已弃用的OptionBuilder?

Mar*_*son 15 java apache-commons apache-commons-cli

IntelliJ显示在此示例代码中不推荐使用OptionBuilder来自http://commons.apache.org/proper/commons-cli/usage.html.

我应该用什么作为替代品?

import org.apache.commons.cli.*;

Options options = new Options();
options.addOption(OptionBuilder.withLongOpt( "block-size" )
       .withDescription( "use SIZE-byte blocks" )
       .hasArg()
       .withArgName("SIZE")
       .create());
Run Code Online (Sandbox Code Playgroud)

Jul*_*... 20

来自http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html

已过时.从1.3开始,使用Option.builder(String)代替

这是替代品:

Options options = new Options();
Option option = Option.builder("a")
    .longOpt( "block-size" )
    .desc( "use SIZE-byte blocks"  )
    .hasArg()
    .argName( "SIZE" )
    .build();
options.addOption( option );
Run Code Online (Sandbox Code Playgroud)