Package groovy.lang

Examples of groovy.lang.MetaProperty


         * If the property does not exist then it will return childName
         * unchanged.
         */
        public String resolveChildRelationName( String parentName, Object parent, String childName,
                Object child ) {
            MetaProperty metaProperty = InvokerHelper.getMetaClass( parent )
                    .hasProperty( parent, childName + "s" );
            if( metaProperty != null ){
                return childName + "s";
            }
            return childName;
View Full Code Here


                    parentClass = (Class) parentContext.get( NODE_CLASS );
                }

                String propertyName = ogbuilder.relationNameResolver.resolveParentRelationName(
                        parentName, parent, childName, child );
                MetaProperty metaProperty = InvokerHelper.getMetaClass( child )
                        .hasProperty( child, propertyName );
                if( metaProperty != null ){
                    metaProperty.setProperty( child, parent );
                }
            }
        }
View Full Code Here

    }

    private <T> T  getGroovyProperty(String propName, Class<T> type, boolean onlyStatic) {
        Object value = null;
        if (GroovyObject.class.isAssignableFrom(getClazz())) {
            MetaProperty metaProperty = getMetaClass().getMetaProperty(propName);
            if (metaProperty != null) {
                int modifiers = metaProperty.getModifiers();
                if (Modifier.isStatic(modifiers)) {
                    value = metaProperty.getProperty(clazz);
                }
                else if (!onlyStatic) {
                    value = metaProperty.getProperty(getReferenceInstance());
                }
            }
        }
        return returnOnlyIfInstanceOf(value, type);
    }
View Full Code Here

        if (GrailsDomainConfigurationUtil.isConfigurational(propertyName.toString())) {
            return null;
        }

        Object val = null;
        MetaProperty mp = metaClass.getMetaProperty(propertyName.toString());
        if (mp != null) {
            val = mp.getProperty(instance);
        }
        return val;
    }
View Full Code Here

        if (propertyName instanceof CharSequence) {
            propertyName = propertyName.toString();
        }

        Object old = null;
        MetaProperty mp = metaClass.getMetaProperty((String)propertyName);
        if (mp != null && !isExcluded(mp)) {
            old = mp.getProperty(instance);
            if (propertyValue instanceof Map) {
                propertyValue = ((Map)propertyValue).get(propertyName);
            }
            mp.setProperty(instance, propertyValue);
        }
        return old;
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static <T> T getPropertyIfExists(Object instance, String property, Class<T> requiredType) {
        MetaClass metaClass = getMetaClass(instance);

        MetaProperty metaProperty = metaClass.getMetaProperty(property);
        if (metaProperty != null) {
            Object value = metaProperty.getProperty(instance);
            if (value != null && requiredType.isInstance(value)) {
                return (T) value;
            }
        }
        return null;
View Full Code Here

     * @param propertyName The name of the property to retrieve
     * @return The property value, instance of DataflowGetPropertyExpression
     */
    @Override
    public final Object getProperty(final String propertyName) {
        final MetaProperty metaProperty = getMetaClass().hasProperty(this, propertyName);
        if (metaProperty != null) {
            return metaProperty.getProperty(this);
        }
        return new DataflowGetPropertyExpression<T>(this, propertyName);
    }
View Full Code Here

                            ref.parent, ref.childName, child));

            // set parent afterwards
            String propertyName = relationNameResolver.resolveParentRelationName(ref.parentName,
                    ref.parent, ref.childName, child);
            MetaProperty metaProperty = InvokerHelper.getMetaClass(child)
                    .hasProperty(child, propertyName);
            if (metaProperty != null) {
                metaProperty.setProperty(child, ref.parent);
            }
        }
    }
View Full Code Here

        public String resolveChildRelationName(String parentName, Object parent, String childName,
                                               Object child) {
            boolean matchesIESRule = PLURAL_IES_PATTERN.matcher(childName).matches();
            String childNamePlural = matchesIESRule ? childName.substring(0, childName.length() - 1) + "ies" : childName + "s";

            MetaProperty metaProperty = InvokerHelper.getMetaClass(parent)
                    .hasProperty(parent, childNamePlural);

            return metaProperty != null ? childNamePlural : childName;
        }
View Full Code Here

                    parentName = (String) parentContext.get(NODE_NAME);
                }

                String propertyName = ogbuilder.relationNameResolver.resolveParentRelationName(
                        parentName, parent, childName, child);
                MetaProperty metaProperty = InvokerHelper.getMetaClass(child)
                        .hasProperty(child, propertyName);
                if (metaProperty != null) {
                    metaProperty.setProperty(child, parent);
                }
            }
        }
View Full Code Here

TOP

Related Classes of groovy.lang.MetaProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.