Package org.apache.groovy.internal.util
Class ImmutableTypes
java.lang.Object
org.apache.groovy.internal.util.ImmutableTypes
The types and marker annotations Groovy treats as immutable, shared by the
@Immutable family of transforms and by the runtime (GROOVY-12390).
Lives outside the AST packages on purpose: GStringImpl consults it
for every GString with a non-trivial value, and reaching it through the
transform utilities would initialise the compiler's ClassHelper,
with its reflective model of the JDK types, in an application that never
compiles anything. Internal to the runtime, not a public API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbuiltinOrMarkedImmutableClass(Class<?> clazz) Whether a class is built in as immutable or carries an immutable marker annotation.static booleanhasImmutableAnnotation(Class<?> clazz) Whether a class carries a recognised immutable marker annotation.static booleanisBuiltinImmutable(String typeName) Whether a type name is one of the JDK types Groovy treats as immutable.static booleanisImmutableMarker(String annotationName) Whether an annotation name marks its target as immutable.
-
Method Details
-
isBuiltinImmutable
Whether a type name is one of the JDK types Groovy treats as immutable.- Parameters:
typeName- the fully qualified type name- Returns:
truefor a built-in immutable type
-
isImmutableMarker
Whether an annotation name marks its target as immutable.- Parameters:
annotationName- the fully qualified annotation type name- Returns:
truefor a recognised immutable marker
-
hasImmutableAnnotation
Whether a class carries a recognised immutable marker annotation.- Parameters:
clazz- the class to inspect- Returns:
truewhen a marker is present
-
builtinOrMarkedImmutableClass
Whether a class is built in as immutable or carries an immutable marker annotation.- Parameters:
clazz- the class to inspect- Returns:
truewhen the class is considered immutable
-