{@inheritDoc}
(final Class sender, final Object object, final String name, final boolean useSuper, final boolean fromInsideClass)
| 2015 | |
| 2016 | /** {@inheritDoc} */ |
| 2017 | @Override |
| 2018 | public Object getProperty(final Class sender, final Object object, final String name, final boolean useSuper, final boolean fromInsideClass) { |
| 2019 | |
| 2020 | //---------------------------------------------------------------------- |
| 2021 | // handling of static |
| 2022 | //---------------------------------------------------------------------- |
| 2023 | boolean isStatic = (theClass != Class.class && object instanceof Class); |
| 2024 | if (isStatic && object != theClass) { |
| 2025 | MetaClass mc = registry.getMetaClass((Class<?>) object); |
| 2026 | return mc.getProperty(sender, object, name, useSuper, false); |
| 2027 | } |
| 2028 | |
| 2029 | checkInitalised(); |
| 2030 | |
| 2031 | //---------------------------------------------------------------------- |
| 2032 | // getter |
| 2033 | //---------------------------------------------------------------------- |
| 2034 | Tuple2<MetaMethod, MetaProperty> methodAndProperty = createMetaMethodAndMetaProperty(sender, name, useSuper, isStatic); |
| 2035 | MetaMethod method = methodAndProperty.getV1(); |
| 2036 | MetaProperty prop = methodAndProperty.getV2(); |
| 2037 | |
| 2038 | if (method == null || isSpecialProperty(name) || isVisibleProperty(prop, method, sender)) { |
| 2039 | //------------------------------------------------------------------ |
| 2040 | // public field |
| 2041 | //------------------------------------------------------------------ |
| 2042 | if (prop != null && prop.isPublic()) { |
| 2043 | try { |
| 2044 | return prop.getProperty(object); |
| 2045 | } catch (GroovyRuntimeException e) { |
| 2046 | // can't access the field directly but there may be a getter |
| 2047 | prop = null; |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | //------------------------------------------------------------------ |
| 2052 | // java.util.Map get method |
| 2053 | //------------------------------------------------------------------ |
| 2054 | if (isMap && !isStatic) { |
| 2055 | return ((Map<?,?>) object).get(name); |
| 2056 | } |
| 2057 | |
| 2058 | //------------------------------------------------------------------ |
| 2059 | // non-public field |
| 2060 | //------------------------------------------------------------------ |
| 2061 | if (prop != null) { |
| 2062 | try { |
| 2063 | return prop.getProperty(object); |
| 2064 | } catch (GroovyRuntimeException e) { |
| 2065 | } |
| 2066 | } |
| 2067 | } |
| 2068 | |
| 2069 | //---------------------------------------------------------------------- |
| 2070 | // java.util.Map get method before non-public getter -- see GROOVY-11367 |
| 2071 | //---------------------------------------------------------------------- |
| 2072 | if (isMap && !isStatic && !method.isPublic()) { |
| 2073 | return ((Map<?,?>) object).get(name); |
| 2074 | } |
no test coverage detected