Example usage for org.apache.commons.collections Predicate evaluate

List of usage examples for org.apache.commons.collections Predicate evaluate

Introduction

In this page you can find the example usage for org.apache.commons.collections Predicate evaluate.

Prototype

public boolean evaluate(T object);

Source Link

Document

Use the specified parameter to perform a test that returns true or false.

Usage

From source file:meta.predicado.base.IsModuloConsultaResidualDisplay.java

@Override
public boolean evaluate(Object object) {
    if (super.evaluate(object)) {
    } else {//from   w  ww.ja  v  a  2  s.  c o m
        return false;
    }
    Predicate predicate;
    List<? extends ModuloBase> siblings = _modulo.getSiblings();
    for (ModuloBase sibling : siblings) {
        predicate = sibling.getPagePredicate();
        if (predicate == null || predicate.evaluate(object)) {
            return false;
        }
    }
    return true;
}

From source file:lt.kape1395.jenkins.ditz.model.IssueOpenPredicateTest.java

/**
 * If issue was not closed but removed, it stays with the active status,
 * but statusChange is recorded correctly. To determine, if issue is active,
 * one should look at both statuses.//from  ww  w. j a  v  a2  s.  com
 */
@Test
public void testPreviouslyDeletedIssues() {
    Predicate p = new IssueOpenPredicate();

    Issue i;
    i = new Issue("a", "b", "c", Status.CLOSED, "d");
    i.setStatusChange(StatusChange.CLOSED);
    assertThat(p.evaluate(i), is(false));

    i = new Issue("a", "b", "c", Status.IN_PROGRESS, "d");
    i.setStatusChange(StatusChange.CLOSED);
    assertThat(p.evaluate(i), is(false));

    i = new Issue("a", "b", "c", Status.PAUSED, "d");
    i.setStatusChange(StatusChange.CLOSED);
    assertThat(p.evaluate(i), is(false));

    i = new Issue("a", "b", "c", Status.UNSTARTED, "d");
    i.setStatusChange(StatusChange.CLOSED);
    assertThat(p.evaluate(i), is(false));

    i = new Issue("a", "b", "c", "some", "d");
    i.setStatusChange(StatusChange.CLOSED);
    assertThat(p.evaluate(i), is(false));

    i = new Issue("a", "b", "c", Status.IN_PROGRESS, "d");
    i.setStatusChange(StatusChange.NEW);
    assertThat(p.evaluate(i), is(true));

}

From source file:com.mindquarry.persistence.mock.SessionMock.java

private boolean matchProperties(Object entity, Map<String, Predicate> properties) {

    for (Entry<String, Predicate> entry : properties.entrySet()) {

        String propertyValue = propertyValue(entity, entry.getKey());
        Predicate propertyPrediate = entry.getValue();

        if (!propertyPrediate.evaluate(propertyValue))
            return false;
    }//from  w w  w . j  a  v  a2  s. co m
    return true;
}

From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.service.AliquotIdBreakdownReportServiceFastTest.java

@Test
public void testProcessAliquotIdBreakdownPredicatesTrue() throws Exception {
    Method m = service.getClass().getDeclaredMethod("processAliquotIdBreakdownPredicates", String.class,
            String.class, String.class);
    m.setAccessible(true);//w ww.j av  a 2  s .c  o  m
    Predicate p = (Predicate) m.invoke(service, "aliquotId", "mock", "blah");
    assertNotNull(p);
    assertTrue(p.evaluate(makeMockAliquotIdBreakdown().get(0)));
}

From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.service.AliquotIdBreakdownReportServiceFastTest.java

@Test
public void testProcessAliquotIdBreakdownPredicatesFalse() throws Exception {
    Method m = service.getClass().getDeclaredMethod("processAliquotIdBreakdownPredicates", String.class,
            String.class, String.class);
    m.setAccessible(true);//from ww  w  .j ava 2s  .  c  om
    Predicate p = (Predicate) m.invoke(service, "aliquotId", "hum", "blah");
    assertNotNull(p);
    assertFalse(p.evaluate(makeMockAliquotIdBreakdown().get(0)));
}

From source file:edu.uci.ics.jung.utils.SubsetManager.java

/**
 * Adds the edge whose event this is to all appropriate subsets.
 *///from w w  w. j av  a  2s .  c o  m
public void edgeAdded(GraphEvent event) {
    ArchetypeEdge e = (ArchetypeEdge) event.getGraphElement();
    Map eMap = getEdgeMap();
    for (Iterator iter = eMap.keySet().iterator(); iter.hasNext();) {
        //            EdgePredicate p = (EdgePredicate)iter.next();
        Predicate p = (Predicate) iter.next();
        //            if (p.evaluateEdge(e))
        if (p.evaluate(e)) {
            Set s = (Set) eMap.get(p);
            s.add(e);
        }
    }
}

From source file:edu.uci.ics.jung.utils.SubsetManager.java

/**
 * Adds the vertex whose event this is to all appropriate subsets.
 *///from   w ww.jav  a  2s .co  m
public void vertexAdded(GraphEvent event) {
    ArchetypeVertex v = (ArchetypeVertex) event.getGraphElement();
    Map vMap = getVertexMap();
    for (Iterator iter = vMap.keySet().iterator(); iter.hasNext();) {
        //            VertexPredicate p = (VertexPredicate)iter.next();
        Predicate p = (Predicate) iter.next();
        //            if (p.evaluateVertex(v))
        if (p.evaluate(v)) {
            Set s = (Set) vMap.get(p);
            s.add(v);
        }
    }
}

From source file:module.siadap.domain.wrappers.PartyWrapper.java

protected List<Unit> getChildUnits(Predicate predicate, AccountabilityType... types) {
    return getParty().getChildAccountabilityStream()
            .filter(a -> match(a, types) && (predicate == null || predicate.evaluate(a))).map(a -> a.getChild())
            .filter(p -> p.isUnit()).map(p -> (Unit) p).collect(Collectors.toList());
}

From source file:module.siadap.domain.wrappers.PartyWrapper.java

protected List<Accountability> getChildAccountabilityTypes(Predicate predicate, AccountabilityType... types) {
    return getParty().getChildAccountabilityStream()
            .filter(a -> match(a, types) && (predicate == null || predicate.evaluate(a)))
            .collect(Collectors.toList());
}

From source file:module.siadap.domain.wrappers.PartyWrapper.java

protected List<Accountability> getParentAccountabilityTypes(Predicate predicate, AccountabilityType... types) {
    return getParty().getParentAccountabilityStream()
            .filter(a -> match(a, types) && (predicate == null || predicate.evaluate(a)))
            .collect(Collectors.toList());
}