Class StringCachedClass

java.lang.Object
org.codehaus.groovy.reflection.CachedClass
org.codehaus.groovy.reflection.stdclasses.StringCachedClass

public class StringCachedClass extends CachedClass
Provides optimized reflection caching for String. Coerces GString arguments to String for type-safe method invocation.
  • Constructor Details

    • StringCachedClass

      public StringCachedClass(ClassInfo classInfo)
      Constructs a cached class representation for String.
      Parameters:
      classInfo - the class information associated with String
  • Method Details

    • isDirectlyAssignable

      public boolean isDirectlyAssignable(Object argument)
      Checks if the given argument is directly assignable to String.
      Overrides:
      isDirectlyAssignable in class CachedClass
      Parameters:
      argument - the argument to check
      Returns:
      true if the argument is an instance of String, false otherwise
    • isAssignableFrom

      public boolean isAssignableFrom(Class classToTransformFrom)
      Determines if the given class can be transformed to String. Accepts null, String, and GString subtypes.
      Overrides:
      isAssignableFrom in class CachedClass
      Parameters:
      classToTransformFrom - the source class to check
      Returns:
      true if the class can be transformed to String, false otherwise
    • coerceArgument

      public Object coerceArgument(Object argument)
      Coerces the given argument to String. Converts GString arguments to String by calling toString().
      Overrides:
      coerceArgument in class CachedClass
      Parameters:
      argument - the argument to coerce
      Returns:
      the argument as a String, or the original argument if not a GString