Class Util
java.lang.Object
com.ibm.wala.util.collections.Util
Miscellaneous utility functions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidaddIfNotNull(T val, Collection<T> vals) static <T> voiddoForAll(Collection<T> c, ObjectVisitor<T> v) Perform an action for all elements in a collection.static <S,T> Set <T> filterByType(Iterable<S> c, Class<T> klass) Return those elements ofcthat are assignable toklass.static <T> @Nullable Tfind(Collection<T> c, Predicate<T> p) Test whether some element of the givenCollectionsatisfies the givenPredicate.static <T> booleanforAll(Collection<T> c, Predicate<T> p) Test whether all elements of the givenCollectionsatisfy the givenPredicate.static <T> booleanforSome(Collection<T> c, Predicate<T> p) Test whether some element of the givenCollectionsatisfies the givenPredicate.static longstatic <T> booleanintersecting(Set<T> s1, Set<T> s2) checks if two sets have a non-empty intersectionstatic <T,U> List <U> Map a list: generate a new list with each element mapped.static <T,U> Set <U> mapToSet(Collection<T> srcSet, Function<T, U> f) Map a set: generate a new set with each element mapped.static StringWrite object fields to stringstatic int[]realloc(int[] data, int newSize) static @Nullable StringremovePackageName(String fully_qualified_name_) Remove the package name from a fully qualified class namestatic Stringstatic StringtopLevelTypeString(String typeStr) given the name of a class C, returns the name of the top-most enclosing class of class C.
-
Field Details
-
EMPTY_BITSET
-
FULLY_QUALIFIED_NAMES
public static final boolean FULLY_QUALIFIED_NAMESGenerate strings with fully qualified names or not- See Also:
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
str
- Throws:
IllegalArgumentException- if thrown == null
-
filterByType
-
forSome
Test whether some element of the givenCollectionsatisfies the givenPredicate.- Throws:
IllegalArgumentException- if c == null
-
find
Test whether some element of the givenCollectionsatisfies the givenPredicate.- Returns:
- The first element satisfying the predicate; otherwise null.
- Throws:
IllegalArgumentException- if c == null
-
forAll
Test whether all elements of the givenCollectionsatisfy the givenPredicate.- Throws:
NullPointerException- if c == null
-
doForAll
public static <T> void doForAll(Collection<T> c, ObjectVisitor<T> v) throws IllegalArgumentException Perform an action for all elements in a collection.- Parameters:
c- the collectionv- the visitor defining the action- Throws:
IllegalArgumentException- if c == null
-
map
Map a list: generate a new list with each element mapped. The new list is always anArrayList; it would have been more precise to usereflectionto create a list of the same type as 'srcList', but reflection works really slowly in some implementations, so it's best to avoid it.- Throws:
IllegalArgumentException- if srcList == null
-
mapToSet
public static <T,U> Set<U> mapToSet(Collection<T> srcSet, Function<T, U> f) throws IllegalArgumentExceptionMap a set: generate a new set with each element mapped. The new set is always aHashSet; it would have been more precise to usereflectionto create a set of the same type as 'srcSet', but reflection works really slowly in some implementations, so it's best to avoid it.- Throws:
IllegalArgumentException- if srcSet == null
-
realloc
- Throws:
IllegalArgumentException
-
objectFieldsToString
Write object fields to string- Throws:
IllegalArgumentException- if obj == null
-
removePackageName
-
intersecting
-
topLevelTypeString
given the name of a class C, returns the name of the top-most enclosing class of class C. For example, given A$B$C, the method returns A- Returns:
- String name of top-most enclosing class
- Throws:
IllegalArgumentException- if typeStr == null
-
addIfNotNull
-
getUsedMemory
public static long getUsedMemory()- Returns:
- the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within the JVM.
-