public abstract class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static List |
copyList(List src,
Class type)
Returns a copy of the given
src list and checks if the
elements of the list are an instance of the given type. |
static List |
copyList(List src,
Class[] types)
Returns a copy of the given
src list and checks if the
elements of the list are an instance of one of the given types
. |
static List |
copyList(List list,
Class[] types,
String name,
boolean maybeNull,
boolean maybeEmpty)
Returns a copy of the given
src list and checks if the
elements of the list are an instance of one of the given types
. |
static List |
copyList(List list,
Class type,
String name,
boolean maybeNull,
boolean maybeEmpty)
Returns a copy of the given
src list and checks if the
elements of the list are an instance of the given type. |
static Object |
exceptionChainingJDK13(Object superMessage,
Throwable cause) |
static String |
randomId(int length)
Creates a random id value string containing the characters from 'A-Z' and
the digits from '0-9' of the given length.
|
public static List copyList(List src, Class type) throws ClassCastException
src list and checks if the
elements of the list are an instance of the given type.src - the source list (may be null)type - the type the copied element must be an instance ofsrc list (may be empty but never
null)ClassCastException - if an element of the list is not an instance of typepublic static List copyList(List src, Class[] types) throws ClassCastException
src list and checks if the
elements of the list are an instance of one of the given types
.src - the source list (may be null)types - the type the copied element must be an instance ofsrc list (may be empty but never
null)ClassCastException - if an element of the list is not an instance of on of the given
typespublic static List copyList(List list, Class type, String name, boolean maybeNull, boolean maybeEmpty)
src list and checks if the
elements of the list are an instance of the given type.
If src is null and maybeNull is
false an NullPointerException is thrown.
If src is empty and maybeEmpty is
false an IllegalArgumentException is thrown.
If one of the list's elements is not of type type a
ClassCastException is thrown.
list - the source listtype - the list's elements typename - the name of the list (used in exception messages)maybeNull - may the src list be null?maybeEmpty - may the src list be empty?NullPointerException - if list is null and
maybeNull is falseIllegalArgumentException - if list is empty and
maybeEmpty is falseClassCastException - if list contains any elements that are not an instance
of the given typepublic static List copyList(List list, Class[] types, String name, boolean maybeNull, boolean maybeEmpty) throws ClassCastException
src list and checks if the
elements of the list are an instance of one of the given types
.
If src is null and maybeNull is
false an NullPointerException is thrown.
If src is empty and maybeEmpty is
false an IllegalArgumentException is thrown.
If one of the list's elements is not of one of the given types
a ClassCastException is thrown.
list - the source listtypes - the list's elements typesname - the name of the list (used in exception messages)maybeNull - may the src list be null?maybeEmpty - may the src list be empty?NullPointerException - if list is null and
maybeNull is falseIllegalArgumentException - if list is empty and
maybeEmpty is falseClassCastException - if list contains any elements that are not an instance
of one of the given typespublic static String randomId(int length)
length - the length of the id value string© 2002-2005 IAIK, © 2004, 2006 - 2019 Stiftung SIC