Class Util
java.lang.Object
com.ibm.wala.util.collections.Util
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
addIfNotNull
(T val, Collection<T> vals) static <T> void
doForAll
(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 ofc
that are assignable toklass
.static <T> @Nullable T
find
(Collection<T> c, Predicate<T> p) Test whether some element of the givenCollection
satisfies the givenPredicate
.static <T> boolean
forAll
(Collection<T> c, Predicate<T> p) Test whether all elements of the givenCollection
satisfy the givenPredicate
.static <T> boolean
forSome
(Collection<T> c, Predicate<T> p) Test whether some element of the givenCollection
satisfies the givenPredicate
.static long
static <T> boolean
intersecting
(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 String
Write object fields to stringstatic int[]
realloc
(int[] data, int newSize) static @Nullable String
removePackageName
(String fully_qualified_name_) Remove the package name from a fully qualified class namestatic String
static String
topLevelTypeString
(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 givenCollection
satisfies the givenPredicate
.- Throws:
IllegalArgumentException
- if c == null
-
find
Test whether some element of the givenCollection
satisfies the givenPredicate
.- Returns:
- The first element satisfying the predicate; otherwise null.
- Throws:
IllegalArgumentException
- if c == null
-
forAll
Test whether all elements of the givenCollection
satisfy 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 usereflection
to 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 usereflection
to 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.
-