mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 06:17:44 +00:00
[issue #788] Add more nullity annotations where relevant
(chainable setters, static constructors, builder stuff)
This commit is contained in:
24 files changed
+112
-41
No files matched your search
@@ -7,7 +7,7 @@ Lombok Changelog
|
||||
* FEATURE: In [`lombok.config`](https://projectlombok.org/features/configuration) it is possible to import other config files, even from a `.zip` or `.jar`.
|
||||
* FEATURE: You can now configure a builder's 'setter' prefixes via `@Builder(setterPrefix = "set")` for example. We discourage doing this, but if some library you use requires them, have at it. [Pull Request #2174](https://github.com/rzwitserloot/lombok/pull/2174], [Issue #1805](https://github.com/rzwitserloot/lombok/issues/1805).
|
||||
* FEATURE: If you use `@Builder`'s `@Singular`, a plural form is also generated, which has the effect of adding all elements in the passed collection. If you pass a null reference, this would result in a message-less `NullPointerException`. Now, it results in that exception but with a useful message attached (uses the same config as `@NonNull`), or alternatively via a parameter on `@Singular`, you can choose to ignore such a call (add nothing, return immediately); this can be useful when deserializing (e.g. Jackson JSON) and JPA/Hibernate code. [Issue #2221](https://github.com/rzwitserloot/lombok/issues/2221]. [singular documentation](https://projectlombok.org/features/Builder).
|
||||
* FEATURE: Tired of being unable to use `@javax.annotation.ParametersAreNonnullByDefault` or `@org.eclipse.jdt.annotation.NonNullByDefault` because then the equals method that lombok generates isn't valid? Fret no more; lombok can now add nullity annotations where relevant. Set the flavour of nullity annotation you prefer in your `lombok.config`. Applies to the return value of `toString` and `withX` methods, and the parameter of `equals`, `canEqual`, and the plural form of `@Singular` marked fields for builder classes. [Issue #788](https://github.com/rzwitserloot/lombok/issues/788)
|
||||
* FEATURE: Tired of being unable to use `@javax.annotation.ParametersAreNonnullByDefault` or `@org.eclipse.jdt.annotation.NonNullByDefault` because then the equals method that lombok generates isn't valid? Fret no more; lombok can now add nullity annotations where relevant. Set the flavour of nullity annotation you prefer in your `lombok.config`. Applies to the return value of `toString`, `withX`, chainable `setX`, static constructors, `build`, `builder`, etcetera, and the parameter of `equals`, `canEqual`, and the plural form of `@Singular` marked fields for builder classes. [Issue #788](https://github.com/rzwitserloot/lombok/issues/788)
|
||||
* BUGFIX: `lombok.experimental.Wither` has been deprecated (it has been renamed to `lombok.With`). However, the intent is that lombok still handles the old annotation in case you haven't updated your lombok dep yet. However, only a star import on `lombok.experimental.*` worked; an explicit one would cause lombok to not generate any with method. [Issue #2235](https://github.com/rzwitserloot/lombok/issues/2235)
|
||||
* BUGFIX: Referring to an inner class inside the generics on a class marked with `@SuperBuilder` would cause the error `wrong number of type arguments; required 3` [Issue #2262](https://github.com/rzwitserloot/lombok/issues/2262); fixed by github user [`@Lekanich`](https://github.com/rzwitserloot/lombok/issues/2262) - thank you!
|
||||
* BUGFIX: Some of the code generated by `@Builder` did not include `this.` prefixes when accessing fields. While semantically it didn't matter, if you use the 'add this prefix for field accesses' save action in eclipse, the save action would break. [Issue #2327](https://github.com/rzwitserloot/lombok/issues/2327)
|
||||
|
||||
@@ -650,6 +650,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
|
||||
}
|
||||
|
||||
createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
|
||||
return out;
|
||||
}
|
||||
@@ -796,6 +797,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
|
||||
}
|
||||
out.arguments = generateBuildArgs(cfv, type, builderFields, source);
|
||||
if (staticName == null) createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return out;
|
||||
}
|
||||
@@ -864,6 +866,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
} else if (sefAnn != null) {
|
||||
out.annotations = new Annotation[] {sefAnn};
|
||||
}
|
||||
createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -562,6 +562,7 @@ public class HandleConstructor {
|
||||
constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[0]);
|
||||
constructor.statements = new Statement[] { new ReturnStatement(statement, (int) (p >> 32), (int)p) };
|
||||
|
||||
createRelevantNonNullAnnotation(type, constructor);
|
||||
constructor.traverse(new SetGeneratedByVisitor(source), typeDecl.scope);
|
||||
return constructor;
|
||||
}
|
||||
|
||||
@@ -260,6 +260,8 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
|
||||
method.statements = statements.toArray(new Statement[0]);
|
||||
param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0]));
|
||||
|
||||
if (returnType != null && returnStatement != null) createRelevantNonNullAnnotation(sourceNode, method);
|
||||
|
||||
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -599,6 +599,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
|
||||
if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
|
||||
|
||||
createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
|
||||
return out;
|
||||
}
|
||||
@@ -633,6 +634,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
|
||||
if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
|
||||
|
||||
createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
|
||||
return out;
|
||||
}
|
||||
@@ -850,8 +852,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
allocationStatement.arguments = new Expression[] {new ThisReference(0, 0)};
|
||||
statements.add(new ReturnStatement(allocationStatement, 0, 0));
|
||||
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
|
||||
createRelevantNonNullAnnotation(builderType, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
data.setGeneratedByRecursive(md);
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
|
||||
@@ -176,6 +177,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
|
||||
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
|
||||
}
|
||||
@@ -207,13 +209,13 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
|
||||
|
||||
md.statements = statements.toArray(new Statement[0]);
|
||||
|
||||
|
||||
md.arguments = new Argument[] {param};
|
||||
md.returnType = returnType;
|
||||
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
|
||||
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
data.setGeneratedByRecursive(md);
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
|
||||
@@ -154,6 +155,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
|
||||
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
|
||||
}
|
||||
@@ -189,6 +191,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
|
||||
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
|
||||
md.returnType = returnType;
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
@@ -253,6 +254,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
|
||||
md.selector = setterName.toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
|
||||
}
|
||||
@@ -326,6 +328,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
|
||||
md.selector = setterName.toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
}
|
||||
|
||||
@@ -611,7 +611,9 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
}
|
||||
JCBlock body = maker.Block(0, statements.toList());
|
||||
List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
|
||||
return maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
|
||||
@@ -714,7 +716,9 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
|
||||
List<JCAnnotation> annsOnMethod = cfv.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
|
||||
List<JCVariableDecl> params = generateBuildArgs(cfv, type, builderFields);
|
||||
return maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(buildName), returnType, List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(buildName), returnType, List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
|
||||
if (builderName == null) createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
public static JCMethodDecl generateDefaultProvider(Name methodName, JavacNode fieldNode, List<JCTypeParameter> params) {
|
||||
@@ -757,7 +761,9 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
else if (annUnique != null) annsOnMethod = List.of(annUnique);
|
||||
else if (annSef != null) annsOnMethod = List.of(annSef);
|
||||
else annsOnMethod = List.nil();
|
||||
return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
|
||||
|
||||
@@ -489,6 +489,8 @@ public class HandleConstructor {
|
||||
JCReturn returnStatement = maker.Return(maker.NewClass(null, List.<JCExpression>nil(), constructorType, args.toList(), null));
|
||||
JCBlock body = maker.Block(0, List.<JCStatement>of(returnStatement));
|
||||
|
||||
return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName(name), returnType, typeParams.toList(), params.toList(), List.<JCExpression>nil(), body, null), source, typeNode.getContext());
|
||||
JCMethodDecl methodDef = maker.MethodDef(mods, typeNode.toName(name), returnType, typeParams.toList(), params.toList(), List.<JCExpression>nil(), body, null);
|
||||
createRelevantNonNullAnnotation(typeNode, methodDef);
|
||||
return recursiveSetGeneratedBy(methodDef, source, typeNode.getContext());
|
||||
}
|
||||
}
|
||||
@@ -277,8 +277,10 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
|
||||
annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
|
||||
}
|
||||
|
||||
JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
|
||||
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
|
||||
JCMethodDecl methodDef = treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
|
||||
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue);
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(source, methodDef);
|
||||
JCMethodDecl decl = recursiveSetGeneratedBy(methodDef, source.get(), field.getContext());
|
||||
copyJavadoc(field, decl, CopyJavadoc.SETTER, returnStatement != null);
|
||||
return decl;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), false, List.<JCTypeParameter>nil()), typeParameterNames.toList());
|
||||
|
||||
List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
|
||||
return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -604,7 +606,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), false, List.<JCTypeParameter>nil()), typeParameterNames.toList());
|
||||
|
||||
List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
|
||||
return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
|
||||
createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -808,7 +812,9 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
JCModifiers modifiers = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
|
||||
|
||||
List<JCVariableDecl> params = HandleBuilder.generateBuildArgs(cfv, type, builderFields);
|
||||
return maker.MethodDef(modifiers, type.toName(buildName), cloneSelfType(returnType), List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
|
||||
JCMethodDecl methodDef = maker.MethodDef(modifiers, type.toName(buildName), cloneSelfType(returnType), List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
|
||||
createRelevantNonNullAnnotation(type, methodDef);
|
||||
return methodDef;
|
||||
}
|
||||
|
||||
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
|
||||
|
||||
@@ -288,6 +288,7 @@ public class JavacSingularsRecipes {
|
||||
|
||||
JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, jcVariableDecls, thrown, body, null);
|
||||
recursiveSetGeneratedBy(method, source, builderType.getContext());
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, method);
|
||||
injectMethod(builderType, method);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,31 +18,31 @@ class BuilderSingularNullBehavior1 {
|
||||
BuilderSingularNullBehavior1Builder() {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder name(final String name) {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder name(final String name) {
|
||||
if (this.names == null) this.names = new java.util.ArrayList<String>();
|
||||
this.names.add(name);
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder names(final java.util.@org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder names(final java.util.@org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
|
||||
assert names != null : "names cannot be null";
|
||||
if (this.names == null) this.names = new java.util.ArrayList<String>();
|
||||
this.names.addAll(names);
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder clearNames() {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder clearNames() {
|
||||
if (this.names != null) this.names.clear();
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder location(final String location) {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder location(final String location) {
|
||||
if (this.locations == null) this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.add(location);
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder locations(final java.util.@org.checkerframework.checker.nullness.qual.Nullable Collection<? extends String> locations) {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder locations(final java.util.@org.checkerframework.checker.nullness.qual.Nullable Collection<? extends String> locations) {
|
||||
if (locations != null) {
|
||||
if (this.locations == null) this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.addAll(locations);
|
||||
@@ -50,10 +50,11 @@ class BuilderSingularNullBehavior1 {
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder clearLocations() {
|
||||
public BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder clearLocations() {
|
||||
if (this.locations != null) this.locations.clear();
|
||||
return this;
|
||||
}
|
||||
@org.checkerframework.checker.nullness.qual.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior1 build() {
|
||||
java.util.List<String> names;
|
||||
@@ -87,7 +88,7 @@ class BuilderSingularNullBehavior1 {
|
||||
}
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder builder() {
|
||||
public static BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder builder() {
|
||||
return new BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder();
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,14 @@ class BuilderSingularNullBehavior2 {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
BuilderSingularNullBehavior2Builder() {
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder location(final String location) {
|
||||
if (this.locations == null) this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.add(location);
|
||||
return this;
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder locations(@org.springframework.lang.NonNull final java.util.Collection<? extends String> locations) {
|
||||
java.util.Objects.requireNonNull(locations, "locations cannot be null");
|
||||
@@ -25,11 +27,13 @@ class BuilderSingularNullBehavior2 {
|
||||
this.locations.addAll(locations);
|
||||
return this;
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder clearLocations() {
|
||||
if (this.locations != null) this.locations.clear();
|
||||
return this;
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public BuilderSingularNullBehavior2 build() {
|
||||
java.util.List<String> locations;
|
||||
@@ -52,6 +56,7 @@ class BuilderSingularNullBehavior2 {
|
||||
return "BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder(locations=" + this.locations + ")";
|
||||
}
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder builder() {
|
||||
return new BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder();
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
public class StaticConstructor {
|
||||
String name;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private StaticConstructor(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@org.checkerframework.checker.nullness.qual.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public static StaticConstructor of(final String name) {
|
||||
return new StaticConstructor(name);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@ class WithPlain {
|
||||
this.i = i;
|
||||
this.foo = foo;
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public WithPlain withI(final int i) {
|
||||
return this.i == i ? this : new WithPlain(i, this.foo);
|
||||
}
|
||||
@org.springframework.lang.NonNull
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public WithPlain withFoo(final int foo) {
|
||||
return this.foo == foo ? this : new WithPlain(this.i, foo);
|
||||
|
||||
@@ -8,31 +8,31 @@ import lombok.Singular;
|
||||
@java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1Builder() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder name(final String name) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder name(final String name) {
|
||||
if ((this.names == null))
|
||||
this.names = new java.util.ArrayList<String>();
|
||||
this.names.add(name);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder names(final java.util. @org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder names(final java.util. @org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
|
||||
assert (names != null): "names cannot be null";
|
||||
if ((this.names == null))
|
||||
this.names = new java.util.ArrayList<String>();
|
||||
this.names.addAll(names);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder clearNames() {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder clearNames() {
|
||||
if ((this.names != null))
|
||||
this.names.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder location(final String location) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder location(final String location) {
|
||||
if ((this.locations == null))
|
||||
this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.add(location);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder locations(final java.util. @org.checkerframework.checker.nullness.qual.Nullable Collection<? extends String> locations) {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder locations(final java.util. @org.checkerframework.checker.nullness.qual.Nullable Collection<? extends String> locations) {
|
||||
if ((locations != null))
|
||||
{
|
||||
if ((this.locations == null))
|
||||
@@ -41,12 +41,12 @@ import lombok.Singular;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder clearLocations() {
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder clearLocations() {
|
||||
if ((this.locations != null))
|
||||
this.locations.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1 build() {
|
||||
public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1 build() {
|
||||
java.util.List<String> names;
|
||||
switch (((this.names == null) ? 0 : this.names.size())) {
|
||||
case 0 :
|
||||
@@ -82,7 +82,7 @@ import lombok.Singular;
|
||||
this.names = names;
|
||||
this.locations = locations;
|
||||
}
|
||||
public static @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder builder() {
|
||||
public static @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior1.@org.checkerframework.checker.nullness.qual.NonNull BuilderSingularNullBehavior1Builder builder() {
|
||||
return new BuilderSingularNullBehavior1.BuilderSingularNullBehavior1Builder();
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,25 @@ import lombok.Singular;
|
||||
@java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2Builder() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder location(final String location) {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder location(final String location) {
|
||||
if ((this.locations == null))
|
||||
this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.add(location);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder locations(final @org.springframework.lang.NonNull java.util.Collection<? extends String> locations) {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder locations(final @org.springframework.lang.NonNull java.util.Collection<? extends String> locations) {
|
||||
java.util.Objects.requireNonNull(locations, "locations cannot be null");
|
||||
if ((this.locations == null))
|
||||
this.locations = new java.util.ArrayList<String>();
|
||||
this.locations.addAll(locations);
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder clearLocations() {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder clearLocations() {
|
||||
if ((this.locations != null))
|
||||
this.locations.clear();
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2 build() {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2 build() {
|
||||
java.util.List<String> locations;
|
||||
switch (((this.locations == null) ? 0 : this.locations.size())) {
|
||||
case 0 :
|
||||
@@ -47,7 +47,7 @@ import lombok.Singular;
|
||||
super();
|
||||
this.locations = locations;
|
||||
}
|
||||
public static @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder builder() {
|
||||
public static @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder builder() {
|
||||
return new BuilderSingularNullBehavior2.BuilderSingularNullBehavior2Builder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import lombok.AllArgsConstructor;
|
||||
public @AllArgsConstructor(staticName = "of") class StaticConstructor {
|
||||
String name;
|
||||
private @java.lang.SuppressWarnings("all") StaticConstructor(final String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
public static @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") StaticConstructor of(final String name) {
|
||||
return new StaticConstructor(name);
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ class WithPlain {
|
||||
this.i = i;
|
||||
this.foo = foo;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WithPlain withI(final int i) {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") WithPlain withI(final int i) {
|
||||
return ((this.i == i) ? this : new WithPlain(i, this.foo));
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WithPlain withFoo(final int foo) {
|
||||
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") WithPlain withFoo(final int foo) {
|
||||
return ((this.foo == foo) ? this : new WithPlain(this.i, foo));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//CONF: lombok.addNullAnnotations = checkerframework
|
||||
import lombok.AllArgsConstructor;
|
||||
@AllArgsConstructor(staticName = "of")
|
||||
public class StaticConstructor {
|
||||
String name;
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import lombok.Value;
|
||||
@Value(staticConstructor = "of")
|
||||
public class ValueStaticConstructorOf {
|
||||
String name;
|
||||
Double price;
|
||||
|
||||
String name;
|
||||
Double price;
|
||||
|
||||
private ValueStaticConstructorOf(String name, Double price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
private ValueStaticConstructorOf(String name, Double price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
//CONF: lombok.addNullAnnotations = spring
|
||||
import lombok.With;
|
||||
class WithPlain {
|
||||
@lombok.With int i;
|
||||
|
||||
Reference in new issue
Block a user