From bfe3f0dd02dcf7987348899e32324ead9e4652b5 Mon Sep 17 00:00:00 2001 From: overcat <4catcode@gmail.com> Date: Wed, 12 Jul 2023 20:30:59 +0800 Subject: [PATCH] feat(java): render constants. --- lib/xdrgen/generators/java.rb | 31 +++++++++++++++---- .../block_comments.x/AccountFlags.java | 2 +- .../block_comments.x/Constants.java | 10 ++++++ .../const.x/Constants.java | 11 +++++++ .../const.x/TestArray.java | 2 +- .../const.x/TestArray2.java | 2 +- .../generator_spec_java/enum.x/Color.java | 2 +- .../generator_spec_java/enum.x/Color2.java | 2 +- .../generator_spec_java/enum.x/Constants.java | 10 ++++++ .../enum.x/MessageType.java | 2 +- .../nesting.x/Constants.java | 10 ++++++ .../generator_spec_java/nesting.x/Foo.java | 2 +- .../nesting.x/MyUnion.java | 2 +- .../nesting.x/UnionKey.java | 2 +- .../generator_spec_java/optional.x/Arr.java | 2 +- .../optional.x/Constants.java | 10 ++++++ .../optional.x/HasOptions.java | 2 +- .../struct.x/Constants.java | 10 ++++++ .../generator_spec_java/struct.x/Int64.java | 2 +- .../struct.x/MyStruct.java | 2 +- .../generator_spec_java/test.x/Color.java | 2 +- .../generator_spec_java/test.x/Constants.java | 12 +++++++ .../generator_spec_java/test.x/HasStuff.java | 2 +- .../generator_spec_java/test.x/Hash.java | 2 +- .../generator_spec_java/test.x/Hashes1.java | 2 +- .../generator_spec_java/test.x/Hashes2.java | 2 +- .../generator_spec_java/test.x/Hashes3.java | 2 +- .../generator_spec_java/test.x/Int1.java | 2 +- .../generator_spec_java/test.x/Int2.java | 2 +- .../generator_spec_java/test.x/Int3.java | 2 +- .../generator_spec_java/test.x/Int4.java | 2 +- .../test.x/LotsOfMyStructs.java | 2 +- .../generator_spec_java/test.x/MyStruct.java | 2 +- .../generator_spec_java/test.x/Nester.java | 2 +- .../generator_spec_java/test.x/OptHash1.java | 2 +- .../generator_spec_java/test.x/OptHash2.java | 2 +- .../generator_spec_java/test.x/Str.java | 2 +- .../generator_spec_java/test.x/Str2.java | 2 +- .../generator_spec_java/test.x/Uint512.java | 2 +- .../generator_spec_java/test.x/Uint513.java | 2 +- .../generator_spec_java/test.x/Uint514.java | 2 +- .../union.x/Constants.java | 10 ++++++ .../generator_spec_java/union.x/Error.java | 2 +- .../generator_spec_java/union.x/IntUnion.java | 2 +- .../union.x/IntUnion2.java | 2 +- .../generator_spec_java/union.x/Multi.java | 2 +- .../generator_spec_java/union.x/MyUnion.java | 2 +- .../generator_spec_java/union.x/UnionKey.java | 2 +- 48 files changed, 147 insertions(+), 45 deletions(-) create mode 100644 spec/output/generator_spec_java/block_comments.x/Constants.java create mode 100644 spec/output/generator_spec_java/const.x/Constants.java create mode 100644 spec/output/generator_spec_java/enum.x/Constants.java create mode 100644 spec/output/generator_spec_java/nesting.x/Constants.java create mode 100644 spec/output/generator_spec_java/optional.x/Constants.java create mode 100644 spec/output/generator_spec_java/struct.x/Constants.java create mode 100644 spec/output/generator_spec_java/test.x/Constants.java create mode 100644 spec/output/generator_spec_java/union.x/Constants.java diff --git a/lib/xdrgen/generators/java.rb b/lib/xdrgen/generators/java.rb index 476c1d754..d495d44c7 100644 --- a/lib/xdrgen/generators/java.rb +++ b/lib/xdrgen/generators/java.rb @@ -6,8 +6,10 @@ module Generators class Java < Xdrgen::Generators::Base def generate + constants_container = Set[] render_lib - render_definitions(@top) + render_definitions(@top, constants_container) + render_constants constants_container end def render_lib @@ -28,9 +30,9 @@ def render_lib @output.write "XdrString.java", result end - def render_definitions(node) - node.namespaces.each{|n| render_definitions n } - node.definitions.each(&method(:render_definition)) + def render_definitions(node, constants_container) + node.namespaces.each{|n| render_definitions n, constants_container } + node.definitions.each { |defn| render_definition(defn, constants_container) } end def add_imports_for_definition(defn, imports) @@ -92,7 +94,7 @@ def add_imports_for_definition(defn, imports) end end - def render_definition(defn) + def render_definition(defn, constants_container) imports = Set[] add_imports_for_definition(defn, imports) @@ -115,6 +117,10 @@ def render_definition(defn) render_element "public class", imports, defn do |out| render_typedef defn, out end + when AST::Definitions::Const ; + const_name = defn.name + const_value = defn.value + constants_container.add([const_name, const_value]) end end @@ -161,6 +167,7 @@ def render_element(type, imports, element, post_name="implements XdrElement") name = name_string element.name out = @output.open(path) render_top_matter out + out.puts "import static #{@namespace}.Constants.*;" imports.each do |import| out.puts "import #{import};" end @@ -174,6 +181,19 @@ def render_element(type, imports, element, post_name="implements XdrElement") out.puts "}" end + def render_constants(constants_container) + out = @output.open("Constants.java") + render_top_matter out + out.puts "public final class Constants {" + out.indent do + out.puts "private Constants() {}" + constants_container.each do |const_name, const_value| + out.puts "public static final int #{const_name} = #{const_value};" + end + end + out.puts "}" + end + def render_enum(enum, out) out.balance_after /,[\s]*/ do enum.members.each do |em| @@ -656,7 +676,6 @@ def render_top_matter(out) package #{@namespace}; - import java.io.IOException; EOS out.break diff --git a/spec/output/generator_spec_java/block_comments.x/AccountFlags.java b/spec/output/generator_spec_java/block_comments.x/AccountFlags.java index 93b03f074..876dee3ea 100644 --- a/spec/output/generator_spec_java/block_comments.x/AccountFlags.java +++ b/spec/output/generator_spec_java/block_comments.x/AccountFlags.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/block_comments.x/Constants.java b/spec/output/generator_spec_java/block_comments.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/block_comments.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/const.x/Constants.java b/spec/output/generator_spec_java/const.x/Constants.java new file mode 100644 index 000000000..1e2b80847 --- /dev/null +++ b/spec/output/generator_spec_java/const.x/Constants.java @@ -0,0 +1,11 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} + public static final int FOO = 1; +} diff --git a/spec/output/generator_spec_java/const.x/TestArray.java b/spec/output/generator_spec_java/const.x/TestArray.java index 68f5aeba4..f97db82fe 100644 --- a/spec/output/generator_spec_java/const.x/TestArray.java +++ b/spec/output/generator_spec_java/const.x/TestArray.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/const.x/TestArray2.java b/spec/output/generator_spec_java/const.x/TestArray2.java index cc4f613b2..949761606 100644 --- a/spec/output/generator_spec_java/const.x/TestArray2.java +++ b/spec/output/generator_spec_java/const.x/TestArray2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/enum.x/Color.java b/spec/output/generator_spec_java/enum.x/Color.java index ac31300ed..cfd87ad25 100644 --- a/spec/output/generator_spec_java/enum.x/Color.java +++ b/spec/output/generator_spec_java/enum.x/Color.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/enum.x/Color2.java b/spec/output/generator_spec_java/enum.x/Color2.java index c39a3ff03..78808edb6 100644 --- a/spec/output/generator_spec_java/enum.x/Color2.java +++ b/spec/output/generator_spec_java/enum.x/Color2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/enum.x/Constants.java b/spec/output/generator_spec_java/enum.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/enum.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/enum.x/MessageType.java b/spec/output/generator_spec_java/enum.x/MessageType.java index 6626f6a1f..2dc247818 100644 --- a/spec/output/generator_spec_java/enum.x/MessageType.java +++ b/spec/output/generator_spec_java/enum.x/MessageType.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/nesting.x/Constants.java b/spec/output/generator_spec_java/nesting.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/nesting.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/nesting.x/Foo.java b/spec/output/generator_spec_java/nesting.x/Foo.java index 17c001dc3..0555036fa 100644 --- a/spec/output/generator_spec_java/nesting.x/Foo.java +++ b/spec/output/generator_spec_java/nesting.x/Foo.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/nesting.x/MyUnion.java b/spec/output/generator_spec_java/nesting.x/MyUnion.java index 3f9f83faf..029b3acc4 100644 --- a/spec/output/generator_spec_java/nesting.x/MyUnion.java +++ b/spec/output/generator_spec_java/nesting.x/MyUnion.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/nesting.x/UnionKey.java b/spec/output/generator_spec_java/nesting.x/UnionKey.java index e98057ce8..84b89a4a1 100644 --- a/spec/output/generator_spec_java/nesting.x/UnionKey.java +++ b/spec/output/generator_spec_java/nesting.x/UnionKey.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/optional.x/Arr.java b/spec/output/generator_spec_java/optional.x/Arr.java index f8f882592..6055f4cf9 100644 --- a/spec/output/generator_spec_java/optional.x/Arr.java +++ b/spec/output/generator_spec_java/optional.x/Arr.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/optional.x/Constants.java b/spec/output/generator_spec_java/optional.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/optional.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/optional.x/HasOptions.java b/spec/output/generator_spec_java/optional.x/HasOptions.java index 87ead7d25..9c6294aca 100644 --- a/spec/output/generator_spec_java/optional.x/HasOptions.java +++ b/spec/output/generator_spec_java/optional.x/HasOptions.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/struct.x/Constants.java b/spec/output/generator_spec_java/struct.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/struct.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/struct.x/Int64.java b/spec/output/generator_spec_java/struct.x/Int64.java index c03bd20ca..b7bc4fadb 100644 --- a/spec/output/generator_spec_java/struct.x/Int64.java +++ b/spec/output/generator_spec_java/struct.x/Int64.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/struct.x/MyStruct.java b/spec/output/generator_spec_java/struct.x/MyStruct.java index 69cde5e57..0b14aa772 100644 --- a/spec/output/generator_spec_java/struct.x/MyStruct.java +++ b/spec/output/generator_spec_java/struct.x/MyStruct.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; import java.util.Arrays; diff --git a/spec/output/generator_spec_java/test.x/Color.java b/spec/output/generator_spec_java/test.x/Color.java index f056d2071..953b51dd1 100644 --- a/spec/output/generator_spec_java/test.x/Color.java +++ b/spec/output/generator_spec_java/test.x/Color.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Constants.java b/spec/output/generator_spec_java/test.x/Constants.java new file mode 100644 index 000000000..646061555 --- /dev/null +++ b/spec/output/generator_spec_java/test.x/Constants.java @@ -0,0 +1,12 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} + public static final int FOO = 1244; + public static final int BAR = FOO; +} diff --git a/spec/output/generator_spec_java/test.x/HasStuff.java b/spec/output/generator_spec_java/test.x/HasStuff.java index 56a086f91..58b8e56b2 100644 --- a/spec/output/generator_spec_java/test.x/HasStuff.java +++ b/spec/output/generator_spec_java/test.x/HasStuff.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Hash.java b/spec/output/generator_spec_java/test.x/Hash.java index 89b5e6433..cd4aa9d0f 100644 --- a/spec/output/generator_spec_java/test.x/Hash.java +++ b/spec/output/generator_spec_java/test.x/Hash.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Hashes1.java b/spec/output/generator_spec_java/test.x/Hashes1.java index a1b58a400..d47aba092 100644 --- a/spec/output/generator_spec_java/test.x/Hashes1.java +++ b/spec/output/generator_spec_java/test.x/Hashes1.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Hashes2.java b/spec/output/generator_spec_java/test.x/Hashes2.java index 67f88c14b..389783f20 100644 --- a/spec/output/generator_spec_java/test.x/Hashes2.java +++ b/spec/output/generator_spec_java/test.x/Hashes2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Hashes3.java b/spec/output/generator_spec_java/test.x/Hashes3.java index eff998cc1..beeaf6711 100644 --- a/spec/output/generator_spec_java/test.x/Hashes3.java +++ b/spec/output/generator_spec_java/test.x/Hashes3.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Int1.java b/spec/output/generator_spec_java/test.x/Int1.java index dd1ef4fb9..e293418b2 100644 --- a/spec/output/generator_spec_java/test.x/Int1.java +++ b/spec/output/generator_spec_java/test.x/Int1.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Int2.java b/spec/output/generator_spec_java/test.x/Int2.java index fad2a12b1..eb7c04931 100644 --- a/spec/output/generator_spec_java/test.x/Int2.java +++ b/spec/output/generator_spec_java/test.x/Int2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Int3.java b/spec/output/generator_spec_java/test.x/Int3.java index 22f040b10..5ab4fa4c7 100644 --- a/spec/output/generator_spec_java/test.x/Int3.java +++ b/spec/output/generator_spec_java/test.x/Int3.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Int4.java b/spec/output/generator_spec_java/test.x/Int4.java index 6199f5af6..17ce1c4e7 100644 --- a/spec/output/generator_spec_java/test.x/Int4.java +++ b/spec/output/generator_spec_java/test.x/Int4.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/LotsOfMyStructs.java b/spec/output/generator_spec_java/test.x/LotsOfMyStructs.java index 2b73289cb..9238e0bbc 100644 --- a/spec/output/generator_spec_java/test.x/LotsOfMyStructs.java +++ b/spec/output/generator_spec_java/test.x/LotsOfMyStructs.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/MyStruct.java b/spec/output/generator_spec_java/test.x/MyStruct.java index 02417b319..b6c5d3894 100644 --- a/spec/output/generator_spec_java/test.x/MyStruct.java +++ b/spec/output/generator_spec_java/test.x/MyStruct.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Nester.java b/spec/output/generator_spec_java/test.x/Nester.java index c5a58271f..5d3b957ba 100644 --- a/spec/output/generator_spec_java/test.x/Nester.java +++ b/spec/output/generator_spec_java/test.x/Nester.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/OptHash1.java b/spec/output/generator_spec_java/test.x/OptHash1.java index 129ab5e06..6da753317 100644 --- a/spec/output/generator_spec_java/test.x/OptHash1.java +++ b/spec/output/generator_spec_java/test.x/OptHash1.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/OptHash2.java b/spec/output/generator_spec_java/test.x/OptHash2.java index c9fb49975..b94e59132 100644 --- a/spec/output/generator_spec_java/test.x/OptHash2.java +++ b/spec/output/generator_spec_java/test.x/OptHash2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Str.java b/spec/output/generator_spec_java/test.x/Str.java index c2aff5be2..f7b47bce4 100644 --- a/spec/output/generator_spec_java/test.x/Str.java +++ b/spec/output/generator_spec_java/test.x/Str.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Str2.java b/spec/output/generator_spec_java/test.x/Str2.java index a3a3a6658..ad7921eea 100644 --- a/spec/output/generator_spec_java/test.x/Str2.java +++ b/spec/output/generator_spec_java/test.x/Str2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Uint512.java b/spec/output/generator_spec_java/test.x/Uint512.java index d4e599497..5342d0254 100644 --- a/spec/output/generator_spec_java/test.x/Uint512.java +++ b/spec/output/generator_spec_java/test.x/Uint512.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Uint513.java b/spec/output/generator_spec_java/test.x/Uint513.java index 91f977b6f..3d237a027 100644 --- a/spec/output/generator_spec_java/test.x/Uint513.java +++ b/spec/output/generator_spec_java/test.x/Uint513.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/test.x/Uint514.java b/spec/output/generator_spec_java/test.x/Uint514.java index e1fd07890..e7212b369 100644 --- a/spec/output/generator_spec_java/test.x/Uint514.java +++ b/spec/output/generator_spec_java/test.x/Uint514.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import java.util.Arrays; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/union.x/Constants.java b/spec/output/generator_spec_java/union.x/Constants.java new file mode 100644 index 000000000..d7d9f4cfc --- /dev/null +++ b/spec/output/generator_spec_java/union.x/Constants.java @@ -0,0 +1,10 @@ +// Automatically generated by xdrgen +// DO NOT EDIT or your changes may be overwritten + +package MyXDR; + +import java.io.IOException; + +public final class Constants { + private Constants() {} +} diff --git a/spec/output/generator_spec_java/union.x/Error.java b/spec/output/generator_spec_java/union.x/Error.java index fa2d711d6..f3841e233 100644 --- a/spec/output/generator_spec_java/union.x/Error.java +++ b/spec/output/generator_spec_java/union.x/Error.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/union.x/IntUnion.java b/spec/output/generator_spec_java/union.x/IntUnion.java index 3595d575a..ae972e472 100644 --- a/spec/output/generator_spec_java/union.x/IntUnion.java +++ b/spec/output/generator_spec_java/union.x/IntUnion.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; import java.util.Arrays; diff --git a/spec/output/generator_spec_java/union.x/IntUnion2.java b/spec/output/generator_spec_java/union.x/IntUnion2.java index e3233374f..1d7b179d6 100644 --- a/spec/output/generator_spec_java/union.x/IntUnion2.java +++ b/spec/output/generator_spec_java/union.x/IntUnion2.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/union.x/Multi.java b/spec/output/generator_spec_java/union.x/Multi.java index 4d0d094e2..5a02d3984 100644 --- a/spec/output/generator_spec_java/union.x/Multi.java +++ b/spec/output/generator_spec_java/union.x/Multi.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; // === xdr source ============================================================ diff --git a/spec/output/generator_spec_java/union.x/MyUnion.java b/spec/output/generator_spec_java/union.x/MyUnion.java index c5962eef0..66debea2f 100644 --- a/spec/output/generator_spec_java/union.x/MyUnion.java +++ b/spec/output/generator_spec_java/union.x/MyUnion.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; import com.google.common.base.Objects; import java.util.Arrays; diff --git a/spec/output/generator_spec_java/union.x/UnionKey.java b/spec/output/generator_spec_java/union.x/UnionKey.java index bfcfa8880..3f0fb8d7b 100644 --- a/spec/output/generator_spec_java/union.x/UnionKey.java +++ b/spec/output/generator_spec_java/union.x/UnionKey.java @@ -3,9 +3,9 @@ package MyXDR; - import java.io.IOException; +import static MyXDR.Constants.*; // === xdr source ============================================================