public class Util extends Object
| Modifier and Type | Field and Description |
|---|---|
static BitSet |
EMPTY_BITSET
The empty
BitSet. |
static boolean |
FULLY_QUALIFIED_NAMES
Generate strings with fully qualified names or not
|
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static <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 of
c that are assignable to klass. |
static <T> T |
find(Collection<T> c,
Predicate<T> p)
Test whether some element of the given
Collection satisfies the given Predicate. |
static <T> boolean |
forAll(Collection<T> c,
Predicate<T> p)
Test whether all elements of the given
Collection satisfy the given Predicate. |
static <T> boolean |
forSome(Collection<T> c,
Predicate<T> p)
Test whether some element of the given
Collection satisfies the given Predicate. |
static long |
getUsedMemory() |
static <T> boolean |
intersecting(Set<T> s1,
Set<T> s2)
checks if two sets have a non-empty intersection
|
static <T,U> List<U> |
map(List<T> srcList,
Function<T,U> f)
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 |
objectFieldsToString(Object obj)
Write object fields to string
|
static int[] |
realloc(int[] data,
int newSize) |
static String |
removePackageName(String fully_qualified_name_)
Remove the package name from a fully qualified class name
|
static String |
str(Throwable thrown)
|
static String |
topLevelTypeString(String typeStr)
given the name of a class C, returns the name of the top-most enclosing class of class C.
|
public static final boolean FULLY_QUALIFIED_NAMES
public static String str(Throwable thrown) throws IllegalArgumentException
IllegalArgumentException - if thrown == nullpublic static <S,T> Set<T> filterByType(Iterable<S> c, Class<T> klass)
c that are assignable to klass.public static <T> boolean forSome(Collection<T> c, Predicate<T> p) throws IllegalArgumentException
Collection satisfies the given Predicate.IllegalArgumentException - if c == nullpublic static <T> T find(Collection<T> c, Predicate<T> p) throws IllegalArgumentException
Collection satisfies the given Predicate.IllegalArgumentException - if c == nullpublic static <T> boolean forAll(Collection<T> c, Predicate<T> p) throws NullPointerException
Collection satisfy the given Predicate.NullPointerException - if c == nullpublic static <T> void doForAll(Collection<T> c, ObjectVisitor<T> v) throws IllegalArgumentException
c - the collectionv - the visitor defining the actionIllegalArgumentException - if c == nullpublic static <T,U> List<U> map(List<T> srcList, Function<T,U> f) throws IllegalArgumentException
ArrayList; it would have been more precise to use reflection 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.IllegalArgumentException - if srcList == nullpublic static <T,U> Set<U> mapToSet(Collection<T> srcSet, Function<T,U> f) throws IllegalArgumentException
HashSet; it would have been more precise to use reflection 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.IllegalArgumentException - if srcSet == nullpublic static int[] realloc(int[] data,
int newSize)
throws IllegalArgumentException
IllegalArgumentExceptionpublic static String objectFieldsToString(Object obj) throws IllegalArgumentException
IllegalArgumentException - if obj == nullpublic static String removePackageName(String fully_qualified_name_)
public static <T> boolean intersecting(Set<T> s1, Set<T> s2)
true if the sets intersect; false otherwisepublic static String topLevelTypeString(String typeStr) throws IllegalArgumentException
IllegalArgumentException - if typeStr == nullpublic static <T> void addIfNotNull(T val,
Collection<T> vals)
public static long getUsedMemory()