首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用带有多个生成器选项的节俭java代码生成器

如何使用带有多个生成器选项的节俭java代码生成器
EN

Stack Overflow用户
提问于 2014-04-16 23:10:30
回答 1查看 5.8K关注 0票数 7

我正在查看第三层代码生成器的文档。一开始是这样的:

代码语言:javascript
复制
Usage: thrift [options] file
Options:
  -version    Print the compiler version
  -o dir      Set the output directory for gen-* packages
               (default: current directory)
  -out dir    Set the ouput location for generated files.
               (no gen-* folder will be created)
  -I dir      Add a directory to the list of directories
                searched for include directives
  -nowarn     Suppress all compiler warnings (BAD!)
  -strict     Strict compiler warnings on
  -v[erbose]  Verbose mode
  -r[ecurse]  Also generate included files
  -debug      Parse debug trace to stdout
  --allow-neg-keys  Allow negative field keys (Used to preserve protocol
                compatibility with older .thrift files)
  --allow-64bit-consts  Do not print warnings about using 64-bit constants
  --gen STR   Generate code with a dynamically-registered generator.
                STR has the form language[:key1=val1[,key2,[key3=val3]]].
                Keys and values are options passed to the generator.
                Many options will not require values.

下面是这样的情况:

代码语言:javascript
复制
  java (Java):
    beans:           Members will be private, and setter methods will return void.
    private-members: Members will be private, but setter methods will return 'this' like usual.
    nocamel:         Do not use CamelCase field accessors with beans.
    hashcode:        Generate quality hashCode methods.
    android_legacy:  Do not use java.io.IOException(throwable) (available for Android 2.3 and above).
    java5:           Generate Java 1.5 compliant code (includes android_legacy flag).
    sorted_containers:
                     Use TreeSet/TreeMap instead of HashSet/HashMap as a implementation of set/map.

我完成了这个任务:-java:bean,但我不知道如何包含多个选项。我不明白这意味着什么:语言[:key1=val1[,key2,key3=val3]]

我尝试过这样的方法:“java[:bean,: hashcode]”,“java:bean,hashcode”“java:bean”,“java:bean :hashcode”“java[:bean,hashcode]”等等。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-17 08:51:39

这是标准符号,您会发现在整个地方都有大多数命令行实用工具,甚至是跨平台的。[括号]包含可选参数,方括号本身不在命令行中键入。

因此,在您的例子中,您想要这样做(例如):

代码语言:javascript
复制
thrift -gen java:beans,private-members,nocamel,java5,sorted_containers  yourfile.thrift

为java生成器指定五个附加选项。一些罕见的选项也采用了值,在这种情况下,它将是(例如,不是真实的):

代码语言:javascript
复制
thrift -gen java:option1=foo,option2,option3=bar  yourfile.thrift

它传递三个选项,其中两个选项具有关联的值。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23121808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档