public class BasicUtil
extends java.lang.Object
Constructor and Description |
---|
BasicUtil() |
Modifier and Type | Method and Description |
---|---|
static <K,V> boolean |
containsKeySafe(java.util.Map<K,V> map,
K key)
Type-safe wrapper for
Map.containsKey(Object) method. |
static <V> boolean |
containsSafe(java.util.Collection<V> collection,
V value)
Type-safe wrapper for
Collection.contains(Object) method. |
static <T> boolean |
eq(T left,
T right)
Convenience wrapper around
Object.equals(Object) method that allows
both left and right to be null. |
static <K,V> V |
getSafe(java.util.Map<K,V> map,
K key)
Type-safe wrapper for
Map.get(Object) method. |
static java.lang.String |
getStacktraceString(java.lang.Exception exception)
Takes stacktrace string out of exception.
|
static int |
hashCode(java.lang.Object obj)
Convenience wrapper around
Object.hashCode() method that allows
object to be null. |
static java.lang.String |
join(java.lang.Iterable<? extends java.lang.String> components,
java.lang.String separator)
Implementation of traditional join operation.
|
static <V> boolean |
removeSafe(java.util.Collection<V> collection,
V value)
Type-safe wrapper for
Collection.remove(Object) method. |
static <K,V> V |
removeSafe(java.util.Map<K,V> map,
K key)
Type-safe wrapper for
Map.remove(Object) method. |
static <T> T[] |
toArray(java.util.Collection<? extends T> collection,
java.lang.Class<T> clazz)
Convenient method wrapping
Collection.toArray() . |
public static <T> T[] toArray(java.util.Collection<? extends T> collection, java.lang.Class<T> clazz)
Collection.toArray()
. It creates array of proper
length of proper type.public static <K,V> V removeSafe(java.util.Map<K,V> map, K key)
Map.remove(Object)
method. It restricts
type of key and makes sure that you do not try to remove key of wrong
type.public static <K,V> V getSafe(java.util.Map<K,V> map, K key)
Map.get(Object)
method. It restricts
type of key and makes sure that you do not try to get by key of wrong
type.public static <K,V> boolean containsKeySafe(java.util.Map<K,V> map, K key)
Map.containsKey(Object)
method. It restricts
type of a value and makes sure that you do not call method for the value
wrong type.public static <V> boolean containsSafe(java.util.Collection<V> collection, V value)
Collection.contains(Object)
method. It restricts
type of a value and makes sure that you do not call method for the value
wrong type.public static <V> boolean removeSafe(java.util.Collection<V> collection, V value)
Collection.remove(Object)
method. It restricts
type of a value and makes sure that you do not call method for the value
wrong type.public static <T> boolean eq(T left, T right)
Object.equals(Object)
method that allows
both left and right to be null.public static int hashCode(java.lang.Object obj)
Object.hashCode()
method that allows
object to be null.public static java.lang.String join(java.lang.Iterable<? extends java.lang.String> components, java.lang.String separator)
public static java.lang.String getStacktraceString(java.lang.Exception exception)
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.