IntelliJ shows that OptionBuilder is deprecated in this example code from http://commons.apache.org/proper/commons-cli/usage.html.
IntelliJ显示了OptionBuilder在http://commons.apache.org/proper/commons-cli/usage.html的示例代码中是不赞成的。
What should I use as the replacement?
我应该用什么来代替呢?
import org.apache.commons.cli.*;
Options options = new Options();
options.addOption(OptionBuilder.withLongOpt( "block-size" )
.withDescription( "use SIZE-byte blocks" )
.hasArg()
.withArgName("SIZE")
.create());
2 个解决方案
#1
12
From http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html
从http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html
Deprecated. since 1.3, use Option.builder(String) instead
弃用。从1.3开始,使用Option.builder(String)代替
This is the replacement:
这是更换:
Options options = new Options();
Option option = Option.builder("a")
.longOpt( "block-size" )
.desc( "use SIZE-byte blocks" )
.hasArg()
.argName( "SIZE" )
.build();
options.addOption( option );
#2
2
Use the (inner) class Option.Builder
as in
使用(内部)类选项。构建器如
Option option = Option.builder("a")
.required(true)
.longOpt("arg-name")
.build();
Cf. Option.Builder Java-Doc. I.e. the static builder()
method of Option
returns an Option.Builder
and the trailing call to build()
gives you an Option
.
Cf。选择。Builder Java-Doc。例如,选项的静态builder()方法返回一个选项。Builder和随后的build()调用为您提供了一个选项。
#1
12
From http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html
从http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html
Deprecated. since 1.3, use Option.builder(String) instead
弃用。从1.3开始,使用Option.builder(String)代替
This is the replacement:
这是更换:
Options options = new Options();
Option option = Option.builder("a")
.longOpt( "block-size" )
.desc( "use SIZE-byte blocks" )
.hasArg()
.argName( "SIZE" )
.build();
options.addOption( option );
#2
2
Use the (inner) class Option.Builder
as in
使用(内部)类选项。构建器如
Option option = Option.builder("a")
.required(true)
.longOpt("arg-name")
.build();
Cf. Option.Builder Java-Doc. I.e. the static builder()
method of Option
returns an Option.Builder
and the trailing call to build()
gives you an Option
.
Cf。选择。Builder Java-Doc。例如,选项的静态builder()方法返回一个选项。Builder和随后的build()调用为您提供了一个选项。