Package: org.apache.groovy.ast.tools

## [Java] Class ImmutablePropertyUtils

- org.apache.groovy.ast.tools.ImmutablePropertyUtils

-     public class ImmutablePropertyUtils
      extends Object

  Utility methods for immutable-property analysis and code generation.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static ClassNode` | `IMMUTABLE_OPTIONS_TYPE` | The ImmutableOptions annotation type used to configure immutable-property handling.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static boolean` | `builtinOrMarkedImmutableClass(Class<?> clazz)` Checks whether the supplied class is built in as immutable or carries an immutable marker annotation.
    `` | `public static Expression` | `cloneArrayOrCloneableExpr(Expression expr, ClassNode type)` Creates an expression that clones an array or Cloneable value and casts it back to the requested type.
    `` | `public static Expression` | `cloneDateExpr(Expression origDate)` Creates an expression that clones a Date value.
    `` | `public static String` | `createErrorMessage(String className, String fieldName, String typeName, String mode)` Creates the standard error message for an unsupported immutable property type.
    `` | `public static boolean` | `derivesFromDate(ClassNode fieldType)` Checks whether the supplied type derives from Date.
    `` | `public static List<String>` | `getKnownImmutableClasses(AbstractASTTransformation xform, ClassNode cNode)` Extracts configured immutable helper classes from ImmutableOptions.
    `` | `public static List<String>` | `getKnownImmutables(AbstractASTTransformation xform, ClassNode cNode)` Extracts configured immutable property names from ImmutableOptions.
    `` | `public static boolean` | `implementsCloneable(ClassNode fieldType)` Checks whether the supplied type implements Cloneable.
    `` | `public static boolean` | `isBuiltinImmutable(String typeName)` Checks whether the supplied type name is one of the built-in immutable types.
    `` | `public static boolean` | `isKnownImmutableType(ClassNode fieldType, List<String> knownImmutableClasses)` Checks whether the supplied type is acceptable for an immutable property.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final ClassNode IMMUTABLE_OPTIONS_TYPE

      The ImmutableOptions annotation type used to configure immutable-property handling.

  - ### Method Detail

    - #### public static boolean builtinOrMarkedImmutableClass(Class<?> clazz)

      Checks whether the supplied class is built in as immutable or carries an immutable marker annotation.

      Parameters:
        `clazz` - the class to inspect
      Returns:
        `true` if the class is treated as immutable

    - #### public static Expression cloneArrayOrCloneableExpr(Expression expr, ClassNode type)

      Creates an expression that clones an array or Cloneable value and casts it back to the requested type.

      Parameters:
        `expr` - the expression producing the original value
        `type` - the expected result type
      Returns:
        an expression that performs the clone operation

    - #### public static Expression cloneDateExpr(Expression origDate)

      Creates an expression that clones a Date value.

      Parameters:
        `origDate` - the date expression to clone
      Returns:
        an expression that creates a defensive date copy

    - #### public static String createErrorMessage(String className, String fieldName, String typeName, String mode)

      Creates the standard error message for an unsupported immutable property type.

      Parameters:
        `className` - the immutable class being processed
        `fieldName` - the property name
        `typeName` - the unsupported type name
        `mode` - the operation being performed
      Returns:
        the formatted error message

    - #### public static boolean derivesFromDate(ClassNode fieldType)

      Checks whether the supplied type derives from Date.

      Parameters:
        `fieldType` - the type to inspect
      Returns:
        `true` if the type derives from Date

    - #### public static List<String> getKnownImmutableClasses(AbstractASTTransformation xform, ClassNode cNode)

      Extracts configured immutable helper classes from ImmutableOptions.

      Parameters:
        `xform` - the transform reporting configuration errors
        `cNode` - the annotated class node
      Returns:
        the configured immutable class names

    - #### public static List<String> getKnownImmutables(AbstractASTTransformation xform, ClassNode cNode)

      Extracts configured immutable property names from ImmutableOptions.

      Parameters:
        `xform` - the transform reporting configuration errors
        `cNode` - the annotated class node
      Returns:
        the configured immutable property names

    - #### public static boolean implementsCloneable(ClassNode fieldType)

      Checks whether the supplied type implements Cloneable.

      Parameters:
        `fieldType` - the type to inspect
      Returns:
        `true` if the type implements Cloneable

    - #### public static boolean isBuiltinImmutable(String typeName)

      Checks whether the supplied type name is one of the built-in immutable types.

      Parameters:
        `typeName` - the type name to inspect
      Returns:
        `true` if the type is treated as built-in immutable

    - #### public static boolean isKnownImmutableType(ClassNode fieldType, List<String> knownImmutableClasses)

      Checks whether the supplied type is acceptable for an immutable property.

      Parameters:
        `fieldType` - the type to inspect
        `knownImmutableClasses` - additional immutable type names supplied by configuration
      Returns:
        `true` if the type is supported by immutable-property handling