Example usage for org.apache.commons.collections Closure execute

List of usage examples for org.apache.commons.collections Closure execute

Introduction

In this page you can find the example usage for org.apache.commons.collections Closure execute.

Prototype

public void execute(Object input);

Source Link

Document

Performs an action on the specified input object.

Usage

From source file:ClosureExample.java

public static void main(String args[]) {
    Closure ifClosure = ClosureUtils.ifClosure(PredicateUtils.equalPredicate(new Integer(20)),
            ClosureUtils.nopClosure(), ClosureUtils.exceptionClosure());
    ifClosure.execute(new Integer(20));
    //      ifClosure.execute(new Integer(30));
}

From source file:com.switchfly.inputvalidation.CobrandNameValidationStrategyTest.java

public static void assertThrowException(Class<? extends Throwable> exceptionClass, Closure closure) {
    try {//from  ww  w . j a v  a  2  s .c o m
        closure.execute(null);
        fail("Should throw " + exceptionClass.getName());
    } catch (Exception e) {
        assertTrue(exceptionClass.isAssignableFrom(e.getClass()));
    }
}

From source file:com.projity.util.DataUtils.java

public static void forAllDo(Iterator i, Closure closure) {
    while (i.hasNext())
        closure.execute(i.next());
}

From source file:com.projity.util.ArrayUtils.java

public static void forAllDo(Object[] array, Closure c) {
    for (int i = 0; i < array.length; i++) {
        c.execute(array[i]);
    }/*from   w ww . j  av  a  2s.c  o  m*/
}

From source file:gov.nih.nci.caarray.security.SecurityPolicy.java

private static void applyTransformations(Set<SecurityPolicy> policies, Object entity,
        PropertyAccessor propAccessor) throws IllegalAccessException, InvocationTargetException {
    Transformer transformer = getPropertyTransformer(policies, propAccessor);
    if (transformer != null) {
        Object originalVal = propAccessor.get(entity);
        Object transformedVal = transformer.transform(originalVal);
        propAccessor.set(entity, transformedVal);
    }/*w w  w  . ja va  2 s .com*/
    Closure mutator = getPropertyMutator(policies, propAccessor);
    if (mutator != null) {
        mutator.execute(propAccessor.get(entity));
    }
}

From source file:com.projity.dialog.XbsDependencyDialog.java

public static boolean doDialog(XbsDependencyDialog dialog, GraphicDependency dependency,
        Closure removeClosure) {
    dialog.setDependency(dependency);/*  w  w w .jav  a 2s. co m*/
    boolean result;
    if (result = dialog.doModal()) {
        if (dialog.remove)
            removeClosure.execute(null);
    }
    dialog.dependency = null;
    return result;
}

From source file:com.cyberway.issue.crawler.datamodel.ServerCache.java

public void forAllHostsDo(Closure c) {
    for (String host : hosts.keySet()) {
        c.execute(hosts.get(host));
    }
}

From source file:com.projity.pm.graphic.model.event.CacheEvent.java

public void forIntervals(Closure f) {
    if (type == NODES_REMOVED) {
        for (ListIterator i = intervals.listIterator(intervals.size()); i.hasPrevious();)
            f.execute(i.previous());
    } else {// w w  w .j a  v  a 2 s  . c om
        for (ListIterator i = intervals.listIterator(); i.hasNext();)
            f.execute(i.next());
    }
}

From source file:com.projity.job.JobQueue.java

public boolean executeCriticalSectionClosure(Job job, Closure c, Object arg) {
    synchronized (criticalSectionMutex) {
        if (criticalSectionOwner == job) {
            c.execute(arg);
            return true;
        } else {//from www . ja  va  2s . c om
            System.out.println(job.getName() + " can execute, lost critical section");
            return false;
        }
    }
}

From source file:com.projity.pm.graphic.frames.workspace.NamedFrame.java

private void fire(NamedFrameEvent evt, Closure closure) {
    Object[] listeners = listenerList.getListenerList();
    // Each listener occupies two elements - the first is the listener class
    // and the second is the listener instance
    for (int i = 0; i < listeners.length; i += 2) {
        if (listeners[i] == NamedFrameListener.class) {
            closure.execute(((NamedFrameListener) listeners[i + 1]));
        }/*from  www .ja v  a  2  s  .co m*/
    }
}