Package groovy.lang

Examples of groovy.lang.MetaClass


        return createCallConstructorSite(callSite, (Class) receiver, args).callConstructor(receiver, args);
    }

    private static CallSite createCallStaticSite(CallSite callSite, Class receiver, Object[] args) {
        CallSite site;
        MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
        if (metaClass instanceof MetaClassImpl) {
            site = ((MetaClassImpl)metaClass).createStaticSite(callSite, args);
        }
        else
          site = new StaticMetaClassSite(callSite, metaClass);
View Full Code Here


        replaceCallSite(callSite, site);
        return site;
    }

    private static CallSite createCallConstructorSite(CallSite callSite, Class receiver, Object[] args) {
       MetaClass metaClass = InvokerHelper.getMetaClass(receiver);

       CallSite site;
       if (metaClass instanceof MetaClassImpl) {
           site = ((MetaClassImpl)metaClass).createConstructorSite(callSite, args);
       }
View Full Code Here

    private static CallSite createCallCurrentSite(CallSite callSite, GroovyObject receiver, Object[] args, Class sender) {
        CallSite site;
        if (receiver instanceof GroovyInterceptable)
          site = new PogoInterceptableSite(callSite);
        else {
            MetaClass metaClass = receiver.getMetaClass();
            if (receiver.getClass() != metaClass.getTheClass() && !metaClass.getTheClass().isInterface()) {
                site = new PogoInterceptableSite(callSite);
            }
            else
                if (metaClass instanceof MetaClassImpl) {
                    site = ((MetaClassImpl)metaClass).createPogoCallCurrentSite(callSite, sender, args);
View Full Code Here

    // for MetaClassImpl we try to pick meta method,
    // otherwise or if method doesn't exist we make call via POJO meta class
    private static CallSite createPojoSite(CallSite callSite, Object receiver, Object[] args) {
        final Class klazz = receiver.getClass();
        MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
        if (!GroovyCategorySupport.hasCategoryInCurrentThread() && metaClass instanceof MetaClassImpl) {
            final MetaClassImpl mci = (MetaClassImpl) metaClass;
            final ClassInfo info = mci.getTheCachedClass().classInfo;
            if (info.hasPerInstanceMetaClasses()) {
                return new PerInstancePojoMetaClassSite(callSite, info);
View Full Code Here

    private static CallSite createPogoSite(CallSite callSite, Object receiver, Object[] args) {
        if (receiver instanceof GroovyInterceptable)
          return new PogoInterceptableSite(callSite);

        MetaClass metaClass = ((GroovyObject)receiver).getMetaClass();

        if (metaClass instanceof MetaClassImpl) {
            return ((MetaClassImpl)metaClass).createPogoCallSite(callSite, args);
        }
View Full Code Here

    int i = 0;
    for (Object arg : args) {
      argTypes[i++] = arg == null ? null : arg.getClass();
    }

    MetaClass metaClass = target instanceof Class ? InvokerHelper.getMetaClass((Class) target) : InvokerHelper.getMetaClass(target);

    MetaMethod metaMethod = metaClass.pickMethod(method, argTypes);
    if (metaMethod == null) {
      return false;
    }

    Class returnType = metaMethod.getReturnType();
View Full Code Here

public class Util {
   
    private static final Object[] EMPTY_OBJECT_ARRAY = {};
   
    static public ReadOnlyProperty getJavaFXProperty(Object instance, String propertyName) {
        MetaClass mc = InvokerHelper.getMetaClass(instance);
        String fxPropertyAccessor = propertyName + "Property";
        if (!mc.respondsTo(instance, fxPropertyAccessor, null).isEmpty()) {
            return (ReadOnlyProperty)InvokerHelper.invokeMethod(instance, fxPropertyAccessor, null);
        }else {
            return null;
        }
    }
View Full Code Here

        }
    }
   
    static public boolean isJavaBeanPropertyWritable(Object instance, String propertyName) {
       
        MetaClass mc = InvokerHelper.getMetaClass(instance);
        MetaProperty metaProperty = mc.getMetaProperty(propertyName);
        if(metaProperty != null) {
            String setterName = MetaProperty.getSetterName(propertyName);
            return !mc.respondsTo(instance, setterName, new Class[]{metaProperty.getType()}).isEmpty();
        } else if(instance instanceof Script) {
            return ((Script)instance).getProperty(propertyName) != null;
        }
        return false;
    }
View Full Code Here

            return getJavaBeanFXReadOnlyProperty(instance, propertyName);
        }
    }
   
    static public ReadOnlyProperty getJavaBeanFXReadOnlyProperty(Object instance, String propertyName) throws NoSuchMethodException {
        MetaClass mc = InvokerHelper.getMetaClass(instance);
        MetaProperty metaProperty = mc.getMetaProperty(propertyName);
        if(metaProperty != null) {
            Class type = metaProperty.getType();
            if(type == Boolean.class || type == Boolean.TYPE) {
                ReadOnlyJavaBeanBooleanPropertyBuilder builder = ReadOnlyJavaBeanBooleanPropertyBuilder.create();
                builder.bean(instance);
View Full Code Here

            return null;
        }

    }
    static public Property getJavaBeanFXWritableProperty(Object instance, String propertyName) throws NoSuchMethodException {
        MetaClass mc = InvokerHelper.getMetaClass(instance);
        //Object a = mc.getAttribute(instance, propertyName);
        MetaProperty metaProperty = mc.getMetaProperty(propertyName);
        if(metaProperty != null) {
            Class type = metaProperty.getType();
            if(type == Boolean.class || type == Boolean.TYPE) {
                JavaBeanBooleanPropertyBuilder builder = JavaBeanBooleanPropertyBuilder.create();
                builder.bean(instance);
View Full Code Here

TOP

Related Classes of groovy.lang.MetaClass

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.