Class Wrapper

java.lang.Object
org.codehaus.groovy.runtime.wrappers.Wrapper
All Implemented Interfaces:
GroovyObject
Direct Known Subclasses:
GroovyObjectWrapper, PojoWrapper

public abstract class Wrapper extends Object implements GroovyObject
Base class for runtime wrappers that expose a value through GroovyObject while reporting a constrained type.
  • Field Details

    • constrainedType

      protected final Class constrainedType
      The constrained type the wrapped value should present to the runtime.
  • Constructor Details

    • Wrapper

      public Wrapper(Class constrainedType)
      Creates a wrapper for values that should appear as the supplied type.
      Parameters:
      constrainedType - the type the wrapped value should report
  • Method Details

    • getMetaClass

      public MetaClass getMetaClass()
      Returns the MetaClass used to service GroovyObject operations for the wrapped value.
      Specified by:
      getMetaClass in interface GroovyObject
      Returns:
      the delegated meta class
    • getType

      public Class getType()
      Returns the constrained type associated with this wrapper.
      Returns:
      the type the wrapped value should be treated as
    • unwrap

      public abstract Object unwrap()
      Returns the wrapped value.
      Returns:
      the underlying value represented by this wrapper
    • getWrapped

      protected abstract Object getWrapped()
      Returns the object used as the delegation target for meta-class-based operations.
      Returns:
      the underlying wrapped object
    • getDelegatedMetaClass

      protected abstract MetaClass getDelegatedMetaClass()
      Returns the meta class that should handle GroovyObject operations for the wrapped value.
      Returns:
      the delegated meta class