Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
(cherry picked from commit 010624d)
  • Loading branch information
daniellansun committed Aug 26, 2017
1 parent df0dfbf commit b82049a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/groovy/lang/GroovyObjectSupport.java
Expand Up @@ -31,7 +31,7 @@ public abstract class GroovyObjectSupport implements GroovyObject {
private transient MetaClass metaClass;

public GroovyObjectSupport() {
this.metaClass = InvokerHelper.getMetaClass(this.getClass());
this.metaClass = getDefaultMetaClass();
}

public Object getProperty(String property) {
Expand All @@ -47,13 +47,17 @@ public Object invokeMethod(String name, Object args) {
}

public MetaClass getMetaClass() {
if (metaClass == null) {
metaClass = InvokerHelper.getMetaClass(getClass());
}
return metaClass;
return this.metaClass;
}

public void setMetaClass(MetaClass metaClass) {
this.metaClass = metaClass;
this.metaClass =
null == metaClass
? getDefaultMetaClass()
: metaClass;
}

private MetaClass getDefaultMetaClass() {
return InvokerHelper.getMetaClass(this.getClass());
}
}

0 comments on commit b82049a

Please sign in to comment.