You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/10/02 15:32:09 UTC

[groovy] branch master updated: added final to parameters and other minor fix-ups

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 1374fc1  added final to parameters and other minor fix-ups
1374fc1 is described below

commit 1374fc1fd4333e70cc5849b599391db53939207d
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Oct 2 10:25:41 2020 -0500

    added final to parameters and other minor fix-ups
---
 .../transform/options/DefaultPropertyHandler.java  | 20 +++--
 .../options/ImmutablePropertyHandler.java          | 51 ++++++------
 .../options/LegacyHashMapPropertyHandler.java      |  8 +-
 .../groovy/transform/options/PropertyHandler.java  | 17 ++--
 .../java/groovy/transform/options/Visibility.java  |  2 +-
 .../groovy/ast/tools/AnnotatedNodeUtils.java       | 11 ++-
 .../apache/groovy/ast/tools/ClassNodeUtils.java    | 59 +++++++-------
 .../groovy/ast/tools/ConstructorNodeUtils.java     |  6 +-
 .../apache/groovy/ast/tools/ExpressionUtils.java   | 12 ++-
 .../groovy/ast/tools/ImmutablePropertyUtils.java   | 54 ++++++-------
 .../apache/groovy/ast/tools/MethodNodeUtils.java   |  3 +-
 .../apache/groovy/ast/tools/VisibilityUtils.java   |  9 +--
 .../transform/ImmutableASTTransformation.java      | 90 ++++++++++------------
 .../codehaus/groovy/util/ListHashMapTest.groovy    | 40 ++++------
 14 files changed, 181 insertions(+), 201 deletions(-)

diff --git a/src/main/java/groovy/transform/options/DefaultPropertyHandler.java b/src/main/java/groovy/transform/options/DefaultPropertyHandler.java
index 7d5201b..2cded2f 100644
--- a/src/main/java/groovy/transform/options/DefaultPropertyHandler.java
+++ b/src/main/java/groovy/transform/options/DefaultPropertyHandler.java
@@ -54,14 +54,14 @@ public class DefaultPropertyHandler extends PropertyHandler {
     private static final ClassNode POJO_TYPE = make(POJO.class);
 
     @Override
-    public boolean validateAttributes(AbstractASTTransformation xform, AnnotationNode anno) {
+    public boolean validateAttributes(final AbstractASTTransformation xform, final AnnotationNode anno) {
         boolean success = true;
-        //success |= isValidAttribute(xform, anno, "");
+      //success |= isValidAttribute(xform, anno, "");
         return success;
     }
 
     @Override
-    public boolean validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props) {
+    public boolean validateProperties(final AbstractASTTransformation xform, final BlockStatement body, final ClassNode cNode, final List<PropertyNode> props) {
         if (xform instanceof MapConstructorASTTransformation) {
             VariableExpression namedArgs = varX("args");
             body.addStatement(ifS(equalsNullX(namedArgs), assignS(namedArgs, new MapExpression())));
@@ -72,10 +72,10 @@ public class DefaultPropertyHandler extends PropertyHandler {
     }
 
     @Override
-    public Statement createPropInit(AbstractASTTransformation xform, AnnotationNode anno, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap) {
+    public Statement createPropInit(final AbstractASTTransformation xform, final AnnotationNode anno, final ClassNode cNode, final PropertyNode pNode, final Parameter namedArgsMap) {
         String name = pNode.getName();
         FieldNode fNode = pNode.getField();
-        boolean useSetters = xform.memberHasValue(anno, "useSetters", true);
+        boolean useSetters = xform.memberHasValue(anno, "useSetters", Boolean.TRUE);
         boolean hasSetter = cNode.getProperty(name) != null && !fNode.isFinal();
         if (namedArgsMap != null) {
             return assignFieldS(useSetters, namedArgsMap, name);
@@ -89,22 +89,20 @@ public class DefaultPropertyHandler extends PropertyHandler {
         }
     }
 
-    private static Statement assignToFieldS(String name, Expression var) {
+    private static Statement assignToFieldS(final String name, final Expression var) {
         return assignS(propX(varX("this"), name), var);
     }
 
-    private static Statement setViaSetterS(String name, Expression var) {
+    private static Statement setViaSetterS(final String name, final Expression var) {
         return stmt(callThisX(getSetterName(name), var));
     }
 
-    private static Statement assignFieldS(boolean useSetters, Parameter map, String name) {
+    private static Statement assignFieldS(final boolean useSetters, final Parameter map, final String name) {
         ArgumentListExpression nameArg = args(constX(name));
         MethodCallExpression var = callX(varX(map), "get", nameArg);
         var.setImplicitThis(false);
         MethodCallExpression containsKey = callX(varX(map), "containsKey", nameArg);
         containsKey.setImplicitThis(false);
-        return ifS(containsKey, useSetters ?
-                setViaSetterS(name, var) :
-                assignToFieldS(name, var));
+        return ifS(containsKey, useSetters ? setViaSetterS(name, var) : assignToFieldS(name, var));
     }
 }
diff --git a/src/main/java/groovy/transform/options/ImmutablePropertyHandler.java b/src/main/java/groovy/transform/options/ImmutablePropertyHandler.java
index 9253c28..b47beef 100644
--- a/src/main/java/groovy/transform/options/ImmutablePropertyHandler.java
+++ b/src/main/java/groovy/transform/options/ImmutablePropertyHandler.java
@@ -94,7 +94,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
     private static final ClassNode POJO_TYPE = make(POJO.class);
 
     @Override
-    public Statement createPropGetter(PropertyNode pNode) {
+    public Statement createPropGetter(final PropertyNode pNode) {
         FieldNode fNode = pNode.getField();
         BlockStatement body = new BlockStatement();
         final ClassNode fieldType = fNode.getType();
@@ -111,17 +111,17 @@ public class ImmutablePropertyHandler extends PropertyHandler {
     }
 
     @Override
-    public Statement createPropSetter(PropertyNode pNode) {
+    public Statement createPropSetter(final PropertyNode pNode) {
         return null;
     }
 
     @Override
-    public boolean validateAttributes(AbstractASTTransformation xform, AnnotationNode anno) {
+    public boolean validateAttributes(final AbstractASTTransformation xform, final AnnotationNode anno) {
         return isValidAttribute(xform, anno, "useSuper");
     }
 
     @Override
-    public boolean validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props) {
+    public boolean validateProperties(final AbstractASTTransformation xform, final BlockStatement body, final ClassNode cNode, final List<PropertyNode> props) {
         if (xform instanceof MapConstructorASTTransformation) {
             VariableExpression namedArgs = varX("args");
             body.addStatement(ifS(equalsNullX(namedArgs), assignS(namedArgs, new MapExpression())));
@@ -132,7 +132,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
     }
 
     @Override
-    public Statement createPropInit(AbstractASTTransformation xform, AnnotationNode anno, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap) {
+    public Statement createPropInit(final AbstractASTTransformation xform, final AnnotationNode anno, final ClassNode cNode, final PropertyNode pNode, final Parameter namedArgsMap) {
         FieldNode fNode = pNode.getField();
         if (fNode.isFinal() && fNode.isStatic()) return null;
         if (fNode.isFinal() && fNode.getInitialExpression() != null) {
@@ -141,24 +141,24 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return createConstructorStatement(xform, cNode, pNode, namedArgsMap);
     }
 
-    private static Statement createGetterBodyDefault(FieldNode fNode) {
+    private static Statement createGetterBodyDefault(final FieldNode fNode) {
         final Expression fieldExpr = varX(fNode);
         return stmt(fieldExpr);
     }
 
-    private Statement createGetterBodyArrayOrCloneable(FieldNode fNode) {
+    private Statement createGetterBodyArrayOrCloneable(final FieldNode fNode) {
         final Expression fieldExpr = varX(fNode);
         final Expression expression = cloneArrayOrCloneableExpr(fieldExpr, fNode.getType());
         return safeExpression(fieldExpr, expression);
     }
 
-    private Statement createGetterBodyDate(FieldNode fNode) {
+    private Statement createGetterBodyDate(final FieldNode fNode) {
         final Expression fieldExpr = varX(fNode);
         final Expression expression = cloneDateExpr(fieldExpr);
         return safeExpression(fieldExpr, expression);
     }
 
-    protected Expression cloneCollectionExpr(Expression fieldExpr, ClassNode type) {
+    protected Expression cloneCollectionExpr(final Expression fieldExpr, final ClassNode type) {
         return castX(type, createIfInstanceOfAsImmutableS(fieldExpr, SORTEDSET_CLASSNODE,
                 createIfInstanceOfAsImmutableS(fieldExpr, SORTEDMAP_CLASSNODE,
                         createIfInstanceOfAsImmutableS(fieldExpr, SET_CLASSNODE,
@@ -171,7 +171,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         ));
     }
 
-    private Expression createIfInstanceOfAsImmutableS(Expression expr, ClassNode type, Expression elseStatement) {
+    private Expression createIfInstanceOfAsImmutableS(final Expression expr, final ClassNode type, final Expression elseStatement) {
         return ternaryX(isInstanceOfX(expr, type), createAsImmutableX(expr, type), elseStatement);
     }
 
@@ -179,7 +179,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return callX(DGM_TYPE, "asImmutable", castX(type, expr));
     }
 
-    protected Statement createConstructorStatement(AbstractASTTransformation xform, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap) {
+    protected Statement createConstructorStatement(final AbstractASTTransformation xform, final ClassNode cNode, final PropertyNode pNode, final Parameter namedArgsMap) {
         final List<String> knownImmutableClasses = ImmutablePropertyUtils.getKnownImmutableClasses(xform, cNode);
         final List<String> knownImmutables = ImmutablePropertyUtils.getKnownImmutables(xform, cNode);
         FieldNode fNode = pNode.getField();
@@ -203,7 +203,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return statement;
     }
 
-    private static Statement createConstructorStatementDefault(FieldNode fNode, Parameter namedArgsMap, boolean shouldNullCheck) {
+    private static Statement createConstructorStatementDefault(final FieldNode fNode, final Parameter namedArgsMap, final boolean shouldNullCheck) {
         final ClassNode fType = fNode.getType();
         final Expression fieldExpr = propX(varX("this"), fNode.getName());
         Expression param = getParam(fNode, namedArgsMap != null);
@@ -225,7 +225,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return assignFieldWithDefault(namedArgsMap, fNode, assignStmt, assignInit);
     }
 
-    private static Statement assignFieldWithDefault(Parameter map, FieldNode fNode, Statement assignStmt, Statement assignInit) {
+    private static Statement assignFieldWithDefault(final Parameter map, final FieldNode fNode, final Statement assignStmt, final Statement assignInit) {
         if (map == null) {
             return assignStmt;
         }
@@ -238,7 +238,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return ifElseS(containsKey, assignStmt, assignInit);
     }
 
-    private static Statement createConstructorStatementGuarded(FieldNode fNode, Parameter namedArgsMap, List<String> knownImmutables, List<String> knownImmutableClasses, boolean shouldNullCheck) {
+    private static Statement createConstructorStatementGuarded(final FieldNode fNode, final Parameter namedArgsMap, final List<String> knownImmutables, final List<String> knownImmutableClasses, final boolean shouldNullCheck) {
         final Expression fieldExpr = propX(varX("this"), fNode.getName());
         Expression param = getParam(fNode, namedArgsMap != null);
         Statement assignStmt = assignS(fieldExpr, createCheckImmutable(fNode, param, knownImmutables, knownImmutableClasses));
@@ -257,12 +257,12 @@ public class ImmutablePropertyHandler extends PropertyHandler {
     }
 
     // check at runtime since classes might not be resolved
-    private static Expression createCheckImmutable(FieldNode fNode, Expression value, List<String> knownImmutables, List<String> knownImmutableClasses) {
+    private static Expression createCheckImmutable(final FieldNode fNode, final Expression value, final List<String> knownImmutables, final List<String> knownImmutableClasses) {
         Expression args = args(callThisX("getClass"), constX(fNode.getName()), value, list2args(knownImmutables), classList2args(knownImmutableClasses));
         return callX(SELF_TYPE, "checkImmutable", args);
     }
 
-    private Statement createConstructorStatementCollection(FieldNode fNode, Parameter namedArgsMap, boolean shouldNullCheck) {
+    private Statement createConstructorStatementCollection(final FieldNode fNode, final Parameter namedArgsMap, final boolean shouldNullCheck) {
         final Expression fieldExpr = propX(varX("this"), fNode.getName());
         ClassNode fieldType = fieldExpr.getType();
         Expression param = getParam(fNode, namedArgsMap != null);
@@ -284,7 +284,7 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return assignFieldWithDefault(namedArgsMap, fNode, assignStmt, assignInit);
     }
 
-    private static Statement createConstructorStatementArrayOrCloneable(FieldNode fNode, Parameter namedArgsMap, boolean shouldNullCheck) {
+    private static Statement createConstructorStatementArrayOrCloneable(final FieldNode fNode, final Parameter namedArgsMap, final boolean shouldNullCheck) {
         final Expression fieldExpr = propX(varX("this"), fNode.getName());
         final ClassNode fieldType = fNode.getType();
         final Expression param = getParam(fNode, namedArgsMap != null);
@@ -303,11 +303,11 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return assignFieldWithDefault(namedArgsMap, fNode, assignStmt, assignInit);
     }
 
-    private static Expression getParam(FieldNode fNode, boolean namedArgs) {
+    private static Expression getParam(final FieldNode fNode, final boolean namedArgs) {
         return namedArgs ? findArg(fNode.getName()) : varX(fNode.getName(), fNode.getType());
     }
 
-    private static Statement createConstructorStatementDate(FieldNode fNode, Parameter namedArgsMap, boolean shouldNullCheck) {
+    private static Statement createConstructorStatementDate(final FieldNode fNode, final Parameter namedArgsMap, final boolean shouldNullCheck) {
         final Expression fieldExpr = propX(varX("this"), fNode.getName());
         final Expression param = getParam(fNode, namedArgsMap != null);
         Statement assignStmt = assignS(fieldExpr, cloneDateExpr(param));
@@ -325,17 +325,18 @@ public class ImmutablePropertyHandler extends PropertyHandler {
         return assignFieldWithDefault(namedArgsMap, fNode, assignStmt, assignInit);
     }
 
-    private static boolean isKnownImmutable(String fieldName, List<String> knownImmutables) {
+    private static boolean isKnownImmutable(final String fieldName, final List<String> knownImmutables) {
         return knownImmutables.contains(fieldName);
     }
 
-    protected Statement checkFinalArgNotOverridden(ClassNode cNode, FieldNode fNode) {
-        final String name = fNode.getName();
+    protected Statement checkFinalArgNotOverridden(final ClassNode cNode, final FieldNode fNode) {
+        String name = fNode.getName();
         Expression value = findArg(name);
         return ifS(
                 notX(equalsNullX(value)),
-                throwS(ctorX(READONLYEXCEPTION_TYPE,
-                        args(constX(name), constX(cNode.getName()))
-                )));
+                throwS(
+                        ctorX(READONLYEXCEPTION_TYPE, args(constX(name), constX(cNode.getName())))
+                )
+        );
     }
 }
diff --git a/src/main/java/groovy/transform/options/LegacyHashMapPropertyHandler.java b/src/main/java/groovy/transform/options/LegacyHashMapPropertyHandler.java
index 64f3ebf..d0c8409 100644
--- a/src/main/java/groovy/transform/options/LegacyHashMapPropertyHandler.java
+++ b/src/main/java/groovy/transform/options/LegacyHashMapPropertyHandler.java
@@ -60,7 +60,7 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.varX;
 public class LegacyHashMapPropertyHandler extends ImmutablePropertyHandler {
     private static final ClassNode HMAP_TYPE = makeWithoutCaching(HashMap.class, false);
 
-    private Statement createLegacyConstructorStatementMapSpecial(FieldNode fNode) {
+    private Statement createLegacyConstructorStatementMapSpecial(final FieldNode fNode) {
         final Expression fieldExpr = varX(fNode);
         final ClassNode fieldType = fieldExpr.getType();
         final Expression initExpr = fNode.getInitialValueExpression();
@@ -87,12 +87,12 @@ public class LegacyHashMapPropertyHandler extends ImmutablePropertyHandler {
     }
 
     @Override
-    public boolean validateAttributes(AbstractASTTransformation xform, AnnotationNode anno) {
+    public boolean validateAttributes(final AbstractASTTransformation xform, final AnnotationNode anno) {
         return !(xform instanceof TupleConstructorASTTransformation) && super.validateAttributes(xform, anno);
     }
 
     @Override
-    public boolean validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props) {
+    public boolean validateProperties(final AbstractASTTransformation xform, final BlockStatement body, final ClassNode cNode, final List<PropertyNode> props) {
         if (!(props.size() == 1 && props.get(0).getType().equals(HMAP_TYPE))) {
             xform.addError("Error during " + xform.getAnnotationName() + " processing. Property handler " + getClass().getName() + " only accepts a single HashMap property", props.size() == 1 ? props.get(0) : cNode);
             return false;
@@ -101,7 +101,7 @@ public class LegacyHashMapPropertyHandler extends ImmutablePropertyHandler {
     }
 
     @Override
-    public Statement createPropInit(AbstractASTTransformation xform, AnnotationNode anno, ClassNode cNode, PropertyNode pNode, Parameter namedArgsMap) {
+    public Statement createPropInit(final AbstractASTTransformation xform, final AnnotationNode anno, final ClassNode cNode, final PropertyNode pNode, final Parameter namedArgsMap) {
         FieldNode fNode = pNode.getField();
         if (fNode.isFinal() && fNode.isStatic()) return null;
         if (fNode.isFinal() && fNode.getInitialExpression() != null) {
diff --git a/src/main/java/groovy/transform/options/PropertyHandler.java b/src/main/java/groovy/transform/options/PropertyHandler.java
index 8469a4d..f155a3a 100644
--- a/src/main/java/groovy/transform/options/PropertyHandler.java
+++ b/src/main/java/groovy/transform/options/PropertyHandler.java
@@ -44,9 +44,10 @@ import static org.codehaus.groovy.ast.ClassHelper.makeWithoutCaching;
 public abstract class PropertyHandler {
     private static final Class<? extends Annotation> PROPERTY_OPTIONS_CLASS = PropertyOptions.class;
     public static final ClassNode PROPERTY_OPTIONS_TYPE = makeWithoutCaching(PROPERTY_OPTIONS_CLASS, false);
+
     public abstract boolean validateAttributes(AbstractASTTransformation xform, AnnotationNode anno);
 
-    public boolean validateProperties(AbstractASTTransformation xform, BlockStatement body, ClassNode cNode, List<PropertyNode> props) {
+    public boolean validateProperties(final AbstractASTTransformation xform, final BlockStatement body, final ClassNode cNode, final List<PropertyNode> props) {
         return true;
     }
 
@@ -66,7 +67,7 @@ public abstract class PropertyHandler {
      *
      *  @param pNode the property node
      */
-    public Statement createPropGetter(PropertyNode pNode) {
+    public Statement createPropGetter(final PropertyNode pNode) {
         return pNode.getGetterBlock();
     }
 
@@ -75,11 +76,11 @@ public abstract class PropertyHandler {
      *
      *  @param pNode the property node
      */
-    public Statement createPropSetter(PropertyNode pNode) {
+    public Statement createPropSetter(final PropertyNode pNode) {
         return pNode.getSetterBlock();
     }
 
-    protected boolean isValidAttribute(AbstractASTTransformation xform, AnnotationNode anno, String memberName) {
+    protected boolean isValidAttribute(final AbstractASTTransformation xform, final AnnotationNode anno, final String memberName) {
         if (xform.getMemberValue(anno, memberName) != null) {
             xform.addError("Error during " + xform.getAnnotationName() + " processing: Annotation attribute '" + memberName +
                     "' not supported for property handler " + getClass().getSimpleName(), anno);
@@ -88,13 +89,12 @@ public abstract class PropertyHandler {
         return true;
     }
 
-    public static PropertyHandler createPropertyHandler(AbstractASTTransformation xform, GroovyClassLoader loader, ClassNode cNode) {
+    public static PropertyHandler createPropertyHandler(final AbstractASTTransformation xform, final GroovyClassLoader loader, final ClassNode cNode) {
         List<AnnotationNode> annotations = cNode.getAnnotations(PROPERTY_OPTIONS_TYPE);
         AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
-        if (anno == null) return new groovy.transform.options.DefaultPropertyHandler();
-
-        ClassNode handlerClass = xform.getMemberClassValue(anno, "propertyHandler", ClassHelper.make(groovy.transform.options.DefaultPropertyHandler.class));
+        if (anno == null) return new DefaultPropertyHandler();
 
+        ClassNode handlerClass = xform.getMemberClassValue(anno, "propertyHandler", ClassHelper.make(DefaultPropertyHandler.class));
         if (handlerClass == null) {
             xform.addError("Couldn't determine propertyHandler class", anno);
             return null;
@@ -107,7 +107,6 @@ public abstract class PropertyHandler {
                 xform.addError("The propertyHandler class '" + handlerClass.getName() + "' on " + xform.getAnnotationName() + " is not a propertyHandler", anno);
                 return null;
             }
-
             return (PropertyHandler) instance;
         } catch (Exception e) {
             xform.addError("Can't load propertyHandler '" + className + "' " + e, anno);
diff --git a/src/main/java/groovy/transform/options/Visibility.java b/src/main/java/groovy/transform/options/Visibility.java
index 667707a..d14db17 100644
--- a/src/main/java/groovy/transform/options/Visibility.java
+++ b/src/main/java/groovy/transform/options/Visibility.java
@@ -34,7 +34,7 @@ public enum Visibility {
 
     private final int modifier;
 
-    Visibility(int modifier) {
+    Visibility(final int modifier) {
         this.modifier = modifier;
     }
 
diff --git a/src/main/java/org/apache/groovy/ast/tools/AnnotatedNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/AnnotatedNodeUtils.java
index 6b370eb..04e3d36 100644
--- a/src/main/java/org/apache/groovy/ast/tools/AnnotatedNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/AnnotatedNodeUtils.java
@@ -32,14 +32,13 @@ import java.util.List;
 public class AnnotatedNodeUtils {
     private static final ClassNode GENERATED_TYPE = ClassHelper.make(Generated.class);
 
-    private AnnotatedNodeUtils() {
-    }
+    private AnnotatedNodeUtils() { }
 
-    public static <T extends AnnotatedNode> T markAsGenerated(ClassNode containingClass, T nodeToMark) {
+    public static <T extends AnnotatedNode> T markAsGenerated(final ClassNode containingClass, final T nodeToMark) {
         return markAsGenerated(containingClass, nodeToMark, false);
     }
 
-    public static <T extends AnnotatedNode> T markAsGenerated(ClassNode containingClass, T nodeToMark, boolean skipChecks) {
+    public static <T extends AnnotatedNode> T markAsGenerated(final ClassNode containingClass, final T nodeToMark, final boolean skipChecks) {
         boolean shouldAnnotate = skipChecks || (containingClass.getModule() != null && containingClass.getModule().getContext() != null);
         if (shouldAnnotate && !isGenerated(nodeToMark)) {
             nodeToMark.addAnnotation(new AnnotationNode(GENERATED_TYPE));
@@ -47,12 +46,12 @@ public class AnnotatedNodeUtils {
         return nodeToMark;
     }
 
-    public static boolean hasAnnotation(AnnotatedNode node, ClassNode annotation) {
+    public static boolean hasAnnotation(final AnnotatedNode node, final ClassNode annotation) {
         List<?> annots = node.getAnnotations(annotation);
         return (annots != null && !annots.isEmpty());
     }
 
-    public static boolean isGenerated(AnnotatedNode node) {
+    public static boolean isGenerated(final AnnotatedNode node) {
         List<?> annots = node.getAnnotations(GENERATED_TYPE);
         return (annots != null && !annots.isEmpty());
     }
diff --git a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
index 65fc823..a18b23f 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
@@ -52,6 +52,8 @@ import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
  */
 public class ClassNodeUtils {
 
+    private ClassNodeUtils() { }
+
     /**
      * Formats a type name into a human readable version. For arrays, appends "[]" to the formatted
      * type name of the component. For unit class nodes, uses the class node name.
@@ -59,7 +61,7 @@ public class ClassNodeUtils {
      * @param cNode the type to format
      * @return a human readable version of the type name (java.lang.String[] for example)
      */
-    public static String formatTypeName(ClassNode cNode) {
+    public static String formatTypeName(final ClassNode cNode) {
         if (cNode.isArray()) {
             ClassNode it = cNode;
             int dim = 0;
@@ -82,12 +84,12 @@ public class ClassNodeUtils {
      *
      * @see ClassNode#addMethod(String, int, ClassNode, Parameter[], ClassNode[], Statement)
      */
-    public static MethodNode addGeneratedMethod(ClassNode cNode, String name,
-                                int modifiers,
-                                ClassNode returnType,
-                                Parameter[] parameters,
-                                ClassNode[] exceptions,
-                                Statement code) {
+    public static MethodNode addGeneratedMethod(final ClassNode cNode, final String name,
+                                final int modifiers,
+                                final ClassNode returnType,
+                                final Parameter[] parameters,
+                                final ClassNode[] exceptions,
+                                final Statement code) {
         MethodNode existing = cNode.getDeclaredMethod(name, parameters);
         if (existing != null) return existing;
         MethodNode result = new MethodNode(name, modifiers, returnType, parameters, exceptions, code);
@@ -100,7 +102,7 @@ public class ClassNodeUtils {
      *
      * @see ClassNode#addMethod(MethodNode)
      */
-    public static void addGeneratedMethod(ClassNode cNode, MethodNode mNode) {
+    public static void addGeneratedMethod(final ClassNode cNode, final MethodNode mNode) {
         cNode.addMethod(mNode);
         markAsGenerated(cNode, mNode);
     }
@@ -110,7 +112,7 @@ public class ClassNodeUtils {
      *
      * @see org.codehaus.groovy.ast.ModuleNode#addClass(ClassNode)
      */
-    public static void addGeneratedInnerClass(ClassNode cNode, ClassNode inner) {
+    public static void addGeneratedInnerClass(final ClassNode cNode, final ClassNode inner) {
         cNode.getModule().addClass(inner);
         markAsGenerated(cNode, inner);
     }
@@ -120,7 +122,7 @@ public class ClassNodeUtils {
      *
      * @see ClassNode#addConstructor(int, Parameter[], ClassNode[], Statement)
      */
-    public static ConstructorNode addGeneratedConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement code) {
+    public static ConstructorNode addGeneratedConstructor(final ClassNode classNode, final int modifiers, final Parameter[] parameters, final ClassNode[] exceptions, final Statement code) {
         ConstructorNode consNode = classNode.addConstructor(modifiers, parameters, exceptions, code);
         markAsGenerated(classNode, consNode);
         return consNode;
@@ -131,7 +133,7 @@ public class ClassNodeUtils {
      *
      * @see ClassNode#addConstructor(ConstructorNode)
      */
-    public static void addGeneratedConstructor(ClassNode classNode, ConstructorNode consNode) {
+    public static void addGeneratedConstructor(final ClassNode classNode, final ConstructorNode consNode) {
         classNode.addConstructor(consNode);
         markAsGenerated(classNode, consNode);
     }
@@ -142,7 +144,7 @@ public class ClassNodeUtils {
      * @param cNode The ClassNode
      * @return A map of methods
      */
-    public static Map<String, MethodNode> getDeclaredMethodsFromSuper(ClassNode cNode) {
+    public static Map<String, MethodNode> getDeclaredMethodsFromSuper(final ClassNode cNode) {
         ClassNode parent = cNode.getSuperClass();
         if (parent == null) {
             return new HashMap<>();
@@ -158,7 +160,7 @@ public class ClassNodeUtils {
      * @param cNode The ClassNode
      * @param methodsMap A map of existing methods to alter
      */
-    public static void addDeclaredMethodsFromInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap) {
+    public static void addDeclaredMethodsFromInterfaces(final ClassNode cNode, final Map<String, MethodNode> methodsMap) {
         for (ClassNode iface : cNode.getInterfaces()) {
             Map<String, MethodNode> declaredMethods = iface.getDeclaredMethodsMap();
             for (Map.Entry<String, MethodNode> entry : declaredMethods.entrySet()) {
@@ -176,7 +178,7 @@ public class ClassNodeUtils {
      * @param cNode The ClassNode
      * @return A map of methods
      */
-    public static Map<String, MethodNode> getDeclaredMethodsFromInterfaces(ClassNode cNode) {
+    public static Map<String, MethodNode> getDeclaredMethodsFromInterfaces(final ClassNode cNode) {
         Map<String, MethodNode> methodsMap = new HashMap<>();
         addDeclaredMethodsFromInterfaces(cNode, methodsMap);
         return methodsMap;
@@ -189,7 +191,7 @@ public class ClassNodeUtils {
      * @param cNode The ClassNode
      * @param methodsMap A map of existing methods to alter
      */
-    public static void addDeclaredMethodsFromAllInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap) {
+    public static void addDeclaredMethodsFromAllInterfaces(final ClassNode cNode, final Map<String, MethodNode> methodsMap) {
         List<?> cnInterfaces = Arrays.asList(cNode.getInterfaces());
         ClassNode parent = cNode.getSuperClass();
         while (parent != null && !parent.equals(ClassHelper.OBJECT_TYPE)) {
@@ -213,7 +215,7 @@ public class ClassNodeUtils {
      * @param trySpread whether to try to account for SpreadExpressions within the arguments
      * @return true if a matching method was found
      */
-    public static boolean hasPossibleStaticMethod(ClassNode cNode, String name, Expression arguments, boolean trySpread) {
+    public static boolean hasPossibleStaticMethod(final ClassNode cNode, final String name, final Expression arguments, final boolean trySpread) {
         int count = 0;
         boolean foundSpread = false;
 
@@ -265,7 +267,7 @@ public class ClassNodeUtils {
     /**
      * Return true if we have a static accessor
      */
-    public static boolean hasPossibleStaticProperty(ClassNode cNode, String methodName) {
+    public static boolean hasPossibleStaticProperty(final ClassNode cNode, final String methodName) {
         // assume explicit static method call checked first so we can assume a simple check here
         if (!methodName.startsWith("get") && !methodName.startsWith("is")) {
             return false;
@@ -282,7 +284,7 @@ public class ClassNodeUtils {
      * @param accessorName the accessor name of interest, e.g. getAge
      * @return the property name, e.g. age, or original if not a valid property accessor name
      */
-    public static String getPropNameForAccessor(String accessorName) {
+    public static String getPropNameForAccessor(final String accessorName) {
         if (!isValidAccessorName(accessorName)) return accessorName;
         int prefixLength = accessorName.startsWith("is") ? 2 : 3;
         return String.valueOf(accessorName.charAt(prefixLength)).toLowerCase() + accessorName.substring(prefixLength + 1);
@@ -294,7 +296,7 @@ public class ClassNodeUtils {
      * @param accessorName the accessor name of interest, e.g. getAge
      * @return true if a valid prefix is found
      */
-    public static boolean isValidAccessorName(String accessorName) {
+    public static boolean isValidAccessorName(final String accessorName) {
         if (accessorName.startsWith("get") || accessorName.startsWith("is") || accessorName.startsWith("set")) {
             int prefixLength = accessorName.startsWith("is") ? 2 : 3;
             return accessorName.length() > prefixLength;
@@ -302,7 +304,7 @@ public class ClassNodeUtils {
         return false;
     }
 
-    public static boolean hasStaticProperty(ClassNode cNode, String propName) {
+    public static boolean hasStaticProperty(final ClassNode cNode, final String propName) {
         PropertyNode found = getStaticProperty(cNode, propName);
         if (found == null) {
             found = getStaticProperty(cNode, BeanUtils.decapitalize(propName));
@@ -318,7 +320,7 @@ public class ClassNodeUtils {
      * @param propName the property name
      * @return the static property if found or else null
      */
-    public static PropertyNode getStaticProperty(ClassNode cNode, String propName) {
+    public static PropertyNode getStaticProperty(final ClassNode cNode, final String propName) {
         ClassNode classNode = cNode;
         while (classNode != null) {
             for (PropertyNode pn : classNode.getProperties()) {
@@ -335,14 +337,11 @@ public class ClassNodeUtils {
      * @param cNode the ClassNode of interest
      * @return true if the given node is a (non-static) inner class, else false
      */
-    public static boolean isInnerClass(ClassNode cNode) {
-        return cNode.redirect().getOuterClass() != null
-                && !Modifier.isStatic(cNode.getModifiers());
+    public static boolean isInnerClass(final ClassNode cNode) {
+        return cNode.getOuterClass() != null && !Modifier.isStatic(cNode.getModifiers());
     }
 
-    private ClassNodeUtils() { }
-
-    public static boolean hasNoArgConstructor(ClassNode cNode) {
+    public static boolean hasNoArgConstructor(final ClassNode cNode) {
         List<ConstructorNode> constructors = cNode.getDeclaredConstructors();
         for (ConstructorNode next : constructors) {
             if (next.getParameters().length == 0) {
@@ -359,7 +358,7 @@ public class ClassNodeUtils {
      * @param cNode the type of the containing class
      * @return true if an explicit (non-generated) constructor was found
      */
-    public static boolean hasExplicitConstructor(AbstractASTTransformation xform, ClassNode cNode) {
+    public static boolean hasExplicitConstructor(final AbstractASTTransformation xform, final ClassNode cNode) {
         List<ConstructorNode> declaredConstructors = cNode.getDeclaredConstructors();
         for (ConstructorNode constructorNode : declaredConstructors) {
             // allow constructors added by other transforms if flagged as Generated
@@ -384,7 +383,7 @@ public class ClassNodeUtils {
      * @return true if both given nodes have the same package name
      * @throws NullPointerException if either of the given nodes are null
      */
-    public static boolean samePackageName(ClassNode first, ClassNode second) {
+    public static boolean samePackageName(final ClassNode first, final ClassNode second) {
         return Objects.equals(first.getPackageName(), second.getPackageName());
     }
 
@@ -395,7 +394,7 @@ public class ClassNodeUtils {
      * @param fieldName the name of the field
      * @return the field or null if not found
      */
-    public static FieldNode getField(ClassNode classNode, String fieldName) {
+    public static FieldNode getField(final ClassNode classNode, final String fieldName) {
         ClassNode node = classNode;
         Set<String> visited = new HashSet<>();
         while (node != null) {
diff --git a/src/main/java/org/apache/groovy/ast/tools/ConstructorNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/ConstructorNodeUtils.java
index bdc2f9a..a9cd0f8 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ConstructorNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ConstructorNodeUtils.java
@@ -53,8 +53,8 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.varX;
  * Utility class for working with ConstructorNodes
  */
 public class ConstructorNodeUtils {
-    private static final ClassNode IMMUTABLE_TYPE = make(ImmutableASTTransformation.class);
     private static final ClassNode EXCEPTION = make(IllegalArgumentException.class);
+    private static final ClassNode IMMUTABLE_TYPE = make(ImmutableASTTransformation.class);
 
     private ConstructorNodeUtils() { }
 
@@ -64,7 +64,7 @@ public class ConstructorNodeUtils {
      * @param code the code to check
      * @return the first statement if a special call or null
      */
-    public static ConstructorCallExpression getFirstIfSpecialConstructorCall(Statement code) {
+    public static ConstructorCallExpression getFirstIfSpecialConstructorCall(final Statement code) {
         if (code == null) return null;
 
         if (code instanceof BlockStatement) {
@@ -84,7 +84,7 @@ public class ConstructorNodeUtils {
         return null;
     }
 
-    public static Statement checkPropNamesS(VariableExpression namedArgs, boolean pojo, List<PropertyNode> props) {
+    public static Statement checkPropNamesS(final VariableExpression namedArgs, final boolean pojo, final List<PropertyNode> props) {
         if (!pojo) {
             return stmt(callX(IMMUTABLE_TYPE, "checkPropNames", args(varX("this"), namedArgs)));
         }
diff --git a/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java b/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
index 440e2e3a..d85c9f1 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
@@ -59,8 +59,7 @@ public final class ExpressionUtils {
         Arrays.sort(HANDLED_TYPES);
     }
 
-    private ExpressionUtils() {
-    }
+    private ExpressionUtils() { }
 
     /**
      * Turns expressions of the form ConstantExpression(40) + ConstantExpression(2)
@@ -340,6 +339,10 @@ public final class ExpressionUtils {
         return null;
     }
 
+    public static boolean isNullConstant(final Expression expression) {
+        return expression instanceof ConstantExpression && ((ConstantExpression) expression).isNullExpression();
+    }
+
     public static boolean isThisExpression(final Expression expression) {
         return expression instanceof VariableExpression && ((VariableExpression) expression).isThisExpression();
     }
@@ -351,9 +354,4 @@ public final class ExpressionUtils {
     public static boolean isThisOrSuper(final Expression expression) {
         return isThisExpression(expression) || isSuperExpression(expression);
     }
-
-    public static boolean isNullConstant(final Expression expr) {
-        return expr instanceof ConstantExpression && ((ConstantExpression) expr).isNullExpression();
-    }
-
 }
diff --git a/src/main/java/org/apache/groovy/ast/tools/ImmutablePropertyUtils.java b/src/main/java/org/apache/groovy/ast/tools/ImmutablePropertyUtils.java
index 190f259..298cae5 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ImmutablePropertyUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ImmutablePropertyUtils.java
@@ -58,16 +58,16 @@ public class ImmutablePropertyUtils {
     private static final String MEMBER_KNOWN_IMMUTABLE_CLASSES = "knownImmutableClasses";
     private static final String MEMBER_KNOWN_IMMUTABLES = "knownImmutables";
     /*
-              Currently leaving BigInteger and BigDecimal in list but see:
-              http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6348370
-
-              Also, Color is not final so while not normally used with child
-              classes, it isn't strictly immutable. Use at your own risk.
-
-              This list can by extended by providing "known immutable" classes
-              via Immutable.knownImmutableClasses
-             */
-    private static final Set<String> BUILTIN_IMMUTABLES = new HashSet<String>(Arrays.asList(
+     * Currently leaving BigInteger and BigDecimal in list but see:
+     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6348370
+     *
+     * Also, Color is not final so while not normally used with child
+     * classes, it isn't strictly immutable. Use at your own risk.
+     *
+     * This list can by extended by providing "known immutable" classes
+     * via Immutable.knownImmutableClasses
+     */
+    private static final Set<String> BUILTIN_IMMUTABLES = new HashSet<>(Arrays.asList(
             "boolean",
             "byte",
             "char",
@@ -125,16 +125,16 @@ public class ImmutablePropertyUtils {
             "java.io.File"
     ));
 
-    private static final Set<String> BUILTIN_IMMUTABLE_ANNOTATIONS = new HashSet<String>(Arrays.asList(
+    private static final Set<String> BUILTIN_IMMUTABLE_ANNOTATIONS = new HashSet<>(Arrays.asList(
             "groovy.transform.Immutable",
             "groovy.transform.KnownImmutable",
-//            "javax.annotation.concurrent.Immutable", // its RetentionPolicy is CLASS, can not be got via reflection
+          //"javax.annotation.concurrent.Immutable", // its RetentionPolicy is CLASS, can not be got via reflection
             "net.jcip.annotations.Immutable" // supported by Findbugs and IntelliJ IDEA
     ));
 
     private ImmutablePropertyUtils() { }
 
-    public static Expression cloneArrayOrCloneableExpr(Expression fieldExpr, ClassNode type) {
+    public static Expression cloneArrayOrCloneableExpr(final Expression fieldExpr, final ClassNode type) {
         Expression smce = callX(
                 REFLECTION_INVOKER_TYPE,
                 "invoke",
@@ -147,19 +147,19 @@ public class ImmutablePropertyUtils {
         return castX(type, smce);
     }
 
-    public static boolean implementsCloneable(ClassNode fieldType) {
+    public static boolean implementsCloneable(final ClassNode fieldType) {
         return isOrImplements(fieldType, CLONEABLE_TYPE);
     }
 
-    public static Expression cloneDateExpr(Expression origDate) {
+    public static Expression cloneDateExpr(final Expression origDate) {
         return ctorX(DATE_TYPE, callX(origDate, "getTime"));
     }
 
-    public static boolean derivesFromDate(ClassNode fieldType) {
+    public static boolean derivesFromDate(final ClassNode fieldType) {
         return fieldType.isDerivedFrom(DATE_TYPE);
     }
 
-    public static String createErrorMessage(String className, String fieldName, String typeName, String mode) {
+    public static String createErrorMessage(final String className, final String fieldName, final String typeName, final String mode) {
         return "Unsupported type (" + prettyTypeName(typeName) + ") found for field '" + fieldName + "' while " + mode + " immutable class " + className + ".\n" +
                 "Immutable classes only support properties with effectively immutable types including:\n" +
                 "- Strings, primitive types, wrapper types, Class, BigInteger and BigDecimal, enums\n" +
@@ -169,11 +169,11 @@ public class ImmutablePropertyUtils {
                 "Other restrictions apply, please see the groovydoc for " + IMMUTABLE_OPTIONS_TYPE.getNameWithoutPackage() + " for further details";
     }
 
-    private static String prettyTypeName(String name) {
+    private static String prettyTypeName(final String name) {
         return name.equals("java.lang.Object") ? name + " or def" : name;
     }
 
-    public static boolean isKnownImmutableType(ClassNode fieldType, List<String> knownImmutableClasses) {
+    public static boolean isKnownImmutableType(final ClassNode fieldType, final List<String> knownImmutableClasses) {
         if (builtinOrDeemedType(fieldType, knownImmutableClasses))
             return true;
         if (!fieldType.isResolved())
@@ -191,11 +191,11 @@ public class ImmutablePropertyUtils {
                 hasImmutableAnnotation(fieldType);
     }
 
-    private static boolean builtinOrDeemedType(ClassNode fieldType, List<String> knownImmutableClasses) {
+    private static boolean builtinOrDeemedType(final ClassNode fieldType, final List<String> knownImmutableClasses) {
         return isBuiltinImmutable(fieldType.getName()) || knownImmutableClasses.contains(fieldType.getName()) || hasImmutableAnnotation(fieldType);
     }
 
-    private static boolean hasImmutableAnnotation(ClassNode type) {
+    private static boolean hasImmutableAnnotation(final ClassNode type) {
         List<AnnotationNode> annotations = type.getAnnotations();
         for (AnnotationNode next : annotations) {
             String name = next.getClassNode().getName();
@@ -204,15 +204,15 @@ public class ImmutablePropertyUtils {
         return false;
     }
 
-    private static boolean matchingImmutableMarkerName(String name) {
+    private static boolean matchingImmutableMarkerName(final String name) {
         return BUILTIN_IMMUTABLE_ANNOTATIONS.contains(name);
     }
 
-    public static boolean isBuiltinImmutable(String typeName) {
+    public static boolean isBuiltinImmutable(final String typeName) {
         return BUILTIN_IMMUTABLES.contains(typeName);
     }
 
-    private static boolean hasImmutableAnnotation(Class clazz) {
+    private static boolean hasImmutableAnnotation(final Class<?> clazz) {
         Annotation[] annotations = clazz.getAnnotations();
         for (Annotation next : annotations) {
             String name = next.annotationType().getName();
@@ -221,11 +221,11 @@ public class ImmutablePropertyUtils {
         return false;
     }
 
-    public static boolean builtinOrMarkedImmutableClass(Class<?> clazz) {
+    public static boolean builtinOrMarkedImmutableClass(final Class<?> clazz) {
         return isBuiltinImmutable(clazz.getName()) || hasImmutableAnnotation(clazz);
     }
 
-    public static List<String> getKnownImmutables(AbstractASTTransformation xform, ClassNode cNode) {
+    public static List<String> getKnownImmutables(final AbstractASTTransformation xform, final ClassNode cNode) {
         List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
         AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
         final List<String> immutables = new ArrayList<String>();
@@ -250,7 +250,7 @@ public class ImmutablePropertyUtils {
         return immutables;
     }
 
-    public static List<String> getKnownImmutableClasses(AbstractASTTransformation xform, ClassNode cNode) {
+    public static List<String> getKnownImmutableClasses(final AbstractASTTransformation xform, final ClassNode cNode) {
         List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
         AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
         final List<String> immutableClasses = new ArrayList<String>();
diff --git a/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
index 190462c..2e9c122 100644
--- a/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/MethodNodeUtils.java
@@ -31,8 +31,7 @@ import static org.apache.groovy.util.BeanUtils.decapitalize;
  */
 public class MethodNodeUtils {
 
-    private MethodNodeUtils() {
-    }
+    private MethodNodeUtils() { }
 
     /**
      * Return the method node's descriptor including its
diff --git a/src/main/java/org/apache/groovy/ast/tools/VisibilityUtils.java b/src/main/java/org/apache/groovy/ast/tools/VisibilityUtils.java
index 124ad35..b750b01 100644
--- a/src/main/java/org/apache/groovy/ast/tools/VisibilityUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/VisibilityUtils.java
@@ -41,8 +41,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
 public class VisibilityUtils {
     private static final ClassNode VISIBILITY_OPTIONS_TYPE = makeWithoutCaching(VisibilityOptions.class, false);
 
-    private VisibilityUtils() {
-    }
+    private VisibilityUtils() { }
 
     /**
      * Determine the correct modifiers by looking for a potential @VisibilityOptions annotation.
@@ -53,7 +52,7 @@ public class VisibilityUtils {
      * @param originalModifiers The modifier value to adjust or return if no applicable @VisibilityOptions is found
      * @return the updated modifiers
      */
-    public static int getVisibility(AnnotationNode anno, AnnotatedNode node, Class<? extends AnnotatedNode> clazz, int originalModifiers) {
+    public static int getVisibility(final AnnotationNode anno, final AnnotatedNode node, final Class<? extends AnnotatedNode> clazz, final int originalModifiers) {
         List<AnnotationNode> annotations = node.getAnnotations(VISIBILITY_OPTIONS_TYPE);
         if (annotations.isEmpty() || anno == null) return originalModifiers;
 
@@ -74,7 +73,7 @@ public class VisibilityUtils {
         return result | vis.getModifier();
     }
 
-    private static Visibility getVisForAnnotation(Class<? extends AnnotatedNode> clazz, AnnotationNode visAnno, String visId) {
+    private static Visibility getVisForAnnotation(final Class<? extends AnnotatedNode> clazz, final AnnotationNode visAnno, final String visId) {
         Map<String, Expression> visMembers = visAnno.getMembers();
         if (visMembers == null) return Visibility.UNDEFINED;
         String id = getMemberStringValue(visAnno, "id", null);
@@ -94,7 +93,7 @@ public class VisibilityUtils {
         return vis;
     }
 
-    private static Visibility getVisibility(Expression e) {
+    private static Visibility getVisibility(final Expression e) {
         if (e instanceof PropertyExpression) {
             PropertyExpression pe = (PropertyExpression) e;
             if (pe.getObjectExpression() instanceof ClassExpression && pe.getObjectExpression().getText().equals("groovy.transform.options.Visibility")) {
diff --git a/src/main/java/org/codehaus/groovy/transform/ImmutableASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/ImmutableASTTransformation.java
index 4bcd378..4149753 100644
--- a/src/main/java/org/codehaus/groovy/transform/ImmutableASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/ImmutableASTTransformation.java
@@ -90,16 +90,13 @@ import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
  */
 @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
 public class ImmutableASTTransformation extends AbstractASTTransformation implements CompilationUnitAware {
-    private CompilationUnit compilationUnit;
 
+    private static final ClassNode HMAP_TYPE = makeWithoutCaching(HashMap.class, false);
     private static final Class<? extends Annotation> MY_CLASS = ImmutableBase.class;
     public static final ClassNode MY_TYPE = makeWithoutCaching(MY_CLASS, false);
     private static final String MY_TYPE_NAME = MY_TYPE.getNameWithoutPackage();
 
-    private static final String MEMBER_ADD_COPY_WITH = "copyWith";
-    private static final String COPY_WITH_METHOD = "copyWith";
-
-    private static final ClassNode HMAP_TYPE = makeWithoutCaching(HashMap.class, false);
+    private CompilationUnit compilationUnit;
 
     @Override
     public String getAnnotationName() {
@@ -107,7 +104,12 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
     }
 
     @Override
-    public void visit(ASTNode[] nodes, SourceUnit source) {
+    public void setCompilationUnit(final CompilationUnit unit) {
+        this.compilationUnit = unit;
+    }
+
+    @Override
+    public void visit(final ASTNode[] nodes, final SourceUnit source) {
         init(nodes, source);
         AnnotatedNode parent = (AnnotatedNode) nodes[1];
         AnnotationNode anno = (AnnotationNode) nodes[0];
@@ -116,14 +118,13 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         if (parent instanceof ClassNode) {
             final GroovyClassLoader classLoader = compilationUnit != null ? compilationUnit.getTransformLoader() : source.getClassLoader();
             final PropertyHandler handler = PropertyHandler.createPropertyHandler(this, classLoader, (ClassNode) parent);
-            if (handler == null) return;
-            if (!handler.validateAttributes(this, anno)) return;
+            if (handler == null || !handler.validateAttributes(this, anno)) return;
             doMakeImmutable((ClassNode) parent, anno, handler);
         }
     }
 
-    private void doMakeImmutable(ClassNode cNode, AnnotationNode node, PropertyHandler handler) {
-        List<PropertyNode> newProperties = new ArrayList<PropertyNode>();
+    private void doMakeImmutable(final ClassNode cNode, final AnnotationNode node, final PropertyHandler handler) {
+        List<PropertyNode> newProperties = new ArrayList<>();
 
         String cName = cNode.getName();
         if (!checkNotInterface(cNode, MY_TYPE_NAME)) return;
@@ -142,7 +143,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
             ensureNotPublic(this, cName, fNode);
         }
         if (hasAnnotation(cNode, TupleConstructorASTTransformation.MY_TYPE)) {
-            // TODO make this a method to be called from TupleConstructor xform, add check for 'defaults'?
+            // TODO: Make this a method to be called from TupleConstructor xform, add check for 'defaults'?
             AnnotationNode tupleCons = cNode.getAnnotations(TupleConstructorASTTransformation.MY_TYPE).get(0);
             if (unsupportedTupleAttribute(tupleCons, "excludes")) return;
             if (unsupportedTupleAttribute(tupleCons, "includes")) return;
@@ -150,17 +151,16 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
             if (unsupportedTupleAttribute(tupleCons, "includeProperties")) return;
             if (unsupportedTupleAttribute(tupleCons, "includeSuperFields")) return;
             if (unsupportedTupleAttribute(tupleCons, "callSuper")) return;
-//            if (unsupportedTupleAttribute(tupleCons, "useSetters")) return;
+          //if (unsupportedTupleAttribute(tupleCons, "useSetters")) return;
             if (unsupportedTupleAttribute(tupleCons, "force")) return;
         }
         if (hasExplicitConstructor(this, cNode)) return;
-        if (memberHasValue(node, MEMBER_ADD_COPY_WITH, true) && !pList.isEmpty() &&
-                !hasDeclaredMethod(cNode, COPY_WITH_METHOD, 1)) {
+        if (!pList.isEmpty() && memberHasValue(node, "copyWith", Boolean.TRUE) && !hasDeclaredMethod(cNode, "copyWith", 1)) {
             createCopyWith(cNode, pList);
         }
     }
 
-    private boolean unsupportedTupleAttribute(AnnotationNode anno, String memberName) {
+    private boolean unsupportedTupleAttribute(final AnnotationNode anno, final String memberName) {
         if (getMemberValue(anno, memberName) != null) {
             String tname = TupleConstructorASTTransformation.MY_TYPE_NAME;
             addError("Error during " + MY_TYPE_NAME + " processing: Annotation attribute '" + memberName +
@@ -170,7 +170,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         return false;
     }
 
-    private static void makeClassFinal(AbstractASTTransformation xform, ClassNode cNode) {
+    private static void makeClassFinal(final AbstractASTTransformation xform, final ClassNode cNode) {
         int modifiers = cNode.getModifiers();
         if ((modifiers & ACC_FINAL) == 0) {
             if ((modifiers & (ACC_ABSTRACT | ACC_SYNTHETIC)) == (ACC_ABSTRACT | ACC_SYNTHETIC)) {
@@ -181,7 +181,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         }
     }
 
-    static boolean isSpecialNamedArgCase(List<PropertyNode> list, boolean checkSize) {
+    static boolean isSpecialNamedArgCase(final List<PropertyNode> list, final boolean checkSize) {
         if (checkSize && list.size() != 1) return false;
         if (list.size() == 0) return false;
         ClassNode firstParamType = list.get(0).getField().getType();
@@ -198,15 +198,15 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         return false;
     }
 
-    private static void ensureNotPublic(AbstractASTTransformation xform, String cNode, FieldNode fNode) {
+    private static void ensureNotPublic(final AbstractASTTransformation xform, final String cNode, final FieldNode fNode) {
         String fName = fNode.getName();
-        // TODO: do we need to lock down things like: $ownClass
+        // TODO: Do we need to lock down things like: $ownClass?
         if (fNode.isPublic() && !fName.contains("$") && !(fNode.isStatic() && fNode.isFinal())) {
             xform.addError("Public field '" + fName + "' not allowed for " + MY_TYPE_NAME + " class '" + cNode + "'.", fNode);
         }
     }
 
-    private static void addProperty(ClassNode cNode, PropertyNode pNode) {
+    private static void addProperty(final ClassNode cNode, final PropertyNode pNode) {
         final FieldNode fn = pNode.getField();
         cNode.getFields().remove(fn);
         cNode.addProperty(pNode.getName(), pNode.getModifiers() | ACC_FINAL, pNode.getType(),
@@ -216,13 +216,13 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         cNode.addField(fn);
     }
 
-    static boolean makeImmutable(ClassNode cNode) {
+    static boolean makeImmutable(final ClassNode cNode) {
         List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
         AnnotationNode annoImmutable = annotations.isEmpty() ? null : annotations.get(0);
         return annoImmutable != null;
     }
 
-    private static void adjustPropertyForImmutability(PropertyNode pNode, List<PropertyNode> newNodes, PropertyHandler handler) {
+    private static void adjustPropertyForImmutability(final PropertyNode pNode, final List<PropertyNode> newNodes, final PropertyHandler handler) {
         final FieldNode fNode = pNode.getField();
         fNode.setModifiers((pNode.getModifiers() & (~ACC_PUBLIC)) | ACC_FINAL | ACC_PRIVATE);
         pNode.setSetterBlock(null);
@@ -265,10 +265,12 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
                                                 new VariableScope(),
                                                 assignS(
                                                         varX("oldValue", ClassHelper.OBJECT_TYPE),
-                                                        varX("newValue", ClassHelper.OBJECT_TYPE)),
+                                                        varX("newValue", ClassHelper.OBJECT_TYPE)
+                                                ),
                                                 assignS(
                                                         varX("dirty", ClassHelper.boolean_TYPE),
-                                                        ConstantExpression.TRUE)
+                                                        ConstantExpression.TRUE
+                                                )
                                         )
                                 ),
                                 stmt(callX(
@@ -307,8 +309,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         body.addStatement(declS(localVarX("dirty", ClassHelper.boolean_TYPE), ConstantExpression.PRIM_FALSE));
         body.addStatement(declS(localVarX("construct", HMAP_TYPE), ctorX(HMAP_TYPE)));
 
-        // Check for each property
-        for (final PropertyNode pNode : pList) {
+        for (PropertyNode pNode : pList) {
             body.addStatement(createCheckForProperty(pNode));
         }
 
@@ -320,7 +321,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
 
         final ClassNode clonedNode = cNode.getPlainNodeReference();
 
-        addGeneratedMethod(cNode, COPY_WITH_METHOD,
+        addGeneratedMethod(cNode, "copyWith",
                 ACC_PUBLIC | ACC_FINAL,
                 clonedNode,
                 params(new Parameter(new ClassNode(Map.class), "map")),
@@ -331,17 +332,16 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
     /**
      * This method exists to be binary compatible with 1.7 - 1.8.6 compiled code.
      */
-    @SuppressWarnings("Unchecked")
-    public static Object checkImmutable(String className, String fieldName, Object field) {
+    public static Object checkImmutable(final String className, final String fieldName, final Object field) {
         if (field == null || field instanceof Enum || ImmutablePropertyUtils.isBuiltinImmutable(field.getClass().getName())) return field;
-        if (field instanceof Collection) return DefaultGroovyMethods.asImmutable((Collection) field);
+        if (field instanceof Collection) return DefaultGroovyMethods.asImmutable((Collection<?>) field);
         if (getAnnotationByName(field, "groovy.transform.Immutable") != null) return field;
 
         final String typeName = field.getClass().getName();
         throw new RuntimeException(createErrorMessage(className, fieldName, typeName, "constructing"));
     }
 
-    private static Annotation getAnnotationByName(Object field, String name) {
+    private static Annotation getAnnotationByName(final Object field, final String name) {
         // find longhand since the annotation from earlier versions is now a meta annotation
         for (Annotation an : field.getClass().getAnnotations()) {
             if (an.getClass().getName().equals(name)) {
@@ -354,8 +354,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
     /**
      * For compatibility with pre 2.5 compiled classes
      */
-    @SuppressWarnings("Unchecked")
-    public static Object checkImmutable(Class<?> clazz, String fieldName, Object field) {
+    public static Object checkImmutable(final Class<?> clazz, final String fieldName, final Object field) {
         if (field == null || field instanceof Enum || builtinOrMarkedImmutableClass(field.getClass())) {
             return field;
         }
@@ -375,13 +374,13 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
                 declaredField = clazz.getDeclaredField(fieldName);
                 Class<?> fieldType = declaredField.getType();
                 if (Collection.class.isAssignableFrom(fieldType)) {
-                    return DefaultGroovyMethods.asImmutable((Collection) field);
+                    return DefaultGroovyMethods.asImmutable((Collection<?>) field);
                 }
                 // potentially allow Collection coercion for a constructor
                 if (builtinOrMarkedImmutableClass(fieldType)) {
                     return field;
                 }
-            } catch (NoSuchFieldException ignore) {
+            } catch (NoSuchFieldException e) {
                 // ignore
             }
         }
@@ -389,8 +388,7 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         throw new RuntimeException(createErrorMessage(clazz.getName(), fieldName, typeName, "constructing"));
     }
 
-    @SuppressWarnings("Unchecked")
-    public static Object checkImmutable(Class<?> clazz, String fieldName, Object field, List<String> knownImmutableFieldNames, List<Class> knownImmutableClasses) {
+    public static Object checkImmutable(final Class<?> clazz, final String fieldName, final Object field, final List<String> knownImmutableFieldNames, final List<Class> knownImmutableClasses) {
         if (field == null || field instanceof Enum || builtinOrMarkedImmutableClass(field.getClass()) || knownImmutableFieldNames.contains(fieldName) || knownImmutableClasses.contains(field.getClass())) {
             return field;
         }
@@ -410,13 +408,13 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
                 declaredField = clazz.getDeclaredField(fieldName);
                 Class<?> fieldType = declaredField.getType();
                 if (Collection.class.isAssignableFrom(fieldType)) {
-                    return DefaultGroovyMethods.asImmutable((Collection) field);
+                    return DefaultGroovyMethods.asImmutable((Collection<?>) field);
                 }
                 // potentially allow Collection coercion for a constructor
                 if (builtinOrMarkedImmutableClass(fieldType) || knownImmutableClasses.contains(fieldType)) {
                     return field;
                 }
-            } catch (NoSuchFieldException ignore) {
+            } catch (NoSuchFieldException e) {
                 // ignore
             }
         }
@@ -424,16 +422,12 @@ public class ImmutableASTTransformation extends AbstractASTTransformation implem
         throw new RuntimeException(createErrorMessage(clazz.getName(), fieldName, typeName, "constructing"));
     }
 
-    public static void checkPropNames(Object instance, Map<String, Object> args) {
+    public static void checkPropNames(final Object instance, final Map<String, Object> args) {
         final MetaClass metaClass = InvokerHelper.getMetaClass(instance);
-        for (String k : args.keySet()) {
-            if (metaClass.hasProperty(instance, k) == null)
-                throw new MissingPropertyException(k, instance.getClass());
+        for (String name : args.keySet()) {
+            if (metaClass.hasProperty(instance, name) == null) {
+                throw new MissingPropertyException(name, instance.getClass());
+            }
         }
     }
-
-    @Override
-    public void setCompilationUnit(CompilationUnit unit) {
-        this.compilationUnit = unit;
-    }
 }
diff --git a/src/test/org/codehaus/groovy/util/ListHashMapTest.groovy b/src/test/org/codehaus/groovy/util/ListHashMapTest.groovy
index 2d550bd..5f82a55 100644
--- a/src/test/org/codehaus/groovy/util/ListHashMapTest.groovy
+++ b/src/test/org/codehaus/groovy/util/ListHashMapTest.groovy
@@ -21,33 +21,28 @@ package org.codehaus.groovy.util
 import groovy.test.GroovyTestCase
 
 class ListHashMapTest extends GroovyTestCase {
-    ListHashMap list
 
+    private final ListHashMap list = new ListHashMap(2)
 
-    public void setUp() throws Exception {
-        super.setUp();
-        list = new ListHashMap(2)
-    }
-
-    public void testEmptyWhenCreated() {
+    void testEmptyWhenCreated() {
         assert list.isEmpty()
         assert list.@maxListFill == 2
     }
 
-    public void testInsertElement() {
+    void testInsertElement() {
         list.put("a", "a")
         assert list.size() == 1
         assert list.@innerMap == null
     }
 
-    public void testInsertTwoElements() {
+    void testInsertTwoElements() {
         list.put("a", "a")
         list.put("b", "b")
         assert list.size() == 2
         assert list.@innerMap == null
     }
 
-    public void testInsertWithSameKey() {
+    void testInsertWithSameKey() {
         list.put("a", "a")
         list.put("a", "b")
         assert list.size() == 1
@@ -55,7 +50,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.get("a") == "b"
     }
 
-    public void testSwitchToInnerMap() {
+    void testSwitchToInnerMap() {
         list.put("a", "a")
         list.put("b", "b")
         list.put("c", "c")
@@ -64,7 +59,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.@innerMap.size() == 3
     }
 
-    public void testSwitchToInnerMapThenFallbackToList() {
+    void testSwitchToInnerMapThenFallbackToList() {
         list.put("a", "a")
         list.put("b", "b")
         list.put("c", "c")
@@ -77,22 +72,21 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.keySet() == ['a','b'] as Set
     }
 
-    public void testPutNullValue() {
+    void testPutNullValue() {
         list.put("a", null)
         assert list.size() == 1
         assert list.a == null
     }
 
-    public void testRemoveNullValue() {
+    void testRemoveNullValue() {
         list.put("a", null)
         assert list.size() == 1
         assert list.a == null
         list.remove("a")
         assert list.size() == 0
-        assert list.a == null
     }
 
-    public void testPutAll() {
+    void testPutAll() {
         list.putAll([a: '1', b: '2', c: '3'])
         assert list.size() == 3
         assert list.@innerMap != null
@@ -101,7 +95,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.values()  as Set == ['1','2','3'] as Set
     }
 
-    public void testPutAllTwice() {
+    void testPutAllTwice() {
         list.putAll([a: '1', b: '2', c: '3'])
         list.putAll([a: '1', b: '2', c: '3'])
         assert list.size() == 3
@@ -111,7 +105,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.values() as Set  == ['1','2','3'] as Set
     }
 
-    public void testRemoveAll() {
+    void testRemoveAll() {
         list.putAll([a: '1', b: '2', c: '3'])
         assert list.size() == 3
         assert list.@innerMap != null
@@ -125,7 +119,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.@innerMap == null
     }
 
-    public void testRemoveFirstShiftsKeyValuesAndClearsArraySlot() {
+    void testRemoveFirstShiftsKeyValuesAndClearsArraySlot() {
         list.putAll([a: '1', b: '2'])
         assert list.size() == 2
         assert list.@innerMap == null
@@ -144,7 +138,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.@listValues[1] == '3'
     }
 
-    public void testRemoveLastClearsLastArraySlot() {
+    void testRemoveLastClearsLastArraySlot() {
         list.putAll([a: '1', b: '2'])
         assert list.size() == 2
         assert list.@innerMap == null
@@ -163,7 +157,7 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.@listValues[1] == '3'
     }
 
-    public void testSwitchToInnerMapClearsArrays() {
+    void testSwitchToInnerMapClearsArrays() {
         list.putAll([a: '1', b: '2'])
         assert list.size() == 2
         assert list.@innerMap == null
@@ -179,12 +173,12 @@ class ListHashMapTest extends GroovyTestCase {
         assert list.@listValues[1] == null
     }
 
-    public void testContainsKey() {
+    void testContainsKey() {
         list.putAll([a: '1', b: '2'])
         assert list.containsKey('b')
     }
 
-    public void testContainsValue() {
+    void testContainsValue() {
         list.putAll([a: '1', b: '2'])
         assert list.containsValue('2')
     }