diff options
Diffstat (limited to 'test/transform/resource/after-delombok')
3 files changed, 181 insertions, 24 deletions
diff --git a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java index d621d376..93825659 100644 --- a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java +++ b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java @@ -1,34 +1,42 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; import java.util.Set; import java.util.Map; import lombok.NonNull; +@Target(ElementType.TYPE_USE) +@interface MyAnnotation { +} class BuilderSingularAnnotatedTypes { - private Set<@NonNull String> foos; - private Map<@NonNull String, @NonNull Integer> bars; + private Set<@MyAnnotation @NonNull String> foos; + private Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; @java.lang.SuppressWarnings("all") - BuilderSingularAnnotatedTypes(final Set<@NonNull String> foos, final Map<@NonNull String, @NonNull Integer> bars) { + BuilderSingularAnnotatedTypes(final Set<@MyAnnotation @NonNull String> foos, final Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars) { this.foos = foos; this.bars = bars; } @java.lang.SuppressWarnings("all") public static class BuilderSingularAnnotatedTypesBuilder { @java.lang.SuppressWarnings("all") - private java.util.ArrayList<@NonNull String> foos; + private java.util.ArrayList<@MyAnnotation @NonNull String> foos; @java.lang.SuppressWarnings("all") - private java.util.ArrayList<@NonNull String> bars$key; + private java.util.ArrayList<@MyAnnotation @NonNull String> bars$key; @java.lang.SuppressWarnings("all") - private java.util.ArrayList<@NonNull Integer> bars$value; + private java.util.ArrayList<@MyAnnotation @NonNull Integer> bars$value; @java.lang.SuppressWarnings("all") BuilderSingularAnnotatedTypesBuilder() { } @java.lang.SuppressWarnings("all") - public BuilderSingularAnnotatedTypesBuilder foo(final @NonNull String foo) { - if (this.foos == null) this.foos = new java.util.ArrayList<@NonNull String>(); + public BuilderSingularAnnotatedTypesBuilder foo(@MyAnnotation @NonNull final String foo) { + if (foo == null) { + throw new java.lang.NullPointerException("foo is marked @NonNull but is null"); + } + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); this.foos.add(foo); return this; } @java.lang.SuppressWarnings("all") - public BuilderSingularAnnotatedTypesBuilder foos(final java.util.Collection<? extends @NonNull String> foos) { - if (this.foos == null) this.foos = new java.util.ArrayList<@NonNull String>(); + public BuilderSingularAnnotatedTypesBuilder foos(final java.util.Collection<? extends @MyAnnotation @NonNull String> foos) { + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); this.foos.addAll(foos); return this; } @@ -38,22 +46,28 @@ class BuilderSingularAnnotatedTypes { return this; } @java.lang.SuppressWarnings("all") - public BuilderSingularAnnotatedTypesBuilder bar(final @NonNull String barKey, final @NonNull Integer barValue) { + public BuilderSingularAnnotatedTypesBuilder bar(@MyAnnotation @NonNull final String barKey, @MyAnnotation @NonNull final Integer barValue) { + if (barKey == null) { + throw new java.lang.NullPointerException("barKey is marked @NonNull but is null"); + } + if (barValue == null) { + throw new java.lang.NullPointerException("barValue is marked @NonNull but is null"); + } if (this.bars$key == null) { - this.bars$key = new java.util.ArrayList<@NonNull String>(); - this.bars$value = new java.util.ArrayList<@NonNull Integer>(); + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); } this.bars$key.add(barKey); this.bars$value.add(barValue); return this; } @java.lang.SuppressWarnings("all") - public BuilderSingularAnnotatedTypesBuilder bars(final java.util.Map<? extends @NonNull String, ? extends @NonNull Integer> bars) { + public BuilderSingularAnnotatedTypesBuilder bars(final java.util.Map<? extends @MyAnnotation @NonNull String, ? extends @MyAnnotation @NonNull Integer> bars) { if (this.bars$key == null) { - this.bars$key = new java.util.ArrayList<@NonNull String>(); - this.bars$value = new java.util.ArrayList<@NonNull Integer>(); + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); } - for (final java.util.Map.Entry<? extends @NonNull String, ? extends @NonNull Integer> $lombokEntry : bars.entrySet()) { + for (final java.util.Map.Entry<? extends @MyAnnotation @NonNull String, ? extends @MyAnnotation @NonNull Integer> $lombokEntry : bars.entrySet()) { this.bars$key.add($lombokEntry.getKey()); this.bars$value.add($lombokEntry.getValue()); } @@ -69,7 +83,7 @@ class BuilderSingularAnnotatedTypes { } @java.lang.SuppressWarnings("all") public BuilderSingularAnnotatedTypes build() { - java.util.Set<@NonNull String> foos; + java.util.Set<@MyAnnotation @NonNull String> foos; switch (this.foos == null ? 0 : this.foos.size()) { case 0: foos = java.util.Collections.emptySet(); @@ -78,11 +92,11 @@ class BuilderSingularAnnotatedTypes { foos = java.util.Collections.singleton(this.foos.get(0)); break; default: - foos = new java.util.LinkedHashSet<@NonNull String>(this.foos.size() < 1073741824 ? 1 + this.foos.size() + (this.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + foos = new java.util.LinkedHashSet<@MyAnnotation @NonNull String>(this.foos.size() < 1073741824 ? 1 + this.foos.size() + (this.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); foos.addAll(this.foos); foos = java.util.Collections.unmodifiableSet(foos); } - java.util.Map<@NonNull String, @NonNull Integer> bars; + java.util.Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; switch (this.bars$key == null ? 0 : this.bars$key.size()) { case 0: bars = java.util.Collections.emptyMap(); @@ -91,8 +105,8 @@ class BuilderSingularAnnotatedTypes { bars = java.util.Collections.singletonMap(this.bars$key.get(0), this.bars$value.get(0)); break; default: - bars = new java.util.LinkedHashMap<@NonNull String, @NonNull Integer>(this.bars$key.size() < 1073741824 ? 1 + this.bars$key.size() + (this.bars$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); - for (int $i = 0; $i < this.bars$key.size(); $i++) bars.put(this.bars$key.get($i), (@NonNull Integer) this.bars$value.get($i)); + bars = new java.util.LinkedHashMap<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer>(this.bars$key.size() < 1073741824 ? 1 + this.bars$key.size() + (this.bars$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + for (int $i = 0; $i < this.bars$key.size(); $i++) bars.put(this.bars$key.get($i), (@MyAnnotation @NonNull Integer) this.bars$value.get($i)); bars = java.util.Collections.unmodifiableMap(bars); } return new BuilderSingularAnnotatedTypes(foos, bars); diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java new file mode 100644 index 00000000..1baf81aa --- /dev/null +++ b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java @@ -0,0 +1,137 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.Set; +import java.util.Map; +import lombok.NonNull; +@Target(ElementType.TYPE_USE) +@interface MyAnnotation { +} +class SuperBuilderSingularAnnotatedTypes { + private Set<@MyAnnotation @NonNull String> foos; + private Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + @java.lang.SuppressWarnings("all") + public static abstract class SuperBuilderSingularAnnotatedTypesBuilder<C extends SuperBuilderSingularAnnotatedTypes, B extends SuperBuilderSingularAnnotatedTypesBuilder<C, B>> { + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull String> foos; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull String> bars$key; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList<@MyAnnotation @NonNull Integer> bars$value; + @java.lang.SuppressWarnings("all") + protected abstract B self(); + @java.lang.SuppressWarnings("all") + public abstract C build(); + @java.lang.SuppressWarnings("all") + public B foo(@MyAnnotation @NonNull final String foo) { + if (foo == null) { + throw new java.lang.NullPointerException("foo is marked @NonNull but is null"); + } + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.foos.add(foo); + return self(); + } + @java.lang.SuppressWarnings("all") + public B foos(final java.util.Collection<? extends @MyAnnotation @NonNull String> foos) { + if (this.foos == null) this.foos = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.foos.addAll(foos); + return self(); + } + @java.lang.SuppressWarnings("all") + public B clearFoos() { + if (this.foos != null) this.foos.clear(); + return self(); + } + @java.lang.SuppressWarnings("all") + public B bar(@MyAnnotation @NonNull final String barKey, @MyAnnotation @NonNull final Integer barValue) { + if (barKey == null) { + throw new java.lang.NullPointerException("barKey is marked @NonNull but is null"); + } + if (barValue == null) { + throw new java.lang.NullPointerException("barValue is marked @NonNull but is null"); + } + if (this.bars$key == null) { + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); + } + this.bars$key.add(barKey); + this.bars$value.add(barValue); + return self(); + } + @java.lang.SuppressWarnings("all") + public B bars(final java.util.Map<? extends @MyAnnotation @NonNull String, ? extends @MyAnnotation @NonNull Integer> bars) { + if (this.bars$key == null) { + this.bars$key = new java.util.ArrayList<@MyAnnotation @NonNull String>(); + this.bars$value = new java.util.ArrayList<@MyAnnotation @NonNull Integer>(); + } + for (final java.util.Map.Entry<? extends @MyAnnotation @NonNull String, ? extends @MyAnnotation @NonNull Integer> $lombokEntry : bars.entrySet()) { + this.bars$key.add($lombokEntry.getKey()); + this.bars$value.add($lombokEntry.getValue()); + } + return self(); + } + @java.lang.SuppressWarnings("all") + public B clearBars() { + if (this.bars$key != null) { + this.bars$key.clear(); + this.bars$value.clear(); + } + return self(); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "SuperBuilderSingularAnnotatedTypes.SuperBuilderSingularAnnotatedTypesBuilder(foos=" + this.foos + ", bars$key=" + this.bars$key + ", bars$value=" + this.bars$value + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class SuperBuilderSingularAnnotatedTypesBuilderImpl extends SuperBuilderSingularAnnotatedTypesBuilder<SuperBuilderSingularAnnotatedTypes, SuperBuilderSingularAnnotatedTypesBuilderImpl> { + @java.lang.SuppressWarnings("all") + private SuperBuilderSingularAnnotatedTypesBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected SuperBuilderSingularAnnotatedTypesBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public SuperBuilderSingularAnnotatedTypes build() { + return new SuperBuilderSingularAnnotatedTypes(this); + } + } + @java.lang.SuppressWarnings("all") + protected SuperBuilderSingularAnnotatedTypes(final SuperBuilderSingularAnnotatedTypesBuilder<?, ?> b) { + java.util.Set<@MyAnnotation @NonNull String> foos; + switch (b.foos == null ? 0 : b.foos.size()) { + case 0: + foos = java.util.Collections.emptySet(); + break; + case 1: + foos = java.util.Collections.singleton(b.foos.get(0)); + break; + default: + foos = new java.util.LinkedHashSet<@MyAnnotation @NonNull String>(b.foos.size() < 1073741824 ? 1 + b.foos.size() + (b.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + foos.addAll(b.foos); + foos = java.util.Collections.unmodifiableSet(foos); + } + this.foos = foos; + java.util.Map<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer> bars; + switch (b.bars$key == null ? 0 : b.bars$key.size()) { + case 0: + bars = java.util.Collections.emptyMap(); + break; + case 1: + bars = java.util.Collections.singletonMap(b.bars$key.get(0), b.bars$value.get(0)); + break; + default: + bars = new java.util.LinkedHashMap<@MyAnnotation @NonNull String, @MyAnnotation @NonNull Integer>(b.bars$key.size() < 1073741824 ? 1 + b.bars$key.size() + (b.bars$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE); + for (int $i = 0; $i < b.bars$key.size(); $i++) bars.put(b.bars$key.get($i), (@MyAnnotation @NonNull Integer) b.bars$value.get($i)); + bars = java.util.Collections.unmodifiableMap(bars); + } + this.bars = bars; + } + @java.lang.SuppressWarnings("all") + public static SuperBuilderSingularAnnotatedTypesBuilder<?, ?> builder() { + return new SuperBuilderSingularAnnotatedTypesBuilderImpl(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java index 5eba938f..cac5482b 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java @@ -18,7 +18,10 @@ public class SuperBuilderWithNonNull { @java.lang.SuppressWarnings("all")
public abstract C build();
@java.lang.SuppressWarnings("all")
- public B nonNullParentField(final String nonNullParentField) {
+ public B nonNullParentField(@lombok.NonNull final String nonNullParentField) {
+ if (nonNullParentField == null) {
+ throw new java.lang.NullPointerException("nonNullParentField is marked @NonNull but is null");
+ }
this.nonNullParentField = nonNullParentField;
nonNullParentField$set = true;
return self();
@@ -72,7 +75,10 @@ public class SuperBuilderWithNonNull { @java.lang.SuppressWarnings("all")
public abstract C build();
@java.lang.SuppressWarnings("all")
- public B nonNullChildField(final String nonNullChildField) {
+ public B nonNullChildField(@lombok.NonNull final String nonNullChildField) {
+ if (nonNullChildField == null) {
+ throw new java.lang.NullPointerException("nonNullChildField is marked @NonNull but is null");
+ }
this.nonNullChildField = nonNullChildField;
return self();
}
|