add method isElementOf()

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4199 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2011-07-01 14:38:40 +00:00
parent 17029a7110
commit 5181b6789f
1 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,7 @@
package com.ibm.wala.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@ -106,6 +107,18 @@ public abstract class Predicate<T> {
};
}
/**
* Create the predicate "is an element of c"
*/
public static <T> Predicate<T> isElementOf(final Collection<T> c) {
return new Predicate<T>() {
@Override
public boolean test(T t) {
return c.contains(t);
}
};
}
/**
* Filter a collection: generate a new list from an existing collection, consisting of the elements satisfying some predicate.
*