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.mailtracking.domain.CorrespondenceEntry.java

public Document getMainDocument() {
    return (Document) CollectionUtils.find(this.getDocumentsSet(), new Predicate() {

        @Override/*from  www . j  ava2 s  . com*/
        public boolean evaluate(Object arg0) {
            return !((Document) arg0).isDocumentDeleted()
                    && DocumentType.MAIN_DOCUMENT.equals(((Document) arg0).getType());
        }

    });
}

From source file:net.sourceforge.fenixedu.domain.student.importation.DgesStudentImportationProcess.java

public static List<DgesStudentImportationProcess> readDoneJobs(final ExecutionYear executionYear) {
    List<DgesStudentImportationProcess> jobList = new ArrayList<DgesStudentImportationProcess>();

    CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() {

        @Override/*  www .ja v a2  s.  c o m*/
        public boolean evaluate(Object arg0) {
            return (arg0 instanceof DgesStudentImportationProcess) && ((QueueJob) arg0).getDone();
        }
    }, jobList);

    return jobList;
}

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityApplicationProcess.java

public List<ErasmusCandidacyProcessReport> getPendingReports() {
    List<ErasmusCandidacyProcessReport> jobList = new ArrayList<ErasmusCandidacyProcessReport>();

    CollectionUtils.select(getErasmusCandidacyProcessReportsSet(), new Predicate() {

        @Override//  w w  w .j  a va  2 s . c om
        public boolean evaluate(Object arg0) {
            return ((QueueJob) arg0).getIsNotDoneAndNotCancelled();
        }
    }, jobList);

    return jobList;
}

From source file:edu.kit.dama.rest.staging.types.TransferTaskContainer.java

/**
 * Set the file tree. This method is used internally in case of a download.
 * Keep in mind, that the file tree set for transfer task containers has to
 * offer a defined structure. It is recommended to perform file tree
 * creation and modifications only by the static methods provided by this
 * class./*  ww  w .  ja  v  a 2 s.c o m*/
 *
 * @param pTree The tree to set.
 */
public final void setFileTree(IFileTree pTree) {
    if (pTree == null) {
        throw new IllegalArgumentException("Argument pTree must not be null");
    }

    if (!(pTree instanceof FileTreeImpl)) {
        throw new IllegalArgumentException(
                "Argument pTree must be an instance of edu.kit.dama.staging.entities.FileTreeImpl");
    }

    IDataOrganizationNode dataNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_DATA_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName());
                }
            });

    if (dataNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_DATA_FOLDER_NAME + "' node found.");
    }
    IDataOrganizationNode generatedNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_GENERATED_FOLDER_NAME
                            .equals(((IDataOrganizationNode) o).getName());
                }
            });
    if (generatedNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_GENERATED_FOLDER_NAME + "' node found.");
    }
    IDataOrganizationNode settingsNode = (IDataOrganizationNode) CollectionUtils
            .find(pTree.getRootNode().getChildren(), new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    return Constants.STAGING_SETTINGS_FOLDER_NAME.equals(((IDataOrganizationNode) o).getName());
                }
            });
    if (settingsNode == null) {
        throw new IllegalArgumentException("Argument pTree has an invalid structure. No '"
                + Constants.STAGING_SETTINGS_FOLDER_NAME + "' node found.");
    }

    tree = (FileTreeImpl) pTree;
}

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

/**
 *
 *//*from   w w w.j av a  2  s .  com*/
public Iterator getInheritingStyleNameIterator() {
    final Styles styles = typeTable.getStyles();
    return new FilterIterator(styles.getStyleNames(), new Predicate() {
        public boolean evaluate(Object obj) {
            return styles.isInheritingStyle((String) obj);
        }
    });
}

From source file:net.sourceforge.fenixedu.domain.student.importation.DgesStudentImportationProcess.java

public static List<DgesStudentImportationProcess> readPendingJobs(final ExecutionYear executionYear) {
    List<DgesStudentImportationProcess> jobList = new ArrayList<DgesStudentImportationProcess>();

    CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() {

        @Override//from   w  w  w . jav  a 2 s  . c  o m
        public boolean evaluate(Object arg0) {
            return (arg0 instanceof DgesStudentImportationProcess)
                    && ((QueueJob) arg0).getIsNotDoneAndNotCancelled();
        }
    }, jobList);

    return jobList;
}

From source file:com.algoTrader.CriteriaSearchProperties.java

/**
 * Gets the type of the embedded value given the <code>ownerType</code>
 * and <code>name</code>/*ww  w  . j ava  2  s.  com*/
 *
 * @param properties Map contains the Collection of properties given the ownerType Class
 * @param ownerType the owner of the association.
 * @param name the name of the association end to find.
 * @return the type of the association end.
 */
public static Class getPropertyType(final Map properties, final Class ownerType, final String name) {
    final Collection ends = (Collection) properties.get(ownerType);
    final PropertyType type = (PropertyType) CollectionUtils.find(ends, new Predicate() {
        public boolean evaluate(final Object object) {
            return ((PropertyType) object).name.equals(name);
        }
    });
    return type != null ? type.type : null;
}

From source file:edu.kit.dama.staging.services.impl.download.DownloadInformationServiceLocal.java

private Collection<StagingProcessor> mergeStagingProcessors(Collection<StagingProcessor> assignedProcessors,
        Collection<StagingProcessor> defaultProcessors) {
    LOGGER.debug("Checking default staging processors.");
    if (assignedProcessors == null || assignedProcessors.isEmpty()) {
        //return defaultProcessors (can't be null, so we do not have to check result)
        LOGGER.debug("No staging processors assigned, using only default processors.");
        return defaultProcessors;
    }/*from  w  w  w.j  a  v a2 s.  c  o  m*/

    LOGGER.debug("Adding all assigned processors to result list.");
    List<StagingProcessor> result = new ArrayList<>(assignedProcessors);

    if (defaultProcessors == null || defaultProcessors.isEmpty()) {
        //return assigned processors
        LOGGER.debug("No default processors provided, using only assigned processors.");
        return result;
    }

    LOGGER.debug("Merging {} existing and {} default processor(s)", assignedProcessors.size(),
            defaultProcessors.size());
    for (final StagingProcessor processor : defaultProcessors) {
        LOGGER.debug("Searching for default processor with id {}", processor.getUniqueIdentifier());
        StagingProcessor exists = (StagingProcessor) CollectionUtils.find(assignedProcessors, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                return Long.compare(((StagingProcessor) o).getId(), processor.getId()) == 0;
            }
        });

        if (exists == null) {
            LOGGER.debug("Default processor with id {} is not assigned, yet. Adding it.", processor.getId());
            //add as it not exists
            result.add(processor);
        }
    }
    return result;
}

From source file:net.shopxx.entity.Goods.java

@Transient
public boolean getIsStockAlert() {
    return CollectionUtils.exists(getProducts(), new Predicate() {
        public boolean evaluate(Object object) {
            Product product = (Product) object;
            return product != null && product.getIsStockAlert();
        }/*w ww  . ja  v  a2  s  . co m*/
    });
}

From source file:com.kcs.service.impl.GenerateXmlOtherServiceImpl.java

private List<Datasetswa> filterChildSwa(final Datasetswa main, List<Datasetswa> childList) {
    List<Datasetswa> result = new ArrayList<Datasetswa>();
    final Predicate predicate = new Predicate() {
        @Override//  w ww .ja  v a 2 s.c  o  m
        public boolean evaluate(Object o) {
            if (Utility.isNotNull(o)) {
                Datasetswa child = (Datasetswa) o;
                boolean result = (objEquals(main.getCustCode(), child.getCustCode())
                        && objEquals(main.getSeq(), child.getSeq())
                        && objEquals(main.getSysCode(), child.getSysCode()));
                return result;
            }
            return false;
        }
    };
    result = (List<Datasetswa>) CollectionUtils.select(childList, predicate);
    return result;
}