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:module.siadap.domain.ExceedingQuotaProposal.java

public static ExceedingQuotaProposal getQuotaProposalFor(final Unit unit, final int year, final Person person,
        final SiadapUniverse siadapUniverse, final boolean quotasUniverse) {
    SiadapYearConfiguration configuration = SiadapYearConfiguration.getSiadapYearConfiguration(year);
    if (configuration == null) {
        return null;
    }/*from   w  w  w.  j a  v a 2  s .  co  m*/

    List<ExceedingQuotaProposal> personQuotaProposal = new ArrayList<ExceedingQuotaProposal>(

            person.getExceedingQuotasProposalsSet());

    List<ExceedingQuotaProposal> exceedingQuotasProposalsForGivenYear = new ArrayList<ExceedingQuotaProposal>(
            configuration.getExceedingQuotasProposals());

    exceedingQuotasProposalsForGivenYear.retainAll(personQuotaProposal);

    List<ExceedingQuotaProposal> quotaProposalsByPredicate = getQuotaProposalsByPredicate(
            exceedingQuotasProposalsForGivenYear, new Predicate() {

                @Override
                public boolean evaluate(Object arg0) {
                    ExceedingQuotaProposal exceedingQuotaProposal = (ExceedingQuotaProposal) arg0;
                    return (exceedingQuotaProposal.getSiadapUniverse().equals(siadapUniverse)
                            && exceedingQuotaProposal.getWithinOrganizationQuotaUniverse() == quotasUniverse
                            && exceedingQuotaProposal.getUnit().equals(unit)
                            && exceedingQuotaProposal.getSuggestion().equals(person));
                }
            });

    if (quotaProposalsByPredicate.size() == 0) {
        return null;
    }
    if (quotaProposalsByPredicate.size() > 1) {
        throw new SiadapException("siadap.exceedingQuotaProposal.inconsistency.detected");
    }
    return quotaProposalsByPredicate.get(0);

}

From source file:com.projity.pm.assignment.Assignment.java

public static Predicate instanceofPredicate() {
    return new Predicate() {
        public boolean evaluate(Object arg0) {
            return arg0 instanceof Assignment;
        }//w  w  w . j  a  v  a 2 s.  com
    };
}

From source file:io.wcm.config.core.persistence.impl.ToolsConfigPagePersistenceProvider.java

@Override
@SuppressWarnings("unchecked")
public Resource getResource(Iterator<Resource> configResources) {
    if (!config.enabled() || !configResources.hasNext()) {
        return null;
    }/*from   w  ww  .j  a  va 2 s  .c o  m*/

    Iterator<Resource> configPageResources = new FilterIterator(configResources, new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            Resource resource = (Resource) object;
            return isConfigPagePath(resource.getPath());
        }
    });

    return getInheritedResourceInternal(configPageResources);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.department.ReadPersonProfessorshipsByExecutionYearAction.java

private void prepareConstants(User userView, InfoPerson infoPerson, HttpServletRequest request)
        throws FenixServiceException {

    List executionYears = ReadNotClosedExecutionYears.run();

    InfoExecutionYear infoExecutionYear = (InfoExecutionYear) CollectionUtils.find(executionYears,
            new Predicate() {
                @Override//from www .j av  a 2 s  .c  om
                public boolean evaluate(Object arg0) {
                    InfoExecutionYear infoExecutionYearElem = (InfoExecutionYear) arg0;
                    if (infoExecutionYearElem.getState().equals(PeriodState.CURRENT)) {
                        return true;
                    }
                    return false;
                }
            });
    Person person = (Person) FenixFramework.getDomainObject(infoPerson.getExternalId());
    InfoDepartment teacherDepartment = null;
    if (person.getTeacher() != null) {
        Department department = person.getTeacher().getCurrentWorkingDepartment();
        teacherDepartment = InfoDepartment.newInfoFromDomain(department);
        if (userView == null || !userView.getPerson().hasRole(RoleType.CREDITS_MANAGER)) {
            final Collection<Department> departmentList = userView.getPerson()
                    .getManageableDepartmentCreditsSet();
            request.setAttribute("isDepartmentManager",
                    (departmentList.contains(department) || department == null));
        } else {
            request.setAttribute("isDepartmentManager", Boolean.FALSE);
        }
    } else {
        request.setAttribute("isDepartmentManager", Boolean.TRUE);
    }

    request.setAttribute("teacherDepartment", teacherDepartment);
    request.setAttribute("executionYear", infoExecutionYear);
    request.setAttribute("executionYears", executionYears);
}

From source file:edu.harvard.med.screensaver.model.libraries.Library.java

/**
 * Get the copy with the given copy name
 *
 * @param copyName the copy name of the copy to get
 * @return the copy with the given copy name
 *//* w ww  . ja va 2  s . com*/
@Transient
public Copy getCopy(final String copyName) {
    return (Copy) CollectionUtils.find(_copies, new Predicate() {
        public boolean evaluate(Object e) {
            return ((Copy) e).getName().equals(copyName);
        };
    });
}

From source file:flex2.compiler.mxml.rep.MxmlDocument.java

/**
 * NOTE: suppress declaration of inherited properties
 *///from w w w  . j  av  a 2s.co m
public final Iterator<PropertyDeclaration> getDeclarationIterator() {
    final Type superType = getSuperClass();

    return new FilterIterator(declarations.values().iterator(), new Predicate() {
        public boolean evaluate(Object object) {
            return superType.getProperty(((PropertyDeclaration) object).getName()) == null;
        }
    });
}

From source file:net.sf.wickedshell.facade.descriptor.ExtensionShellDescriptor.java

/**
 * @see net.sf.wickedshell.facade.descriptor.IShellDescriptor#isAllowedForBatchList(java.io.File)
 *//*  w  ww  .  j  a  v  a 2s.  com*/
public boolean isAllowedForBatchList(final File file) {
    return CollectionUtils.exists(Arrays.asList(executableFiles), new Predicate() {
        /**
         * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
         */
        public boolean evaluate(Object object) {
            IExecutableFile executableFile = (IExecutableFile) object;
            return executableFile.isBatchFile() && file.getName().endsWith(executableFile.getExtension());
        }
    });
}

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

public List<TeacherAdviseService> getTeacherAdviseServices() {
    return (List<TeacherAdviseService>) CollectionUtils.select(getServiceItemsSet(), new Predicate() {
        @Override/*w w  w  .  j a va 2s  .c  om*/
        public boolean evaluate(Object arg0) {
            return arg0 instanceof TeacherAdviseService;
        }
    });
}

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

public Iterator getLocalFunctions() {
    return localFunctions == null ? IteratorUtils.EMPTY_ITERATOR
            : IteratorUtils.filteredIterator(localFunctions.iterator(), new Predicate() {
                public boolean evaluate(Object ob) {
                    JsUserDefinedMethod method = (JsUserDefinedMethod) ob;
                    return method.definedAsVar && !method.definedInVar;
                }//  w w  w. jav  a 2s.c o m
            });
}

From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.AccountPageController.java

@RequestMapping(value = "/profile", method = RequestMethod.GET)
@RequireHardLogIn/*from w  ww.  jav  a 2  s .  c  om*/
public String profile(final Model model) throws CMSItemNotFoundException {
    final List<TitleData> titles = userFacade.getTitles();

    final CustomerData customerData = customerFacade.getCurrentCustomer();

    if (customerData.getTitleCode() != null) {
        model.addAttribute("title", CollectionUtils.find(titles, new Predicate() {
            @Override
            public boolean evaluate(final Object object) {
                if (object instanceof TitleData) {
                    return customerData.getTitleCode().equals(((TitleData) object).getCode());
                }
                return false;
            }
        }));
    }

    model.addAttribute("customerData", customerData);

    storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE));
    model.addAttribute("breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile"));
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.Account.AccountProfilePage;
}