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

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

Introduction

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

Prototype

Predicate

Source Link

Usage

From source file:net.sourceforge.fenixedu.domain.residence.StudentsPerformanceReport.java

public static List<StudentsPerformanceReport> readNotGeneratedReports(
        final ExecutionSemester executionSemester) {
    List<StudentsPerformanceReport> generatedReports = new ArrayList<StudentsPerformanceReport>();

    CollectionUtils.select(executionSemester.getStudentsPerformanceReportsSet(), new Predicate() {

        @Override/*from ww  w  .  ja v  a  2s  .  co m*/
        public boolean evaluate(Object arg0) {
            return !((StudentsPerformanceReport) arg0).getDone();
        }

    }, generatedReports);

    return generatedReports;
}

From source file:com.projity.grouping.core.summaries.DeepChildSearcher.java

public static Object searchForUniqueId(NodeModel nodeModel, final long uniqueId) {
    return search(nodeModel, new Predicate() {
        public boolean evaluate(Object arg0) {
            return ((HasKey) arg0).getUniqueId() == uniqueId;
        }/* www  .jav a 2 s . co m*/
    });
}

From source file:gr.omadak.leviathan.asp.objects.GenericClass.java

public Iterator getMethods() {
    return members == null ? IteratorUtils.EMPTY_ITERATOR
            : IteratorUtils.filteredIterator(members.values().iterator(), new Predicate() {
                public boolean evaluate(Object obj) {
                    return obj instanceof Method;
                }//from   w w w  . ja va2s  .c o m
            });
}

From source file:edu.kit.dama.rest.dataworkflow.test.DataWorkflowTestService.java

private DataWorkflowTask getTaskById(final Long id) {
    DataWorkflowTask result = (DataWorkflowTask) CollectionUtils.find(tasks, new Predicate() {

        @Override/* ww  w  . j  a  v a  2 s .c  o m*/
        public boolean evaluate(Object o) {
            return Objects.equals(((DataWorkflowTask) o).getId(), id);
        }
    });

    if (result == null) {
        throw new WebApplicationException(404);
    }
    return result;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.student.enrollment.bolonha.ErasmusBolonhaStudentEnrolmentLayout.java

private boolean contains(List<CurricularCourse> curricularCourseList,
        final IDegreeModuleToEvaluate degreeModule) {
    if (!CurricularCourse.class.isAssignableFrom(degreeModule.getClass())) {
        return false;
    }//from w w  w . ja  v  a2 s. c  o m

    return CollectionUtils.find(curricularCourseList, new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            return ((CurricularCourse) degreeModule).isEquivalent((CurricularCourse) arg0);
        }
    }) != null;
}

From source file:com.ebay.cloud.cms.dal.search.impl.criteria.EqualityCriteriaHandler.java

private boolean evalNotEq(final List<?> fieldValues, final Object criteriaValue) {
    if (fieldValues == null || fieldValues.isEmpty()) {
        return true;
    }//from   www.ja  v  a2s .co  m

    Predicate notEqPre = new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            if (criteriaValue instanceof Long && object instanceof Integer) {
                Long value = Long.valueOf((Integer) object);
                return !criteriaValue.equals(value);
            } else {
                return !criteriaValue.equals(object);
            }
        }
    };
    return CollectionUtils.exists(fieldValues, notEqPre);
}

From source file:net.sourceforge.fenixedu.domain.teacher.TeacherService.java

public List<DegreeTeachingService> getDegreeTeachingServiceByProfessorship(final Professorship professorship) {
    return (List<DegreeTeachingService>) CollectionUtils.select(getDegreeTeachingServices(), new Predicate() {
        @Override/*from  w ww . j  av  a 2  s.  c  o m*/
        public boolean evaluate(Object arg0) {
            DegreeTeachingService degreeTeachingService = (DegreeTeachingService) arg0;
            return degreeTeachingService.getProfessorship() == professorship;
        }
    });
}

From source file:io.neba.core.resourcemodels.metadata.ModelMetadataConsolePlugin.java

private void provideStatisticsOfModel(final String typeName, HttpServletResponse res) {
    ResourceModelMetaData metaData = (ResourceModelMetaData) find(this.modelMetaDataRegistrar.get(),
            new Predicate() {
                @Override// w  w  w  .  j av  a  2 s .c om
                public boolean evaluate(Object object) {
                    return ((ResourceModelMetaData) object).getTypeName().equals(typeName);
                }
            });

    if (metaData != null) {
        ResourceModelStatistics statistics = metaData.getStatistics();

        Map<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("age", statistics.getSince());
        data.put("mappableFields", metaData.getMappableFields().length);
        data.put("instantiations", statistics.getInstantiations());
        data.put("mappings", statistics.getNumberOfMappings());
        data.put("averageMappingDuration", statistics.getAverageMappingDuration());
        data.put("maximumMappingDuration", statistics.getMaximumMappingDuration());
        data.put("minimumMappingDuration", statistics.getMinimumMappingDuration());
        data.put("mappingDurationMedian", statistics.getMappingDurationMedian());

        int[] mappingDurationFrequencies = statistics.getMappingDurationFrequencies();
        int[] intervalBoundaries = statistics.getMappingDurationIntervalBoundaries();

        try {
            JSONObject json = new JSONObject(data);
            JSONObject durationFrequencies = new JSONObject();

            int leftBoundary = 0;
            for (int i = 0; i < mappingDurationFrequencies.length; ++i) {
                durationFrequencies.put("[" + leftBoundary + ", " + intervalBoundaries[i] + ")",
                        mappingDurationFrequencies[i]);
                leftBoundary = intervalBoundaries[i];
            }

            json.put("mappingDurationFrequencies", durationFrequencies);

            prepareJsonResponse(res);
            json.write(res.getWriter());
        } catch (Exception e) {
            throw new RuntimeException("Unable to write the resource model JSON data.", e);
        }
    }
}

From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUserService.java

protected Set<PrincipalGroupModel> removeUsergroupFromGroups(final String usergroup,
        final Set<PrincipalGroupModel> groups) {
    final Set<PrincipalGroupModel> groupsWithoutUsergroup = new HashSet<PrincipalGroupModel>(groups);
    CollectionUtils.filter(groupsWithoutUsergroup, new Predicate() {
        @Override//from ww w .  j a  v  a 2s  .c o m
        public boolean evaluate(final Object object) {
            final PrincipalGroupModel group = (PrincipalGroupModel) object;
            return !StringUtils.equals(usergroup, group.getUid());
        }
    });
    return groupsWithoutUsergroup;
}

From source file:com.vmware.upgrade.progress.DefaultExecutionStateAggregatorTest.java

private Set<ExecutionState> computeStateTransitions(final ExecutionState state) {
    EnumSet<ExecutionState> states = EnumSet.allOf(ExecutionState.class);
    CollectionUtils.filter(states, new Predicate() {
        @Override/*from  w  w w.j a  v  a  2  s  . co  m*/
        public boolean evaluate(Object object) {
            return state.canTransitionTo((ExecutionState) object);
        }
    });
    return states;
}