Package groovy.lang

Examples of groovy.lang.Closure.call()


                if (callback != null && callback instanceof Closure) {
                    Closure closure = (Closure) callback;
                    closure.setDelegate(del);
                    if (closure.getMaximumNumberOfParameters() == 1)
                        closure.call(buildAttributeNotificationPacket(note));
                    else closure.call();
                }
            }
        }

        private static Map buildAttributeNotificationPacket(AttributeChangeNotification note) {
View Full Code Here


    }
   
    public Object invoke(Object object, Object[] arguments) {
        Closure cloned = (Closure) callable.clone();
        cloned.setDelegate(object);
        return cloned.call(arguments);
    }

    public int getModifiers() {
        return Modifier.PUBLIC | Modifier.STATIC;
    }
View Full Code Here

        Map m = (Map) getDelegate();
        Closure cl = (Closure) m.get(method.getName());
        if (cl == null) {
            throw new UnsupportedOperationException();
        }
        return cl.call(args);
    }

    public String toString() {
        return DefaultGroovyMethods.toString(getDelegate());
    }
View Full Code Here

        obj.setX(newX2);
        obj.x = newX3;

        assertTrue(((Closure) obj.getProperty("x")).call() == newX2.call());
        assertTrue(((Closure) obj.getMetaClass().getAttribute(obj, "x")).call() == newX3.call());
    }

    public void testObjectSupportNameHandlingWitnClosureValuesi() {
        final Tt1cgo obj = new Tt1cgo() {
        }// repeat test with subclass
View Full Code Here

        obj.setX(newX2);
        obj.x = newX3;

        assertTrue(((Closure) obj.getProperty("x")).call() == newX2.call());
        assertTrue(((Closure) obj.getMetaClass().getAttribute(obj, "x")).call() == newX3.call());
    }

    public void testMetaClassNameHandling() {
        final Tt1gi obj = new Tt1gi()// Test class implementing GroovyObject
        final String newX = "new x";
View Full Code Here

        obj.setX(newX2);
        obj.x = newX3;

        assertTrue(((Closure) obj.getProperty("x")).call() == newX2.call());
        assertTrue(((Closure) obj.getMetaClass().getAttribute(obj, "x")).call() == newX3.call());
    }

    public void testMetaClassNameHandlingWithClosures1() {
        final Tt1cgi obj = new Tt1cgi() {
        }// repeat test with subclass
View Full Code Here

        obj.setX(newX2);
        obj.x = newX3;

        assertTrue(((Closure) obj.getProperty("x")).call() == newX2.call());
        assertTrue(((Closure) obj.getMetaClass().getAttribute(obj, "x")).call() == newX3.call());
    }
}
View Full Code Here

            // push new node on stack
            Object oldCurrent = getCurrent();
            setCurrent(node);
            // let's register the builder as the delegate
            setClosureDelegate(closure, node);
            closure.call();
            setCurrent(oldCurrent);
        }

        proxyBuilder.nodeCompleted(current, node);
        return proxyBuilder.postNodeCompletion(current, node);
View Full Code Here

            this.childPropertySetter = new ChildPropertySetter() {
                public void setChild(Object parent, Object child, String parentName,
                                     String propertyName) {
                    Closure cls = (Closure) childPropertySetter;
                    cls.setDelegate(self);
                    cls.call(new Object[]{parent, child, parentName, propertyName});
                }
            };
        } else {
            this.childPropertySetter = new DefaultChildPropertySetter();
        }
View Full Code Here

            final ObjectGraphBuilder self = this;
            this.classNameResolver = new ClassNameResolver() {
                public String resolveClassname(String classname) {
                    Closure cls = (Closure) classNameResolver;
                    cls.setDelegate(self);
                    return (String) cls.call(new Object[]{classname});
                }
            };
        } else if (classNameResolver instanceof Map) {
            Map classNameResolverOptions = (Map) classNameResolver;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.