public Object getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass) {

        //----------------------------------------------------------------------
        // handling of static
        //----------------------------------------------------------------------
        boolean isStatic = theClass != Class.class && object instanceof Class;
        if (isStatic && object != theClass) {
            MetaClass mc = registry.getMetaClass((Class) object);
            return mc.getProperty(sender, object, name, useSuper, false);
        }

        checkInitalised();

        //----------------------------------------------------------------------
        // turn getProperty on a Map to get on the Map itself
        //----------------------------------------------------------------------
        if (!isStatic && this.isMap) {
            return ((Map) object).get(name);
        }

        MetaMethod method = null;
        Object[] arguments = EMPTY_ARGUMENTS;

        //----------------------------------------------------------------------
        // getter
        //----------------------------------------------------------------------
        MetaProperty mp = getMetaProperty(sender, name, useSuper, isStatic);
        if (mp != null) {
            if (mp instanceof MetaBeanProperty) {
                MetaBeanProperty mbp = (MetaBeanProperty) mp;
                method = mbp.getGetter();
                mp = mbp.getField();
            }
        }

        // check for a category method named like a getter
        if (!useSuper && !isStatic && GroovyCategorySupport.hasCategoryInCurrentThread()) {
            String getterName = GroovyCategorySupport.getPropertyCategoryGetterName(name);
            if (getterName != null) {
                MetaMethod categoryMethod = getCategoryMethodGetter(sender, getterName, false);
                if (categoryMethod != null) method = categoryMethod;
            }
        }

        //----------------------------------------------------------------------
        // field
        //----------------------------------------------------------------------
        if (method == null && mp != null) {
            try {
                return mp.getProperty(object);
            } catch (IllegalArgumentException e) {
                // can't access the field directly but there may be a getter
                mp = null;
            }
        }

        //----------------------------------------------------------------------
        // generic get method
        //----------------------------------------------------------------------
        // check for a generic get method provided through a category
        if (method == null && !useSuper && !isStatic && GroovyCategorySupport.hasCategoryInCurrentThread()) {
            method = getCategoryMethodGetter(sender, "get", true);
            if (method != null) arguments = new Object[]{name};
        }

        // the generic method is valid, if available (!=null), if static or
        // if it is not static and we do no static access
        if (method == null && genericGetMethod != null && !(!genericGetMethod.isStatic() && isStatic)) {
            arguments = new Object[]{name};
            method = genericGetMethod;
        }

        //----------------------------------------------------------------------
        // special cases
        //----------------------------------------------------------------------
        if (method == null) {
            /** todo these special cases should be special MetaClasses maybe */
            if (theClass != Class.class && object instanceof Class) {
                MetaClass mc = registry.getMetaClass(Class.class);
                return mc.getProperty(Class.class, object, name, useSuper, false);
            } else if (object instanceof Collection) {
                return DefaultGroovyMethods.getAt((Collection) object, name);
            } else if (object instanceof Object[]) {
                return DefaultGroovyMethods.getAt(Arrays.asList((Object[]) object), name);
            } else {
                MetaMethod addListenerMethod = (MetaMethod) listeners.get(name);
                if (addListenerMethod != null) {
                    //TODO: one day we could try return the previously registered Closure listener for easy removal
                    return null;
                }
            }
        } else {

            //----------------------------------------------------------------------
            // executing the getter method
            //----------------------------------------------------------------------
            return method.doMethodInvoke(object, arguments);
        }

        //----------------------------------------------------------------------
        // error due to missing method/field
        //----------------------------------------------------------------------
        if (isStatic || object instanceof Class)
            return invokeStaticMissingProperty(object, name, null, true);
        else
            return invokeMissingProperty(object, name, null, true);
    }
public Object getProperty ( Class sender , Object object , String name , boolean useSuper , boolean fromInsideClass ) { boolean isStatic = theClass != Class . class && object instanceof Class ; if ( isStatic && object != theClass ) { MetaClass mc = registry . getMetaClass ( ( Class ) object ) ; return mc . getProperty ( sender , object , name , useSuper , false ) ; } checkInitalised ( ) ; if ( ! isStatic && this . isMap ) { return ( ( Map ) object ) . get ( name ) ; } MetaMethod method = null ; Object [ ] arguments = EMPTY_ARGUMENTS ; MetaProperty mp = getMetaProperty ( sender , name , useSuper , isStatic ) ; if ( mp != null ) { if ( mp instanceof MetaBeanProperty ) { MetaBeanProperty mbp = ( MetaBeanProperty ) mp ; method = mbp . getGetter ( ) ; mp = mbp . getField ( ) ; } } if ( ! useSuper && ! isStatic && GroovyCategorySupport . hasCategoryInCurrentThread ( ) ) { String getterName = GroovyCategorySupport . getPropertyCategoryGetterName ( name ) ; if ( getterName != null ) { MetaMethod categoryMethod = getCategoryMethodGetter ( sender , getterName , false ) ; if ( categoryMethod != null ) method = categoryMethod ; } } if ( method == null && mp != null ) { try { return mp . getProperty ( object ) ; } catch ( IllegalArgumentException e ) { mp = null ; } } if ( method == null && ! useSuper && ! isStatic && GroovyCategorySupport . hasCategoryInCurrentThread ( ) ) { method = getCategoryMethodGetter ( sender , "get" , true ) ; if ( method != null ) arguments = new Object [ ] { name } ; } if ( method == null && genericGetMethod != null && ! ( ! genericGetMethod . isStatic ( ) && isStatic ) ) { arguments = new Object [ ] { name } ; method = genericGetMethod ; } if ( method == null ) { if ( theClass != Class . class && object instanceof Class ) { MetaClass mc = registry . getMetaClass ( Class . class ) ; return mc . getProperty ( Class . class , object , name , useSuper , false ) ; } else if ( object instanceof Collection ) { return DefaultGroovyMethods . getAt ( ( Collection ) object , name ) ; } else if ( object instanceof Object [ ] ) { return DefaultGroovyMethods . getAt ( Arrays . asList ( ( Object [ ] ) object ) , name ) ; } else { MetaMethod addListenerMethod = ( MetaMethod ) listeners . get ( name ) ; if ( addListenerMethod != null ) { return null ; } } } else { return method . doMethodInvoke ( object , arguments ) ; } if ( isStatic || object instanceof Class ) return invokeStaticMissingProperty ( object , name , null , true ) ; else return invokeMissingProperty ( object , name , null , true ) ; }
@return the given property's value on the object