X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fcollections%2FCollectionFilter.java;h=95155fa1382936a85da3656e6b75dcf430b795bd;hb=7d3754ca3d757ef89241cdbd679f82941e64cfc6;hp=c52bf7b15a49831e6d431db4e58bff97e3904110;hpb=54b3f906ff4cb24e0deb3714a1c31a832abe1b5d;p=utils diff --git a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java index c52bf7b1..95155fa1 100644 --- a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java +++ b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,35 @@ */ package org.wamblee.collections; -import java.util.Collection; - import org.wamblee.conditions.Condition; -public class CollectionFilter { +import java.util.Collection; - public static void filter(Collection aFrom, Collection aTo, Condition aCondition) { - for (T t: aFrom) { - if ( aCondition.matches(t)) { - aTo.add(t); - } - } - } - +/** + * Collection filter for filtering collections based on a certain condition. + * + * @author Erik Brakkee + */ +public class CollectionFilter { + /** + * Filters a collection by adding all elements in the from collection that + * satisfy a given condition to the to collection. + * + * @param + * Type of contained element. + * @param aFrom + * From container to which the condition is applied. + * @param aTo + * To container to which matching elements are added. + * @param aCondition + * Condition by which elements are matched. + */ + public static void filter(Collection aFrom, Collection aTo, + Condition aCondition) { + for (T t : aFrom) { + if (aCondition.matches(t)) { + aTo.add(t); + } + } + } }