public class MiscUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T,S extends T> |
castList(List<T> list,
Class<S> clazz)
Casts a list containing elements of class T to a list containing elements of a subclass S.
|
static boolean |
containsInstance(List<?> list,
Object object)
Returns true if the list contains the exact instance of the specified object.
|
static boolean |
fileExists(String fileName)
Returns true if the specified file exists.
|
static Class<?>[] |
getParameterTypes(Object... parameters)
Returns an array of parameter types given an array of parameters.
|
static int |
indexOfInstance(List<?> list,
Object object)
Performs a lookup for the exact instance of an object in the list and returns its index, or
-1 if not found.
|
static <T,S extends T> |
iterableForType(Collection<T> collection,
Class<S> type)
Returns an iterable that produces only collection members of the specified type.
|
static <T,S extends T> |
iteratorForType(Collection<T> collection,
Class<S> type)
Returns a list iterator that produces only collection elements of the specified type.
|
static <T,S extends T> |
iteratorForType(Iterator<T> iterator,
Class<S> type)
Returns an iterator that returns only elements of the specified type.
|
static RuntimeException |
toUnchecked(Throwable e)
Converts a checked exception to unchecked.
|
public static boolean fileExists(String fileName)
fileName - File name.public static boolean containsInstance(List<?> list, Object object)
list - List to search.object - Object instance to locate.public static int indexOfInstance(List<?> list, Object object)
list - List to search.object - Object instance to locate.public static <T,S extends T> List<S> castList(List<T> list, Class<S> clazz)
T - Class of list elements.S - Target subclass for cast.list - List to be recast.clazz - Class to which to cast list elements.public static <T,S extends T> Iterator<S> iteratorForType(Collection<T> collection, Class<S> type)
T - Class of collection elements.S - Subclass of T to be used by iterator.collection - Collection to iterate.type - Type of element to return.public static <T,S extends T> Iterator<S> iteratorForType(Iterator<T> iterator, Class<S> type)
T - Class of collection elements.S - Subclass of T to be used by iterator.iterator - Iterator to wrap.type - Type of element to return.public static <T,S extends T> Iterable<S> iterableForType(Collection<T> collection, Class<S> type)
T - Class of collection elements.S - Subclass of T to be used by iterable.collection - Collection to iterate.type - Type of element to return.public static RuntimeException toUnchecked(Throwable e)
e - The original exception.Copyright © 2018 Regenstrief Center for Biomedical Informatics. All rights reserved.