public Object getAt(Class key) {
if (key.isAssignableFrom(object.getClass())) {
return new GroovyObjectSupport() {
{
final MetaClass ownMetaClass = InvokerHelper.getMetaClass(object.getClass());
setMetaClass(new OwnedMetaClass(ownMetaClass) {
protected Object getOwner() {
return object;
}
protected MetaClass getOwnerMetaClass(Object owner) {
return getAdaptee();
}
});
}
};
}
for (final MixinInMetaClass mixin : mixinClasses) {
if (key.isAssignableFrom(mixin.getMixinClass().getTheClass())) {
return new GroovyObjectSupport() {
{
final Object mixedInInstance = mixin.getMixinInstance(object);
setMetaClass(new OwnedMetaClass(InvokerHelper.getMetaClass(mixedInInstance)) {
@Override
protected Object getOwner() {
return mixedInInstance;
}