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:com.google.mr4c.content.ContentTypes.java

public static Collection<String> filterByContentType(Collection<String> fileNames, final String contentType,
        final boolean canonicalOnly) {
    return CollectionUtils.predicatedCollection(fileNames, new Predicate() {
        public boolean evaluate(Object obj) {
            String name = (String) obj;
            if (canonicalOnly) {
                String suffix = ContentTypes.getSuffix(contentType);
                return FilenameUtils.isExtension(name, suffix);
            } else {
                Collection<String> suffixes = ContentTypes.getSuffixes(contentType);
                return FilenameUtils.isExtension(name, suffixes);
            }//from   ww  w.  j a  v a 2s .  co  m
        }
    });
}

From source file:com.tesora.dve.charset.NativeCollationCatalogImpl.java

@Override
public NativeCollation findDefaultCollationForCharSet(String charsetName) {
    final List<NativeCollation> collations = collationsByCharsetName
            .get(charsetName.toUpperCase(Locale.ENGLISH));
    if (collations == null) {
        return null;
    }//from  ww  w  .j  av a2 s.  co m

    final NativeCollation defaultCollation = (NativeCollation) CollectionUtils.find(collations,
            new Predicate() {
                @Override
                public boolean evaluate(Object arg0) {
                    if (arg0 instanceof NativeCollation) {
                        final NativeCollation nc = (NativeCollation) arg0;
                        return nc.isDefault();
                    }
                    return false;
                }
            });

    if (defaultCollation == null) {
        throw new PECodingException("No default collation found for character set '" + charsetName + "'");
    }

    return defaultCollation;
}

From source file:net.sourceforge.fenixedu.domain.phd.PhdProgramFocusArea.java

public static PhdProgramFocusArea readPhdProgramFocusAreaByName(final String name) {
    return (PhdProgramFocusArea) CollectionUtils.find(Bennu.getInstance().getPhdProgramFocusAreasSet(),
            new Predicate() {

                @Override//from   w ww  .  j  av a  2s  .c  o  m
                public boolean evaluate(Object arg0) {
                    return name.equals(((PhdProgramFocusArea) arg0).getName().getContent());
                }

            });
}

From source file:de.hybris.platform.acceleratorservices.sitemap.renderer.SiteMapContext.java

public void init(final CMSSiteModel site, final SiteMapPageEnum siteMapPageEnum) {
    final String currentUrlEncodingPattern = getUrlEncoderService().getCurrentUrlEncodingPattern();
    this.put(BASE_URL,
            getSiteBaseUrlResolutionService().getWebsiteUrlForSite(site, currentUrlEncodingPattern, false, ""));
    this.put(MEDIA_URL, getSiteBaseUrlResolutionService().getMediaUrlForSite(site, false, ""));

    final Collection<SiteMapPageModel> siteMapPages = site.getSiteMapConfig().getSiteMapPages();
    final SiteMapPageModel siteMapPageModel = (SiteMapPageModel) CollectionUtils.find(siteMapPages,
            new Predicate() {
                @Override/*from  w  w  w .j a  va  2  s .  com*/
                public boolean evaluate(final Object o) {
                    return ((SiteMapPageModel) o).getCode().equals(siteMapPageEnum);
                }
            });

    if (siteMapPageModel != null) {
        this.put(CHANGE_FREQ, siteMapPageModel.getFrequency().getCode());
        this.put(PRIORITY, siteMapPageModel.getPriority());
    } else {
        this.put(CHANGE_FREQ, SiteMapChangeFrequencyEnum.DAILY.getCode());
        this.put(PRIORITY, Double.valueOf(0.5D));
    }
}

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

@Override
public List<PendingUUID> getFilteredPendingUUIDList(final List<PendingUUID> list, final List<String> bcr,
        final List<String> center, final String batch, final String plateId) {
    final StringBuilder strLog = new StringBuilder();
    strLog.append("Filter used: Bcr:").append(bcr).append(" Center:").append(center).append(" Batch:")
            .append(batch).append(" Plate Id:").append(plateId);
    logger.debug(strLog);//ww w  . j  av a 2s .  c  om
    if (bcr == null && center == null && batch == null && plateId == null) {
        return list;
    }
    final List<Predicate> pUUIDPredicateList = new LinkedList<Predicate>();
    pUUIDPredicateList.add(new Predicate() {
        public boolean evaluate(Object o) {
            if (batch == null || "".equals(batch)) {
                return true;
            }
            return batch.equals(((PendingUUID) o).getBatchNumber());
        }
    });
    pUUIDPredicateList.add(new Predicate() {
        public boolean evaluate(Object o) {
            if (plateId == null || "".equals(plateId)) {
                return true;
            }
            return plateId.equals(((PendingUUID) o).getPlateId());
        }
    });
    commonService.genORPredicateList(PendingUUID.class, pUUIDPredicateList, bcr, BCR);
    commonService.genORPredicateList(PendingUUID.class, pUUIDPredicateList, center, CENTER);
    final Predicate pendingUUIDPredicates = PredicateUtils.allPredicate(pUUIDPredicateList);
    final List<PendingUUID> fList = (List<PendingUUID>) CollectionUtils.select(list, pendingUUIDPredicates);
    return fList;
}

From source file:net.sourceforge.fenixedu.domain.accounting.events.serviceRequests.PartialRegistrationRegimeRequestEvent.java

@Override
public PostingRule getPostingRule() {
    Set<PostingRule> activePostingRules = getAdministrativeOffice().getServiceAgreementTemplate()
            .getActivePostingRules(getExecutionYear().getBeginDateYearMonthDay().toDateTimeAtMidnight());

    return (PostingRule) CollectionUtils.find(activePostingRules, new Predicate() {

        @Override// w ww. ja va  2s.c  om
        public boolean evaluate(Object arg0) {
            return ((PostingRule) arg0).getEventType().equals(getEventType())
                    && ((PartialRegistrationRegimeRequestPR) arg0).getExecutionYear()
                            .equals(getAcademicServiceRequest().getExecutionYear());
        }

    });
}

From source file:net.shopxx.controller.admin.ParameterController.java

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(Parameter parameter, RedirectAttributes redirectAttributes) {
    CollectionUtils.filter(parameter.getNames(), new AndPredicate(new UniquePredicate(), new Predicate() {
        public boolean evaluate(Object object) {
            String name = (String) object;
            return StringUtils.isNotEmpty(name);
        }//from  ww  w  .j  a v a2 s  .  c  o  m
    }));
    if (!isValid(parameter, BaseEntity.Update.class)) {
        return ERROR_VIEW;
    }
    parameterService.update(parameter, "productCategory");
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:list.jhtml";
}

From source file:com.sammyun.service.impl.PluginServiceImpl.java

public List<MessagePushPlugin> getMessagePushPlugins(final boolean isEnabled) {
    List<MessagePushPlugin> result = new ArrayList<MessagePushPlugin>();
    CollectionUtils.select(messagePlugins, new Predicate() {
        public boolean evaluate(Object object) {
            MessagePushPlugin messagePushPlugin = (MessagePushPlugin) object;
            return messagePushPlugin.getIsEnabled() == isEnabled;
        }/*from  w  w  w .j  a  va 2 s.  c om*/
    }, result);
    Collections.sort(result);
    return result;
}

From source file:edu.kit.rest.usergroupmanagement.test.UserGroupTestService.java

private UserData findUserByUserId(final String userId) {
    return (UserData) CollectionUtils.find(users, new Predicate() {

        @Override//from  w  w w. j a  v  a  2s  . c o m
        public boolean evaluate(Object o) {
            return Objects.equals(((UserData) o).getDistinguishedName(), userId);
        }
    });
}

From source file:edu.scripps.fl.pubchem.db.PCAssayPanel.java

@Transient
public XRef getGene() {
    List<PCAssayXRef> list = new ArrayList();
    CollectionUtils.select(assay.getAssayXRefs(), new Predicate() {
        public boolean evaluate(Object object) {
            PCAssayXRef xref = (PCAssayXRef) object;
            if (xref.getPanel() != null)
                if (xref.getPanel().getPanelNumber() == getPanelNumber() && xref.getXRef() != null
                        && "gene".equals(xref.getXRef().getDatabase()))
                    return true;
            return false;
        }//from w ww . j a va2 s .co  m
    }, list);
    return list.size() > 0 ? list.get(0).getXRef() : null;
}