的sorted_containers
選項切換到
TreeMap
爲map<>
TreeSet
爲set<>
的選項是被當愈傷組織指定納克節儉編譯,就像這樣:
$ thrift -gen java:sorted_containers myfile.thrift
這裏是可以用於Java所有選項(CURENT主分支,thrift -help
透露更多信息)
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.
fullcamel: Convert underscored_accessor_or_service_names to camelCase.
android: Generated structures are Parcelable.
android_legacy: Do not use java.io.IOException(throwable) (available for Android 2.3 and above).
option_type: Wrap optional fields in an Option type.
java5: Generate Java 1.5 compliant code (includes android_legacy flag).
reuse-objects: Data objects will not be allocated, but existing instances will be used (read and write).
sorted_containers:
Use TreeSet/TreeMap instead of HashSet/HashMap as a implementation of set/map.
generated_annotations=[undated|suppress]:
undated: suppress the date at @Generated annotations
suppress: suppress @Generated annotations entirely
其他選項不可用。 C++生成器支持註釋,Java似乎不是這種情況。我有沒有提到we accept patches?
我已經知道我可以將類型更改爲由thrift生成的java類中的LinkedHashSet。但是,在我們的情況下,這並不是有用的,因爲我們每次在構建過程中生成/替換節儉類。 – Ruby9191