Java Code Examples for org.apache.commons.collections.CollectionUtils.filter()

The following are Jave code examples for showing how to use filter() of the org.apache.commons.collections.CollectionUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: OrderedMigrationRunnerStrategy.java   View Source Code Vote up 7 votes
public List<MigrationTask> getRollbackCandidates(List<MigrationTask> allMigrationTasks, int[] rollbackLevels, PatchInfoStore currentPatchInfoStore) throws MigrationException
{
    validateRollbackLevel(rollbackLevels);

    int rollbackLevel = rollbackLevels[0];
    int currentPatchLevel = currentPatchInfoStore.getPatchLevel();

    if (currentPatchLevel < rollbackLevel)
    {
        throw new MigrationException(
                "The rollback patch level cannot be greater than the current patch level");
    }

    PatchRollbackPredicate rollbackPredicate = new PatchRollbackPredicate(currentPatchLevel,
            rollbackLevel);
    List<MigrationTask> migrationCandidates = new ArrayList<MigrationTask>();
    migrationCandidates.addAll(allMigrationTasks);
    CollectionUtils.filter(migrationCandidates, rollbackPredicate);
    Collections.sort(migrationCandidates);
    // need to reverse the list do we apply the rollbacks in descending
    // order
    Collections.reverse(migrationCandidates);
    return migrationCandidates;

}