Package org.springframework.rules.closure

Examples of org.springframework.rules.closure.Closure.call()


    Boolean visit(ClosureResultConstraint ofConstraint) {
        Closure f = ofConstraint.getFunction();
        if (logger.isDebugEnabled()) {
            logger.debug("Invoking function with argument " + argument);
        }
        setArgument(f.call(argument));
        return (Boolean)visitorSupport.invokeVisit(this, ofConstraint
                .getPredicate());
    }

    boolean visit(Constraint constraint) {
View Full Code Here


public class RefreshableValueHolderTests extends TestCase {
    public void testWithLazyInitTrueAndAlwaysRefreshFalse() {
        Object returnValue = new Object();

        Closure refreshFunction = (Closure) EasyMock.createMock(Closure.class);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue);
        EasyMock.replay(refreshFunction);

        RefreshableValueHolder valueHolder = new RefreshableValueHolder(refreshFunction);
        // lazy init
        assertNull(valueHolder.getValue());
View Full Code Here

    public void testWithLazyInitFalseAndAlwaysRefreshFalse() {
        Object returnValue = new Object();

        Closure refreshFunction = (Closure) EasyMock.createMock(Closure.class);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue);
        EasyMock.replay(refreshFunction);

        RefreshableValueHolder valueHolder = new RefreshableValueHolder(refreshFunction, false, false);
        assertSame(returnValue, valueHolder.getValue());
View Full Code Here

        Object returnValue1 = new Object();
        Object returnValue2 = new Object();
        Object returnValue3 = new Object();

        Closure refreshFunction = (Closure) EasyMock.createMock(Closure.class);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue1);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue2);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue3);
        EasyMock.replay(refreshFunction);

        RefreshableValueHolder valueHolder = new RefreshableValueHolder(refreshFunction, true, true);
View Full Code Here

        Object returnValue2 = new Object();
        Object returnValue3 = new Object();

        Closure refreshFunction = (Closure) EasyMock.createMock(Closure.class);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue1);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue2);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue3);
        EasyMock.replay(refreshFunction);

        RefreshableValueHolder valueHolder = new RefreshableValueHolder(refreshFunction, true, true);
        assertSame(returnValue1, valueHolder.getValue());
View Full Code Here

        Object returnValue3 = new Object();

        Closure refreshFunction = (Closure) EasyMock.createMock(Closure.class);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue1);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue2);
        EasyMock.expect(refreshFunction.call(null)).andReturn(returnValue3);
        EasyMock.replay(refreshFunction);

        RefreshableValueHolder valueHolder = new RefreshableValueHolder(refreshFunction, true, true);
        assertSame(returnValue1, valueHolder.getValue());
        assertSame(returnValue2, valueHolder.getValue());
View Full Code Here

  public Object call(Object argument) {
    Object result = argument;
    Iterator it = iterator();
    while (it.hasNext()) {
      Closure f = (Closure) it.next();
      result = f.call(result);
    }
    return result;
  }

  /**
 
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.