mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 12:19:00 +00:00
[fixes #2838] Handle anonymous classes properly
Generated qualified names (e.g. Outer.Inner) now stop at anonymous classes instead of adding an empty part. All handlers that add static fields/methods/types now add error messages instead of generating invalid code.
This commit is contained in:
1 parent
6758714ed5
commit
60f575496b
75 files changed
+1103
-28
No files matched your search
@@ -1042,7 +1042,7 @@ public class EclipseHandlerUtil {
|
||||
res[count] = name;
|
||||
|
||||
n = parent;
|
||||
while (n != null && n.getKind() == Kind.TYPE && n.get() instanceof TypeDeclaration) {
|
||||
while (count > 0) {
|
||||
TypeDeclaration td = (TypeDeclaration) n.get();
|
||||
res[--count] = td.name;
|
||||
n = n.up();
|
||||
@@ -2635,6 +2635,13 @@ public class EclipseHandlerUtil {
|
||||
return isTypeAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | AccRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
|
||||
*/
|
||||
public static boolean isClassEnumOrRecord(EclipseNode typeNode) {
|
||||
return isTypeAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
|
||||
*/
|
||||
@@ -2662,6 +2669,21 @@ public class EclipseHandlerUtil {
|
||||
return (modifiers & flags) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node supports static methods and types (top level or static class)
|
||||
*/
|
||||
public static boolean isStaticAllowed(EclipseNode typeNode) {
|
||||
boolean staticAllowed = true;
|
||||
|
||||
while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
|
||||
if (!staticAllowed) return false;
|
||||
|
||||
staticAllowed = typeNode.isStatic();
|
||||
typeNode = typeNode.up();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static AbstractVariableDeclaration[] getRecordComponents(TypeDeclaration typeDeclaration) {
|
||||
if (typeDeclaration == null || (typeDeclaration.modifiers & AccRecord) == 0) return null;
|
||||
try {
|
||||
|
||||
@@ -293,6 +293,11 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
|
||||
List<EclipseNode> nonFinalNonDefaultedFields = null;
|
||||
|
||||
if (!isStaticAllowed(upToTypeNode(parent))) {
|
||||
annotationNode.addError("@Builder is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent.get() instanceof TypeDeclaration) {
|
||||
if (!isClass(parent) && !isRecord(parent)) {
|
||||
annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
|
||||
|
||||
@@ -538,14 +538,15 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
|
||||
if (addWildcards) genericsCount.add(arraySizeOf(((TypeDeclaration) type.get()).typeParameters));
|
||||
boolean staticContext = (((TypeDeclaration) type.get()).modifiers & ClassFileConstants.AccStatic) != 0;
|
||||
EclipseNode tNode = type.up();
|
||||
if (!staticContext && tNode.getKind() == Kind.TYPE && (((TypeDeclaration) tNode.get()).modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
|
||||
|
||||
while (tNode != null && tNode.getKind() == Kind.TYPE) {
|
||||
TypeDeclaration td = (TypeDeclaration) tNode.get();
|
||||
if (td.name == null || td.name.length == 0) break;
|
||||
list.add(tNode.getName());
|
||||
if (addWildcards) genericsCount.add(staticContext ? 0 : arraySizeOf(((TypeDeclaration) tNode.get()).typeParameters));
|
||||
if (!staticContext) staticContext = (((TypeDeclaration) tNode.get()).modifiers & Modifier.STATIC) != 0;
|
||||
if (!staticContext && tNode.getKind() == Kind.TYPE && (td.modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
|
||||
if (addWildcards) genericsCount.add(staticContext ? 0 : arraySizeOf(td.typeParameters));
|
||||
if (!staticContext) staticContext = (td.modifiers & Modifier.STATIC) != 0;
|
||||
tNode = tNode.up();
|
||||
if (!staticContext && tNode.getKind() == Kind.TYPE && (((TypeDeclaration) tNode.get()).modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
|
||||
}
|
||||
Collections.reverse(list);
|
||||
if (addWildcards) Collections.reverse(genericsCount);
|
||||
|
||||
@@ -60,14 +60,12 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
|
||||
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
|
||||
|
||||
public void generateFieldNameConstantsForType(EclipseNode typeNode, EclipseNode errorNode, AccessLevel level, boolean asEnum, IdentifierName innerTypeName, boolean onlyExplicit, boolean uppercase) {
|
||||
TypeDeclaration typeDecl = null;
|
||||
if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
|
||||
|
||||
int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
|
||||
boolean notAClass = (modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
|
||||
|
||||
if (typeDecl == null || notAClass) {
|
||||
errorNode.addError("@FieldNameConstants is only supported on a class or an enum.");
|
||||
if (!isClassEnumOrRecord(typeNode)) {
|
||||
errorNode.addError("@FieldNameConstants is only supported on a class, an enum or a record.");
|
||||
return;
|
||||
}
|
||||
if (!isStaticAllowed(typeNode)) {
|
||||
errorNode.addError("@FieldNameConstants is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ public class HandleLog {
|
||||
return;
|
||||
}
|
||||
|
||||
if (useStatic && !isStaticAllowed(owner)) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
Object valueGuess = annotation.getValueGuess("topic");
|
||||
Expression loggerTopic = (Expression) annotation.getActualExpression("topic");
|
||||
|
||||
|
||||
@@ -184,6 +184,10 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
annotationNode.addError("@SuperBuilder is only supported on classes.");
|
||||
return;
|
||||
}
|
||||
if (!isStaticAllowed(parent)) {
|
||||
annotationNode.addError("@SuperBuilder is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
job.parentType = parent;
|
||||
TypeDeclaration td = (TypeDeclaration) parent.get();
|
||||
|
||||
@@ -315,7 +315,9 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
|
||||
String typeName = getSingleTypeName(type);
|
||||
EclipseNode upType = type.up();
|
||||
while (upType.getKind() == Kind.TYPE) {
|
||||
typeName = getSingleTypeName(upType) + "." + typeName;
|
||||
String upTypeName = getSingleTypeName(upType);
|
||||
if (upTypeName.isEmpty()) break;
|
||||
typeName = upTypeName + "." + typeName;
|
||||
upType = upType.up();
|
||||
}
|
||||
return typeName;
|
||||
|
||||
@@ -234,6 +234,11 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
|
||||
ArrayList<JavacNode> nonFinalNonDefaultedFields = null;
|
||||
|
||||
if (!isStaticAllowed(upToTypeNode(parent))) {
|
||||
annotationNode.addError("@Builder is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent.get() instanceof JCClassDecl) {
|
||||
if (!isClass(parent) && !isRecord(parent)) {
|
||||
annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
|
||||
|
||||
@@ -385,7 +385,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
|
||||
boolean staticContext = (((JCClassDecl) type.get()).getModifiers().flags & Flags.STATIC) != 0;
|
||||
JavacNode tNode = type.up();
|
||||
|
||||
while (tNode != null && tNode.getKind() == Kind.TYPE) {
|
||||
while (tNode != null && tNode.getKind() == Kind.TYPE && !tNode.getName().isEmpty()) {
|
||||
list.add(tNode.getName());
|
||||
if (addWildcards) genericsCount.add(staticContext ? 0 : ((JCClassDecl) tNode.get()).typarams.size());
|
||||
if (!staticContext) staticContext = (((JCClassDecl) tNode.get()).getModifiers().flags & Flags.STATIC) != 0;
|
||||
|
||||
@@ -57,14 +57,12 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
|
||||
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
|
||||
|
||||
public void generateFieldNameConstantsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean asEnum, IdentifierName innerTypeName, boolean onlyExplicit, boolean uppercase) {
|
||||
JCClassDecl typeDecl = null;
|
||||
if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
|
||||
|
||||
long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
|
||||
boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION)) != 0;
|
||||
|
||||
if (typeDecl == null || notAClass) {
|
||||
errorNode.addError("@FieldNameConstants is only supported on a class or an enum.");
|
||||
if (!isClassEnumOrRecord(typeNode)) {
|
||||
errorNode.addError("@FieldNameConstants is only supported on a class, an enum or a record.");
|
||||
return;
|
||||
}
|
||||
if (!isStaticAllowed(typeNode)) {
|
||||
errorNode.addError("@FieldNameConstants is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,11 @@ public class HandleLog {
|
||||
return;
|
||||
}
|
||||
|
||||
if (useStatic && !isStaticAllowed(typeNode)) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
Object valueGuess = annotation.getValueGuess("topic");
|
||||
JCExpression loggerTopic = (JCExpression) annotation.getActualExpression("topic");
|
||||
|
||||
|
||||
@@ -163,6 +163,10 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
annotationNode.addError("@SuperBuilder is only supported on classes.");
|
||||
return;
|
||||
}
|
||||
if (!isStaticAllowed(parent)) {
|
||||
annotationNode.addError("@SuperBuilder is not supported on non-static nested classes.");
|
||||
return;
|
||||
}
|
||||
|
||||
job.parentType = parent;
|
||||
JCClassDecl td = (JCClassDecl) parent.get();
|
||||
|
||||
@@ -44,7 +44,6 @@ import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
|
||||
import com.sun.tools.javac.tree.JCTree.JCBlock;
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCExpression;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
||||
@@ -252,10 +251,10 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
|
||||
}
|
||||
|
||||
public static String getTypeName(JavacNode typeNode) {
|
||||
String typeName = ((JCClassDecl) typeNode.get()).name.toString();
|
||||
String typeName = typeNode.getName();
|
||||
JavacNode upType = typeNode.up();
|
||||
while (upType.getKind() == Kind.TYPE) {
|
||||
typeName = ((JCClassDecl) upType.get()).name.toString() + "." + typeName;
|
||||
while (upType.getKind() == Kind.TYPE && !upType.getName().isEmpty()) {
|
||||
typeName = upType.getName() + "." + typeName;
|
||||
upType = upType.up();
|
||||
}
|
||||
return typeName;
|
||||
|
||||
@@ -1286,6 +1286,7 @@ public class JavacHandlerUtil {
|
||||
static Type classEnter(JCTree tree, JavacNode parent) {
|
||||
Enter enter = Enter.instance(parent.getContext());
|
||||
Env<AttrContext> classEnv = enter.getEnv((TypeSymbol) parent.getElement());
|
||||
if (classEnv == null) return null;
|
||||
Type type = (Type) Permit.invokeSneaky(classEnter, enter, tree, classEnv);
|
||||
if (type == null) return null;
|
||||
type.complete();
|
||||
@@ -1902,7 +1903,7 @@ public class JavacHandlerUtil {
|
||||
|
||||
public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode parentType, Name typeName, boolean instance, List<JCTypeParameter> params, List<JCAnnotation> annotations) {
|
||||
JCExpression r = null;
|
||||
if (parentType != null && parentType.getKind() == Kind.TYPE) {
|
||||
if (parentType != null && parentType.getKind() == Kind.TYPE && !parentType.getName().isEmpty()) {
|
||||
JCClassDecl td = (JCClassDecl) parentType.get();
|
||||
boolean outerInstance = instance && ((td.mods.flags & Flags.STATIC) == 0);
|
||||
List<JCTypeParameter> outerParams = instance ? td.typarams : List.<JCTypeParameter>nil();
|
||||
@@ -1978,6 +1979,13 @@ public class JavacHandlerUtil {
|
||||
return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | RECORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
|
||||
*/
|
||||
public static boolean isClassEnumOrRecord(JavacNode typeNode) {
|
||||
return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
|
||||
*/
|
||||
@@ -1994,6 +2002,21 @@ public class JavacHandlerUtil {
|
||||
return (typeDeclflags & flags) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the provided node supports static methods and types (top level or static class)
|
||||
*/
|
||||
public static boolean isStaticAllowed(JavacNode typeNode) {
|
||||
boolean staticAllowed = true;
|
||||
|
||||
while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
|
||||
if (!staticAllowed) return false;
|
||||
|
||||
staticAllowed = typeNode.isStatic();
|
||||
typeNode = typeNode.up();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static JavacNode upToTypeNode(JavacNode node) {
|
||||
if (node == null) throw new NullPointerException("node");
|
||||
while ((node != null) && !(node.get() instanceof JCClassDecl)) node = node.up();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
public class AccessorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public String string() {
|
||||
return this.string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code this}.
|
||||
*/
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner string(final String string) {
|
||||
this.string = string;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class BuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import lombok.NonNull;
|
||||
|
||||
public class ConstructorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
@NonNull
|
||||
private String string2;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner(final String string, @NonNull final String string2) {
|
||||
if (string2 == null) {
|
||||
throw new java.lang.NullPointerException("string2 is marked non-null but is null");
|
||||
}
|
||||
this.string = string;
|
||||
this.string2 = string2;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner(@NonNull final String string2) {
|
||||
if (string2 == null) {
|
||||
throw new java.lang.NullPointerException("string2 is marked non-null but is null");
|
||||
}
|
||||
this.string2 = string2;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner() {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
public class DataInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner() {
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Inner)) return false;
|
||||
final Inner other = (Inner) o;
|
||||
if (!other.canEqual((java.lang.Object) this)) return false;
|
||||
final java.lang.Object this$string = this.getString();
|
||||
final java.lang.Object other$string = other.getString();
|
||||
if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
protected boolean canEqual(final java.lang.Object other) {
|
||||
return other instanceof Inner;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.getString();
|
||||
result = result * PRIME + ($string == null ? 43 : $string.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "Inner(string=" + this.getString() + ")";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
public class EqualsAndHashCodeInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Inner)) return false;
|
||||
final Inner other = (Inner) o;
|
||||
if (!other.canEqual((java.lang.Object) this)) return false;
|
||||
final java.lang.Object this$string = this.string;
|
||||
final java.lang.Object other$string = other.string;
|
||||
if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
protected boolean canEqual(final java.lang.Object other) {
|
||||
return other instanceof Inner;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.string;
|
||||
result = result * PRIME + ($string == null ? 43 : $string.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class FieldNameConstantsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class GetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
public class GetterLazyInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
|
||||
|
||||
@java.lang.SuppressWarnings({"all", "unchecked"})
|
||||
public String getString() {
|
||||
java.lang.Object value = this.string.get();
|
||||
if (value == null) {
|
||||
synchronized (this.string) {
|
||||
value = this.string.get();
|
||||
if (value == null) {
|
||||
final String actualValue = "test";
|
||||
value = actualValue == null ? this.string : actualValue;
|
||||
this.string.set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (String) (value == this.string ? null : value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class LoggerSlf4jInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class SetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class SuperBuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class InnerParent {
|
||||
private String string;
|
||||
}
|
||||
|
||||
class InnerChild {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class SynchronizedInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private final java.lang.Object $lock = new java.lang.Object[0];
|
||||
|
||||
public void foo() {
|
||||
synchronized (this.$lock) {
|
||||
String foo = "bar";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
public class ToStringInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "Inner(string=" + this.string + ")";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class UtilityClassInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
public class ValueInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
final class Inner {
|
||||
private final String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof Inner)) return false;
|
||||
final Inner other = (Inner) o;
|
||||
final java.lang.Object this$string = this.getString();
|
||||
final java.lang.Object other$string = other.getString();
|
||||
if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.getString();
|
||||
result = result * PRIME + ($string == null ? 43 : $string.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "Inner(string=" + this.getString() + ")";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class WithByInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private Inner(String string) {
|
||||
}
|
||||
|
||||
private String string;
|
||||
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner withStringBy(final java.util.function.Function<? super String, ? extends String> transformer) {
|
||||
return new Inner(transformer.apply(this.string));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
public class WithInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
|
||||
class Inner {
|
||||
private Inner(String string) {
|
||||
}
|
||||
|
||||
private String string;
|
||||
|
||||
/**
|
||||
* @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
|
||||
*/
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public Inner withString(final String string) {
|
||||
return this.string == string ? this : new Inner(string);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
public class AccessorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Getter @Setter @Accessors(fluent = true) class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") String string() {
|
||||
return this.string;
|
||||
}
|
||||
/**
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public @java.lang.SuppressWarnings("all") Inner string(final String string) {
|
||||
this.string = string;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public AccessorsInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import lombok.Builder;
|
||||
public class BuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Builder class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public BuilderInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
public class ConstructorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@AllArgsConstructor @RequiredArgsConstructor @NoArgsConstructor class Inner {
|
||||
private String string;
|
||||
private @NonNull String string2;
|
||||
public @java.lang.SuppressWarnings("all") Inner(final String string, final @NonNull String string2) {
|
||||
super();
|
||||
if ((string2 == null))
|
||||
{
|
||||
throw new java.lang.NullPointerException("string2 is marked non-null but is null");
|
||||
}
|
||||
this.string = string;
|
||||
this.string2 = string2;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") Inner(final @NonNull String string2) {
|
||||
super();
|
||||
if ((string2 == null))
|
||||
{
|
||||
throw new java.lang.NullPointerException("string2 is marked non-null but is null");
|
||||
}
|
||||
this.string2 = string2;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public ConstructorsInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import lombok.Data;
|
||||
public class DataInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Data class Inner {
|
||||
private String string;
|
||||
public @java.lang.SuppressWarnings("all") String getString() {
|
||||
return this.string;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
|
||||
if ((o == this))
|
||||
return true;
|
||||
if ((! (o instanceof Inner)))
|
||||
return false;
|
||||
final Inner other = (Inner) o;
|
||||
if ((! other.canEqual((java.lang.Object) this)))
|
||||
return false;
|
||||
final java.lang.Object this$string = this.getString();
|
||||
final java.lang.Object other$string = other.getString();
|
||||
if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
|
||||
return (other instanceof Inner);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.getString();
|
||||
result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
|
||||
return result;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (("Inner(string=" + this.getString()) + ")");
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public DataInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import lombok.EqualsAndHashCode;
|
||||
public class EqualsAndHashCodeInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@EqualsAndHashCode class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
|
||||
if ((o == this))
|
||||
return true;
|
||||
if ((! (o instanceof Inner)))
|
||||
return false;
|
||||
final Inner other = (Inner) o;
|
||||
if ((! other.canEqual((java.lang.Object) this)))
|
||||
return false;
|
||||
final java.lang.Object this$string = this.string;
|
||||
final java.lang.Object other$string = other.string;
|
||||
if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
|
||||
return (other instanceof Inner);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.string;
|
||||
result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public EqualsAndHashCodeInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
public class FieldNameConstantsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@FieldNameConstants class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public FieldNameConstantsInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import lombok.Getter;
|
||||
public class GetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Getter class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") String getString() {
|
||||
return this.string;
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public GetterInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import lombok.Getter;
|
||||
public class GetterLazyInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
class Inner {
|
||||
private final @Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings({"all", "unchecked"}) String getString() {
|
||||
java.lang.Object value = this.string.get();
|
||||
if ((value == null))
|
||||
{
|
||||
synchronized (this.string)
|
||||
{
|
||||
value = this.string.get();
|
||||
if ((value == null))
|
||||
{
|
||||
final String actualValue = "test";
|
||||
value = ((actualValue == null) ? this.string : actualValue);
|
||||
this.string.set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (String) ((value == this.string) ? null : value);
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public GetterLazyInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
public class LoggerSlf4jInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Slf4j class Inner {
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public LoggerSlf4jInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import lombok.Setter;
|
||||
public class SetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Setter class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public SetterInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import lombok.experimental.SuperBuilder;
|
||||
public class SuperBuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@SuperBuilder class InnerParent {
|
||||
private String string;
|
||||
InnerParent() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@SuperBuilder class InnerChild {
|
||||
private String string;
|
||||
InnerChild() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public SuperBuilderInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import lombok.Synchronized;
|
||||
public class SynchronizedInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
class Inner {
|
||||
private final java.lang.Object $lock = new java.lang.Object[0];
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @Synchronized void foo() {
|
||||
synchronized (this.$lock)
|
||||
{
|
||||
String foo = "bar";
|
||||
}
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public SynchronizedInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import lombok.ToString;
|
||||
public class ToStringInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@ToString class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (("Inner(string=" + this.string) + ")");
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public ToStringInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import lombok.experimental.UtilityClass;
|
||||
public class UtilityClassInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@UtilityClass class Inner {
|
||||
private String string;
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public UtilityClassInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import lombok.Value;
|
||||
public class ValueInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
final @Value class Inner {
|
||||
private final String string;
|
||||
public @java.lang.SuppressWarnings("all") String getString() {
|
||||
return this.string;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
|
||||
if ((o == this))
|
||||
return true;
|
||||
if ((! (o instanceof Inner)))
|
||||
return false;
|
||||
final Inner other = (Inner) o;
|
||||
final java.lang.Object this$string = this.getString();
|
||||
final java.lang.Object other$string = other.getString();
|
||||
if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
final java.lang.Object $string = this.getString();
|
||||
result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
|
||||
return result;
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
|
||||
return (("Inner(string=" + this.getString()) + ")");
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") Inner(final String string) {
|
||||
super();
|
||||
this.string = string;
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public ValueInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import lombok.experimental.WithBy;
|
||||
public class WithByInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@WithBy class Inner {
|
||||
private String string;
|
||||
private Inner(String string) {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") Inner withStringBy(final java.util.function.Function<? super String, ? extends String> transformer) {
|
||||
return new Inner(transformer.apply(this.string));
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public WithByInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import lombok.With;
|
||||
public class WithInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@With class Inner {
|
||||
private String string;
|
||||
private Inner(String string) {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
|
||||
*/
|
||||
public @java.lang.SuppressWarnings("all") Inner withString(final String string) {
|
||||
return ((this.string == string) ? this : new Inner(string));
|
||||
}
|
||||
}
|
||||
x() {
|
||||
super();
|
||||
}
|
||||
};
|
||||
public WithInAnonymousClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
public class AccessorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(fluent = true)
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Builder;
|
||||
|
||||
public class BuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Builder
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public class ConstructorsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@NoArgsConstructor
|
||||
class Inner {
|
||||
private String string;
|
||||
@NonNull
|
||||
private String string2;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Data;
|
||||
|
||||
public class DataInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Data
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
public class EqualsAndHashCodeInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@EqualsAndHashCode
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
public class FieldNameConstantsInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@FieldNameConstants
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Getter;
|
||||
|
||||
public class GetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Getter
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Getter;
|
||||
|
||||
public class GetterLazyInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
class Inner {
|
||||
@Getter(lazy = true)
|
||||
private final String string = "test";
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
public class LoggerSlf4jInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Slf4j
|
||||
class Inner {
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Setter;
|
||||
|
||||
public class SetterInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Setter
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
public class SuperBuilderInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@SuperBuilder
|
||||
class InnerParent {
|
||||
private String string;
|
||||
}
|
||||
|
||||
@SuperBuilder
|
||||
class InnerChild {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class SynchronizedInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
class Inner {
|
||||
@Synchronized
|
||||
public void foo() {
|
||||
String foo = "bar";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.ToString;
|
||||
|
||||
public class ToStringInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@ToString
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
public class UtilityClassInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@UtilityClass
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.Value;
|
||||
|
||||
public class ValueInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@Value
|
||||
class Inner {
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import lombok.experimental.WithBy;
|
||||
|
||||
public class WithByInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@WithBy
|
||||
class Inner {
|
||||
private Inner(String string) { }
|
||||
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import lombok.With;
|
||||
|
||||
public class WithInAnonymousClass {
|
||||
Object annonymous = new Object() {
|
||||
@With
|
||||
class Inner {
|
||||
private Inner(String string) { }
|
||||
|
||||
private String string;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
5 @Builder is not supported on non-static nested classes.
|
||||
+1
@@ -0,0 +1 @@
|
||||
5 @FieldNameConstants is not supported on non-static nested classes.
|
||||
@@ -0,0 +1 @@
|
||||
5 @Slf4j is not supported on non-static nested classes.
|
||||
@@ -0,0 +1,2 @@
|
||||
5 @SuperBuilder is not supported on non-static nested classes.
|
||||
10 @SuperBuilder is not supported on non-static nested classes.
|
||||
@@ -0,0 +1 @@
|
||||
5 @UtilityClass automatically makes the class static, however, this class cannot be made static.
|
||||
@@ -0,0 +1 @@
|
||||
5 @Builder is not supported on non-static nested classes.
|
||||
@@ -0,0 +1 @@
|
||||
5 @FieldNameConstants is not supported on non-static nested classes.
|
||||
@@ -0,0 +1 @@
|
||||
5 @Slf4j is not supported on non-static nested classes.
|
||||
@@ -0,0 +1,2 @@
|
||||
5 @SuperBuilder is not supported on non-static nested classes.
|
||||
10 @SuperBuilder is not supported on non-static nested classes.
|
||||
@@ -0,0 +1 @@
|
||||
5 @UtilityClass automatically makes the class static, however, this class cannot be made static.
|
||||
Reference in new issue
Block a user