Example usage for org.apache.commons.collections CollectionUtils collect

List of usage examples for org.apache.commons.collections CollectionUtils collect

Introduction

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

Prototype

public static Collection collect(Iterator inputIterator, Transformer transformer) 

Source Link

Document

Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection.

Usage

From source file:org.metaabm.provider.MetaABMItemProvider.java

public static Collection<?> labels(final Collection<?> ids) {
    Collection<?> inputLabels = CollectionUtils.collect(ids, new org.apache.commons.collections.Transformer() {
        public Object transform(Object o) {
            return ((IID) o).getLabel();
        }/*from   w w  w  . j  av a 2  s . c om*/
    });
    return inputLabels;
}

From source file:org.metaabm.provider.MetaABMItemProvider.java

public static Collection<?> texts(final Collection<?> ids) {
    Collection<?> inputLabels = CollectionUtils.collect(ids, new org.apache.commons.collections.Transformer() {
        public Object transform(Object o) {
            MetaABMItemProvider provider = providerFor(o);
            if (provider != null) {
                return provider.getText(o);
            } else {
                return "--";
            }/*from w w w .j a  v  a2 s .  com*/
        }
    });
    return inputLabels;
}

From source file:org.metaabm.provider.MetaABMItemProvider.java

public static Collection<?> inputVals(final Collection<AInput> inputs) {
    Collection<?> inputLabels = CollectionUtils.collect(inputs,
            new org.apache.commons.collections.Transformer() {
                public Object transform(Object o) {
                    return ((AInput) o).getValue();
                }/*from  ww w  .j  a  v  a2  s . co m*/
            });
    return inputLabels;
}

From source file:org.metaabm.provider.MetaABMItemProvider.java

public static Collection<?> ids(final Collection<?> ids) {
    return CollectionUtils.collect(ids, new org.apache.commons.collections.Transformer() {
        public Object transform(Object o) {
            return ((IID) o).getID();
        }/* w w  w . j a  v  a2s.  co m*/
    });
}

From source file:org.metaabm.provider.MetaABMItemProvider.java

public static final Collection<?> idsCaps(final Collection<?> ids) {

    return CollectionUtils.collect(ids, new org.apache.commons.collections.Transformer() {
        public Object transform(Object o) {
            if (o instanceof IID) {
                return StringUtils.capitalize(((IID) o).getID());
            } else if (o instanceof AInput && ((AInput) o).getValue() != null) {
                return StringUtils.capitalize(((AInput) o).getValue().getID());
            } else {
                return "null";
            }/* w  w w . java 2  s. c  o m*/
        }
    });
}

From source file:org.mifos.framework.components.batchjobs.helpers.BranchReportLoanArrearsAgingHelperIntegrationTest.java

private void assertLoanArrearsAgingPopulated(Set<BranchReportLoanArrearsAgingBO> loanArrearsAgingSummaries) {
    Assert.assertNotNull(loanArrearsAgingSummaries);
    Collection foundPeriods = CollectionUtils.collect(loanArrearsAgingSummaries, new Transformer() {
        @Override/*from  www  .jav a2 s  .c om*/
        public Object transform(Object input) {
            return ((BranchReportLoanArrearsAgingBO) input).getAgingPeriod();
        }
    });

    assertSameCollections(expectedPeriods, foundPeriods);
}

From source file:org.mifos.framework.components.batchjobs.helpers.BranchReportStaffingLevelSummaryHelperIntegrationTest.java

private void assertStaffingLevelSummaries(BranchReportBO branchReport) {
    Set<BranchReportStaffingLevelSummaryBO> staffingLevelSummaries = branchReport.getStaffingLevelSummaries();
    Assert.assertEquals(1, staffingLevelSummaries.size());
    Collection retrievedRolenames = CollectionUtils.collect(staffingLevelSummaries, new Transformer() {
        @Override// w  w w .  j a va  2  s  .com
        public Object transform(Object input) {
            return ((BranchReportStaffingLevelSummaryBO) input).getTitleName();
        }
    });
    Assert.assertEquals(1, retrievedRolenames.size());
    Assert.assertTrue(retrievedRolenames.contains(BranchReportStaffingLevelSummaryBO.TOTAL_STAFF_ROLE_NAME));
}

From source file:org.mifos.reports.business.service.HOCashConfirmationConfigService.java

@SuppressWarnings("unchecked")
private List<Short> getProductIds(String productIdKey) throws ServiceException {
    return (List<Short>) CollectionUtils.collect(getPropertyValues(productIdKey), TRANSFORM_STRING_TO_SHORT);
}

From source file:org.mifos.reports.business.validator.AbstractReportParameterValidator.java

@SuppressWarnings("unchecked")
public AbstractReportParameterValidator(List<String> applicableFilePaths) {
    this.applicableFilePaths = (List<String>) CollectionUtils.collect(applicableFilePaths, new Transformer() {
        @Override//from ww w  .j a v  a 2 s.  co  m
        public Object transform(Object input) {
            return ((String) input).trim();
        }
    });
}

From source file:org.mifos.reports.cashconfirmationreport.BranchCashConfirmationInfoBO.java

public static List<BranchCashConfirmationInfoBO> createIssuesBO(List<String> productOfferingNames,
        final MifosCurrency currency) {
    return (List<BranchCashConfirmationInfoBO>) CollectionUtils.collect(productOfferingNames,
            new Transformer() {
                @Override/*from www  .  ja  v a  2 s . co  m*/
                public Object transform(Object input) {
                    return new BranchCashConfirmationIssueBO((String) input, MoneyUtils.zero(currency));
                }
            });
}