mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
SuperBuilder toBuilder with generics (ecj)
This commit is contained in:
1 parent
68318742ef
commit
279ceaa727
2 files changed
+15
-20
No files matched your search
@@ -572,9 +572,6 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
out.modifiers = ClassFileConstants.AccPublic;
|
||||
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
|
||||
|
||||
// Add type params if there are any.
|
||||
if (typeParams != null && typeParams.length > 0) out.typeParameters = copyTypeParams(typeParams, source);
|
||||
|
||||
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND) };
|
||||
out.returnType = new ParameterizedSingleTypeReference(builderClassName.toCharArray(), mergeToTypeReferences(typeParams, wildcards), 0, p);
|
||||
|
||||
@@ -609,7 +606,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
if (inherited) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get())};
|
||||
out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0);
|
||||
|
||||
TypeReference builderType = createTypeReferenceWithTypeParameters(classGenericName, typeParams);
|
||||
TypeReference builderType = new SingleTypeReference(classGenericName.toCharArray(), 0);
|
||||
out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, builderType, Modifier.FINAL)};
|
||||
|
||||
List<Statement> body = new ArrayList<Statement>();
|
||||
@@ -662,7 +659,11 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND)};
|
||||
TypeReference builderType = new ParameterizedSingleTypeReference(builderClassName.toCharArray(), mergeToTypeReferences(typeParams, wildcards), 0, 0);
|
||||
Argument builderArgument = new Argument(BUILDER_VARIABLE_NAME, 0, builderType, Modifier.FINAL);
|
||||
out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, new SingleTypeReference(tdParent.getName().toCharArray(), 0), Modifier.FINAL), builderArgument};
|
||||
TypeReference parentArgument = new ParameterizedSingleTypeReference(tdParent.getName().toCharArray(), mergeToTypeReferences(typeParams, new TypeReference[0]), 0, 0);
|
||||
out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, parentArgument, Modifier.FINAL), builderArgument};
|
||||
|
||||
// Add type params if there are any.
|
||||
if (typeParams.length > 0) out.typeParameters = copyTypeParams(typeParams, source);
|
||||
|
||||
List<Statement> body = new ArrayList<Statement>();
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import java.util.List;
|
||||
|
||||
import SuperBuilderBasicToBuilder.Child;
|
||||
import SuperBuilderBasicToBuilder.Parent;
|
||||
import SuperBuilderBasicToBuilder.Child.ChildBuilder;
|
||||
import SuperBuilderBasicToBuilder.Child.ChildBuilderImpl;
|
||||
import SuperBuilderBasicToBuilder.Parent.ParentBuilder;
|
||||
public class SuperBuilderWithGenericsAndToBuilder {
|
||||
public static @lombok.experimental.SuperBuilder class Parent<A> {
|
||||
public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent<A> {
|
||||
public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends Parent<A>, B extends ParentBuilder<A, C, B>> {
|
||||
private @java.lang.SuppressWarnings("all") A field1;
|
||||
private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
|
||||
@@ -14,10 +8,10 @@ public class SuperBuilderWithGenericsAndToBuilder {
|
||||
super();
|
||||
}
|
||||
protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
|
||||
ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
|
||||
return self();
|
||||
}
|
||||
private static @java.lang.SuppressWarnings("all") void <A>$fillValuesFromInstanceIntoBuilder(final Parent<A> instance, final ParentBuilder<A, ?, ?> b) {
|
||||
ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
|
||||
return self();
|
||||
}
|
||||
private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final Parent<A> instance, final ParentBuilder<A, ?, ?> b) {
|
||||
b.field1(instance.field1);
|
||||
b.items(((instance.items == null) ? java.util.Collections.emptyList() : instance.items));
|
||||
}
|
||||
@@ -77,14 +71,14 @@ public class SuperBuilderWithGenericsAndToBuilder {
|
||||
}
|
||||
this.items = items;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") <A>ParentBuilder<A, ?, ?> toBuilder() {
|
||||
public @java.lang.SuppressWarnings("all") ParentBuilder<A, ?, ?> toBuilder() {
|
||||
return new ParentBuilderImpl<A>().$fillValuesFrom(this);
|
||||
}
|
||||
public static @java.lang.SuppressWarnings("all") <A>ParentBuilder<A, ?, ?> builder() {
|
||||
return new ParentBuilderImpl<A>();
|
||||
}
|
||||
}
|
||||
public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
|
||||
public static @lombok.experimental.SuperBuilder(toBuilder = true) class Child<A> extends Parent<A> {
|
||||
public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends Child<A>, B extends ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
|
||||
private @java.lang.SuppressWarnings("all") double field3;
|
||||
public ChildBuilder() {
|
||||
@@ -95,7 +89,7 @@ public class SuperBuilderWithGenericsAndToBuilder {
|
||||
ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
|
||||
return self();
|
||||
}
|
||||
private static @java.lang.SuppressWarnings("all") void <A>$fillValuesFromInstanceIntoBuilder(final Child<A> instance, final ChildBuilder<A, <d?, ?> b) {
|
||||
private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final Child<A> instance, final ChildBuilder<A, ?, ?> b) {
|
||||
b.field3(instance.field3);
|
||||
}
|
||||
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
|
||||
@@ -131,7 +125,7 @@ public class SuperBuilderWithGenericsAndToBuilder {
|
||||
return new ChildBuilderImpl<A>();
|
||||
}
|
||||
}
|
||||
public SuperBuilderWithGenerics() {
|
||||
public SuperBuilderWithGenericsAndToBuilder() {
|
||||
super();
|
||||
}
|
||||
public static void test() {
|
||||
|
||||
Reference in new issue
Block a user