Package org.codehaus.groovy.reflection.stdclasses

# 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.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.codehaus.groovy.reflection.CachedClass

  `CachedClass.CachedMethodComparatorByName, CachedClass.CachedMethodComparatorWithString`

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.reflection.CachedClass

  `classInfo, EMPTY_ARRAY, isArray, isInterface, isNumber, isPrimitive, modifiers, mopMethods`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringCachedClass(ClassInfo classInfo)`
  Constructs a cached class representation for `String`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `coerceArgument(Object argument)`
  Coerces the given argument to `String`.
  `boolean`
  `isAssignableFrom(Class classToTransformFrom)`
  Determines if the given class can be transformed to `String`.
  `boolean`
  `isDirectlyAssignable(Object argument)`
  Checks if the given argument is directly assignable to `String`.

  ### Methods inherited from class org.codehaus.groovy.reflection.CachedClass

  `addNewMopMethods, getCachedClass, getCachedSuperClass, getCallSiteLoader, getConstructors, getDeclaredInterfaces, getFields, getHierarchy, getInterfaces, getMethods, getModifiers, getName, getNewMetaMethods, getSuperClassDistance, getTheClass, getTypeDescription, hashCode, isInterface, isPrimitive, isVoid, searchMethods, setNewMopMethods, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## 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`