diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-01-26 13:52:50 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-01-26 13:52:50 +0100 |
commit | 30beb498ca46772e60dd321a07e19be1d08d1e9a (patch) | |
tree | 7fe984d4c745408b1dd2cfc9f51d3205a258bbf1 /test/transform | |
parent | 75da1e2481d077d6c39b91aa9d364a397a41461f (diff) | |
download | lombok-30beb498ca46772e60dd321a07e19be1d08d1e9a.tar.gz lombok-30beb498ca46772e60dd321a07e19be1d08d1e9a.tar.bz2 lombok-30beb498ca46772e60dd321a07e19be1d08d1e9a.zip |
optimized the creation for singular lists/collections.
Diffstat (limited to 'test/transform')
5 files changed, 15 insertions, 39 deletions
diff --git a/test/transform/resource/after-delombok/BuilderSingularLists.java b/test/transform/resource/after-delombok/BuilderSingularLists.java index aa5382c1..0d074e92 100644 --- a/test/transform/resource/after-delombok/BuilderSingularLists.java +++ b/test/transform/resource/after-delombok/BuilderSingularLists.java @@ -66,11 +66,9 @@ class BuilderSingularLists<T> { children = java.util.Collections.singletonList(this.children.get(0)); break; default: - children = new java.util.ArrayList<T>(this.children.size()); - children.addAll(this.children); - children = java.util.Collections.unmodifiableList(children); + children = java.util.Collections.unmodifiableList(new java.util.ArrayList<T>(this.children)); } - java.util.List<Number> scarves; + java.util.Collection<Number> scarves; switch (this.scarves == null ? 0 : this.scarves.size()) { case 0: scarves = java.util.Collections.emptyList(); @@ -79,9 +77,7 @@ class BuilderSingularLists<T> { scarves = java.util.Collections.singletonList(this.scarves.get(0)); break; default: - scarves = new java.util.ArrayList<Number>(this.scarves.size()); - scarves.addAll(this.scarves); - scarves = java.util.Collections.unmodifiableList(scarves); + scarves = java.util.Collections.unmodifiableList(new java.util.ArrayList<Number>(this.scarves)); } java.util.List<java.lang.Object> rawList; switch (this.rawList == null ? 0 : this.rawList.size()) { @@ -92,9 +88,7 @@ class BuilderSingularLists<T> { rawList = java.util.Collections.singletonList(this.rawList.get(0)); break; default: - rawList = new java.util.ArrayList<java.lang.Object>(this.rawList.size()); - rawList.addAll(this.rawList); - rawList = java.util.Collections.unmodifiableList(rawList); + rawList = java.util.Collections.unmodifiableList(new java.util.ArrayList<java.lang.Object>(this.rawList)); } return new BuilderSingularLists<T>(children, scarves, rawList); } diff --git a/test/transform/resource/after-delombok/BuilderSingularNoAutosingularize.java b/test/transform/resource/after-delombok/BuilderSingularNoAutosingularize.java index 07bbef9c..5f985e16 100644 --- a/test/transform/resource/after-delombok/BuilderSingularNoAutosingularize.java +++ b/test/transform/resource/after-delombok/BuilderSingularNoAutosingularize.java @@ -64,9 +64,7 @@ class BuilderSingularNoAutosingularize { things = java.util.Collections.singletonList(this.things.get(0)); break; default: - things = new java.util.ArrayList<String>(this.things.size()); - things.addAll(this.things); - things = java.util.Collections.unmodifiableList(things); + things = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.things)); } java.util.List<String> widgets; switch (this.widgets == null ? 0 : this.widgets.size()) { @@ -77,9 +75,7 @@ class BuilderSingularNoAutosingularize { widgets = java.util.Collections.singletonList(this.widgets.get(0)); break; default: - widgets = new java.util.ArrayList<String>(this.widgets.size()); - widgets.addAll(this.widgets); - widgets = java.util.Collections.unmodifiableList(widgets); + widgets = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.widgets)); } java.util.List<String> items; switch (this.items == null ? 0 : this.items.size()) { @@ -90,9 +86,7 @@ class BuilderSingularNoAutosingularize { items = java.util.Collections.singletonList(this.items.get(0)); break; default: - items = new java.util.ArrayList<String>(this.items.size()); - items.addAll(this.items); - items = java.util.Collections.unmodifiableList(items); + items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.items)); } return new BuilderSingularNoAutosingularize(things, widgets, items); } diff --git a/test/transform/resource/after-ecj/BuilderSingularLists.java b/test/transform/resource/after-ecj/BuilderSingularLists.java index c0a3ef9a..9e4bb894 100644 --- a/test/transform/resource/after-ecj/BuilderSingularLists.java +++ b/test/transform/resource/after-ecj/BuilderSingularLists.java @@ -56,11 +56,9 @@ import lombok.Singular; children = java.util.Collections.singletonList(this.children.get(0)); break; default : - children = new java.util.ArrayList<T>(this.children.size()); - children.addAll(this.children); - children = java.util.Collections.unmodifiableList(children); + children = java.util.Collections.unmodifiableList(new java.util.ArrayList<T>(this.children)); } - java.util.List<Number> scarves; + java.util.Collection<Number> scarves; switch (((this.scarves == null) ? 0 : this.scarves.size())) { case 0 : scarves = java.util.Collections.emptyList(); @@ -69,9 +67,7 @@ import lombok.Singular; scarves = java.util.Collections.singletonList(this.scarves.get(0)); break; default : - scarves = new java.util.ArrayList<Number>(this.scarves.size()); - scarves.addAll(this.scarves); - scarves = java.util.Collections.unmodifiableList(scarves); + scarves = java.util.Collections.unmodifiableList(new java.util.ArrayList<Number>(this.scarves)); } java.util.List<java.lang.Object> rawList; switch (((this.rawList == null) ? 0 : this.rawList.size())) { @@ -82,9 +78,7 @@ import lombok.Singular; rawList = java.util.Collections.singletonList(this.rawList.get(0)); break; default : - rawList = new java.util.ArrayList<java.lang.Object>(this.rawList.size()); - rawList.addAll(this.rawList); - rawList = java.util.Collections.unmodifiableList(rawList); + rawList = java.util.Collections.unmodifiableList(new java.util.ArrayList<java.lang.Object>(this.rawList)); } return new BuilderSingularLists<T>(children, scarves, rawList); } diff --git a/test/transform/resource/after-ecj/BuilderSingularNoAutosingularize.java b/test/transform/resource/after-ecj/BuilderSingularNoAutosingularize.java index 53bed757..16febc2e 100644 --- a/test/transform/resource/after-ecj/BuilderSingularNoAutosingularize.java +++ b/test/transform/resource/after-ecj/BuilderSingularNoAutosingularize.java @@ -54,9 +54,7 @@ import lombok.Singular; things = java.util.Collections.singletonList(this.things.get(0)); break; default : - things = new java.util.ArrayList<String>(this.things.size()); - things.addAll(this.things); - things = java.util.Collections.unmodifiableList(things); + things = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.things)); } java.util.List<String> widgets; switch (((this.widgets == null) ? 0 : this.widgets.size())) { @@ -67,9 +65,7 @@ import lombok.Singular; widgets = java.util.Collections.singletonList(this.widgets.get(0)); break; default : - widgets = new java.util.ArrayList<String>(this.widgets.size()); - widgets.addAll(this.widgets); - widgets = java.util.Collections.unmodifiableList(widgets); + widgets = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.widgets)); } java.util.List<String> items; switch (((this.items == null) ? 0 : this.items.size())) { @@ -80,9 +76,7 @@ import lombok.Singular; items = java.util.Collections.singletonList(this.items.get(0)); break; default : - items = new java.util.ArrayList<String>(this.items.size()); - items.addAll(this.items); - items = java.util.Collections.unmodifiableList(items); + items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.items)); } return new BuilderSingularNoAutosingularize(things, widgets, items); } diff --git a/test/transform/resource/before/BuilderSingularRedirectToGuava.java b/test/transform/resource/before/BuilderSingularRedirectToGuava.java index 7e1e2c23..2dfa7684 100644 --- a/test/transform/resource/before/BuilderSingularRedirectToGuava.java +++ b/test/transform/resource/before/BuilderSingularRedirectToGuava.java @@ -1,4 +1,4 @@ -//CONF: lombok.builder.useGuava = true +//CONF: lombok.singular.useGuava = true import java.util.Set; import java.util.NavigableMap; import java.util.Collection; |