MCPcopy
hub / github.com/apache/groovy / Wrapper

Class Wrapper

src/main/java/org/codehaus/groovy/runtime/wrappers/Wrapper.java:28–85  ·  view source on GitHub ↗

Base class for runtime wrappers that expose a value through GroovyObject while reporting a constrained type.

Source from the content-addressed store, hash-verified

26 * {@link GroovyObject} while reporting a constrained type.
27 */
28public abstract class Wrapper implements GroovyObject {
29 /**
30 * The constrained type the wrapped value should present to the runtime.
31 */
32 protected final Class constrainedType;
33
34 /**
35 * Creates a wrapper for values that should appear as the supplied type.
36 *
37 * @param constrainedType the type the wrapped value should report
38 */
39 public Wrapper(final Class constrainedType) {
40 this.constrainedType = constrainedType;
41 }
42
43 /**
44 * Returns the {@link MetaClass} used to service GroovyObject operations for
45 * the wrapped value.
46 *
47 * @return the delegated meta class
48 */
49 @Override
50 public MetaClass getMetaClass() {
51 return getDelegatedMetaClass();
52 }
53
54 /**
55 * Returns the constrained type associated with this wrapper.
56 *
57 * @return the type the wrapped value should be treated as
58 */
59 public Class getType() {
60 return this.constrainedType;
61 }
62
63 /**
64 * Returns the wrapped value.
65 *
66 * @return the underlying value represented by this wrapper
67 */
68 public abstract Object unwrap();
69
70 /**
71 * Returns the object used as the delegation target for meta-class-based
72 * operations.
73 *
74 * @return the underlying wrapped object
75 */
76 protected abstract Object getWrapped();
77
78 /**
79 * Returns the meta class that should handle GroovyObject operations for the
80 * wrapped value.
81 *
82 * @return the delegated meta class
83 */
84 protected abstract MetaClass getDelegatedMetaClass();
85}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…