Class Shorts
- Direct Known Subclasses:
BasicTestUtils
A single wildcard static import
(import static org.apache.juneau.commons.utils.Shorts.*;) exposes the entire
short-name vocabulary. Almost every method here is a one-line delegation to a canonical,
fully-descriptive method on a domain class — behavior is identical to calling the canonical
method directly — and each such alias documents its target via an @see tag. Canonical
implementations live in ObjectUtils, StringUtils, CollectionUtils,
ClassUtils, ThrowableUtils, IoUtils, FileUtils,
PredicateUtils, SystemUtils, DateUtils, and
ReflectionUtils.
Documented exception: the terse exception factories (rex/brex/
iaex/isex/uoex/uoroex/ioex/exex) are
self-contained — they construct the exception directly rather than delegating to a domain
class — so that the domain *Utils classes can stay Shorts-free (they use the
package-private Exceptions helper instead). These are the only methods in this class
with no @see tag, apart from the argument/state checks described next.
Argument and state checks: the req* family (req, reqnn,
reqnb, reqnns, reqt, reqcat; throwing
IllegalArgumentException) and the chk* family (chk, chknn;
throwing IllegalStateException) are also self-contained: Shorts holds their
canonical implementations. Because of that, the domain
*Utils classes may import Shorts for req*/chk* calls. That is the
only relaxation: a domain class may use the self-contained members of Shorts (exception
factories, req*, chk*) but never a delegating alias, because that alias would
call back into a domain class.
Example:
Disjointness invariant: no Shorts alias name is identical to the canonical
(full) method name of any method in any domain class. This lets a developer wildcard-import
Shorts.* alongside any single domain *Utils.* with zero method-name
collisions.
This class is the replacement for the former Utils grab-bag (now deleted): callers
replace import static ...utils.Utils.* with import static ...utils.Shorts.*.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShorts()Constructor — this class is meant to be subclassed. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]a(T... x) Creates an array from the specified elements.static <E> E[][]a2(E[]... v) Creates a 2-dimensional array from the specified rows.static <E> List<E>Adds the specified elements to the given list and returns it.static booleanand(boolean... v) Returnstrue if all of the specified booleans aretrue .static booleanany(boolean... v) Returnstrue if any of the specified booleans aretrue .static Object[]Creates anObject[]from the specified elements.static <E> EReturns the element at the specified index of a list (null-safe).static booleanConverts the specified object to a boolean.static StringReturns a blank (single-space) string if the specified string is null, else the string.static boolean[]booleans(boolean... v) Creates aboolean[]from the specified values.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith an associated class and formatted message.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith a formatted message.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwrapping a cause.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith a cause, associated class, and formatted message.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith a cause and formatted message.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith a cause, associated class, and formatted message.static BeanRuntimeExceptionCreates aBeanRuntimeExceptionwith an associated class and formatted message.static booleanbtw(int n, int lo, int hi) Returnstrue if the specified integer is within the inclusive range.static byte[]bytes(int... v) Creates abyte[]from the specified int values.static <T> TCasts the specified object to the specified type (null-safe).static <T> TCasts the specified throwable to the specified type, wrapping if necessary.static char[]chars(char... v) Creates achar[]from the specified values.static voidThrows anIllegalStateExceptionif the specified expression isfalse .static <T> TThrows anIllegalStateExceptionif the specified object isnull .static intCompares two objects for order (null-safe).static StringReturns the fully-qualified class name of the specified object (null-safe).static StringReturns the simple class name of the specified object (null-safe).static StringReturns the qualified simple class name of the specified object (includes enclosing classes).static booleanReturnstrue if the string contains the specified substring (null-safe).static boolean[]cp(boolean[] v) Makes a copy of the specified array.static byte[]cp(byte[] v) Makes a copy of the specified array.static char[]cp(char[] v) Makes a copy of the specified array.static double[]cp(double[] v) Makes a copy of the specified array.static float[]cp(float[] v) Makes a copy of the specified array.static int[]cp(int[] v) Makes a copy of the specified array.static long[]cp(long[] v) Makes a copy of the specified array.static short[]cp(short[] v) Makes a copy of the specified array.static <E> Collection<E>cp(Collection<E> v) Creates a new collection from the specified collection.static <E> List<E>Returns a mutable copy of the specified list.static <E> List<E>Makes a deep copy of the specified list, transforming each value.static <E> List<E>Makes a deep copy of the specified list, transforming each value using the specified list factory.static <K,V> Map<K, V> Creates a new map from the specified map.static <K,V> Map<K, V> Makes a deep copy of the specified map, transforming each value.static <K,V> Map<K, V> Makes a deep copy of the specified map, transforming each value using the specified map factory.static <E> Set<E>Creates a new set from the specified set.static <E> Set<E>Makes a deep copy of the specified set, transforming each value.static <E> Set<E>Makes a deep copy of the specified set, transforming each value using the specified set factory.static <T> T[]cp(T[] v) Makes a copy of the specified array.static double[]doubles(double... v) Creates adouble[]from the specified values.static StringReturns an empty string if the specified object is null, else its string form.static StringReturns an empty string if the specified string is null, else the string.static booleanReturnstrue if the two strings are equal, optionally ignoring case.static <T> booleaneq(T a, T b) Returnstrue if the two objects are equal (null-safe).static <T,U> boolean eq(T a, U b, BiPredicate<T, U> t) Returnstrue if the two objects are equal using the specified equality test.static <T> booleaneqa(T a, T... b) Returnstrue if the first object equals any of the remaining objects.static booleanReturnstrue if the two objects are equal ignoring case (via their string forms).static booleanReturnstrue if the two strings are equal ignoring case (null-safe).static booleanReturnstrue if the string ends with the specified suffix (null-safe).static ExecutableExceptionCreates anExecutableExceptionwith a formatted message.static ExecutableExceptionCreates anExecutableExceptionwrapping a cause.static ExecutableExceptionCreates anExecutableExceptionwith a cause and formatted message.static StringFormats a message using printf-style (%s/%d/…) placeholders.Searches the causal chain of the specified throwable for a cause of the specified type.static float[]floats(float... v) Creates afloat[]from the specified values.static StringReturns the first non-blank string from the specified values.static StringReturns the first non-empty string from the specified values.Returns a supplier that lazily formats a printf-style message (deferred untilSupplier.get()).static StringReturns the stack trace of the specified throwable as a string.static <T extends Comparable<T>>
booleangt(T a, T b) Returnstrue if the first comparable is greater than the second.static <T extends Throwable>
TReturns the first cause of the specified type from the throwable's causal chain.static <T extends Comparable<T>>
booleangte(T a, T b) Returnstrue if the first comparable is greater than or equal to the second.static intComputes a hash code over the specified values.static <T> Set<T>hs(T... v) Creates a mutableHashSetfrom the specified elements.static IllegalArgumentExceptionCreates anIllegalArgumentExceptionwith a formatted message.static IllegalArgumentExceptionCreates anIllegalArgumentExceptionwrapping a cause.static IllegalArgumentExceptionCreates anIllegalArgumentExceptionwith a cause and formatted message.static booleanReturnstrue if the specified string is null, empty, or whitespace-only.static StringReturns the system identity string of the specified object.static booleanie(CharSequence s) Returnstrue if the specified character sequence is null or empty.static booleanReturnstrue if the specified object is null or empty (string/collection/map/array).static booleanie(Collection<?> c) Returnstrue if the specified collection is null or empty.static booleanReturnstrue if the specified map is null or empty.static <K,V> Map<K, V> im()Creates an unmodifiable, empty map.static <K,V> Map<K, V> im(K k1, V v1) Creates an unmodifiable map with 1 entry.static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2) Creates an unmodifiable map with 2 entries.static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3) Creates an unmodifiable map with 3 entries.static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) Creates an unmodifiable map with 4 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) Creates an unmodifiable map with 5 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Creates an unmodifiable map with 6 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Creates an unmodifiable map with 7 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Creates an unmodifiable map with 8 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Creates an unmodifiable map with 9 entries (keys/values in alternating order).static <K,V> Map<K, V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Creates an unmodifiable map with 10 entries (keys/values in alternating order).static booleanReturnstrue if the specified string contains non-whitespace content.static booleanine(CharSequence s) Returnstrue if the specified character sequence is not null and not empty.static booleanReturnstrue if the specified object is not null and not empty.static booleanine(Collection<?> c) Returnstrue if the specified collection is not null and not empty.static booleanReturnstrue if the specified map is not null and not empty.static int[]ints(int... v) Creates anint[]from the specified values.static IOExceptionCreates anIOExceptionwith a formatted message.static IOExceptionCreates anIOExceptionwrapping a cause.static IOExceptionCreates anIOExceptionwith a cause and formatted message.static IllegalStateExceptionCreates anIllegalStateExceptionwith a formatted message.static IllegalStateExceptionCreates anIllegalStateExceptionwrapping a cause.static IllegalStateExceptionCreates anIllegalStateExceptionwith a cause and formatted message.static <E> Set<E>ist(E... v) Creates an unmodifiable set from the specified elements.static StringConcatenates the specified strings.static <T> List<T>l(T... x) Creates a modifiableArrayListfrom the specified elements.static <E> Lists<E>Creates a newListsbuilder for the specified element type.static StringConverts the specified string to lower case (null-safe).static StringConverts the specified string to lower case usingLocale.ROOT(null-safe).static intReturns the length/size of the specified object (array/collection/map/string).static <T> List<T>ll(T... v) Creates a mutableLinkedListfrom the specified elements.static StringReturns the localized message of the specified throwable.static long[]longs(long... v) Creates along[]from the specified values.static <E> List<E>los(int n) Creates a modifiable, emptyArrayListpresized to the specified capacity.static <T extends Comparable<T>>
booleanlt(T a, T b) Returnstrue if the first comparable is less than the second.static <T extends Comparable<T>>
booleanlte(T a, T b) Returnstrue if the first comparable is less than or equal to the second.static <K,V> Map<K, V> m()Creates an empty modifiable map.static <K,V> Map<K, V> m(K k1, V v1) Creates a modifiable map with 1 entry.static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2) Creates a modifiable map with 2 entries.static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3) Creates a modifiable map with 3 entries.static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) Creates a modifiable map with 4 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) Creates a modifiable map with 5 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Creates a modifiable map with 6 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Creates a modifiable map with 7 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Creates a modifiable map with 8 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Creates a modifiable map with 9 entries (keys/values in alternating order).static <K,V> Map<K, V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Creates a modifiable map with 10 entries (keys/values in alternating order).static <K,V> Maps<K, V> mb()Creates a newMapsbuilder.static <K,V> Maps<K, V> Creates a newMapsbuilder for the specified key and value types.static StringFormats a message usingMessageFormat-style {0} placeholders.Returns a supplier that lazily formats a MessageFormat-style message (deferred untilSupplier.get()).static booleanReturnstrue if the specified array is null or any of its elements are null.static <T> booleann(T v) Returnstrue if the specified value is null.static <T> T[]Returnsnull typed as an array of the specified component type.static <T> booleanneq(T a, T b) Returnstrue if the two objects are not equal (null-safe).static <T,U> boolean neq(T a, U b, BiPredicate<T, U> t) Returnstrue if the two objects are not equal using the specified equality test.static booleanReturnstrue if the two strings are not equal ignoring case (null-safe).static StringReturns null if the specified string is empty, else the string.static <E> List<E>Returns null if the specified list is empty, else the list.static <K,V> Map<K, V> Returns null if the specified map is empty, else the map.static <E> Set<E>Returns null if the specified set is empty, else the set.static <T,R> R Null-safe map: returnsnull when the value isnull , else the mapper's result.static <T extends Number>
booleannm1(T v) Returnstrue if the specified number is non-null and not equal to -1.static booleanReturnstrue if the specified object is not null.static booleannot(boolean v) Returns the logical negation of the specified boolean.static <T> Optional<T>Returns the element at the specified index of a list as anOptional.static <T> Optional<T>o(T t) Wraps the specified value in anOptional.static <T> Optional<T>oe()Returns an emptyOptional.static <T> TReturns the value of the optional, or the specified default if empty.static <T> Tor(T... t) Returns the first non-null argument, or null if all are null.static voidRuns the specified snippet, silently swallowing any thrown exception.static StringReturns a human-readable string representation of the specified object.static voidThrows anIllegalArgumentExceptionif the specified expression isfalse .static <E> Class<E>[]Throws anIllegalArgumentExceptionif any element of the specified class array is not a subtype of the specified type.static StringThrows anIllegalArgumentExceptionif the specified string argument isnull or blank.static voidThrows anIllegalArgumentExceptionif either of the specified arguments isnull .static voidThrows anIllegalArgumentExceptionif any of the three specified arguments isnull .static voidreqnn(String name1, Object o1, String name2, Object o2, String name3, Object o3, String name4, Object o4) Throws anIllegalArgumentExceptionif any of the four specified arguments isnull .static voidreqnn(String name1, Object o1, String name2, Object o2, String name3, Object o3, String name4, Object o4, String name5, Object o5) Throws anIllegalArgumentExceptionif any of the five specified arguments isnull .static <T> TThrows anIllegalArgumentExceptionif the specified argument isnull .static <T,C extends Collection<T>>
CThrows anIllegalArgumentExceptionif the specified collection argument or any of its elements isnull .static <T> T[]Throws anIllegalArgumentExceptionif the specified array argument or any of its elements isnull .static <T> TThrows anIllegalArgumentExceptionif the specified object is not an instance of the specified type.static <T> Treqt(Class<T> type, Object o, Supplier<? extends RuntimeException> exceptionSupplier) Throws the exception provided by the supplier if the specified object is not an instance of the specified type.static RuntimeExceptionCreates aRuntimeExceptionwith a formatted message.static RuntimeExceptionCreates aRuntimeExceptionwrapping a cause.static RuntimeExceptionCreates aRuntimeExceptionwith a cause and formatted message.static <T> Trnn(T v) Returns the specified value, throwingNullPointerExceptionif it is null.static StringConverts the specified object to its string representation (null-safe).static booleansa(Constructor<?> c) Makes the specified constructor accessible.static booleanMakes the specified field accessible.static booleanMakes the specified method accessible.static StringBuilderCreates a newStringBuilderinitialized with the stringified form of the specified value.static StringBuilderCreates a newStringBuilderwith the stringified form of each specified value appended in order.static short[]shorts(int... v) Creates ashort[]from the specified int values.static <E> SortedSet<E>ss(E... v) Creates a sortedTreeSetfrom the specified elements (null values filtered out).static <T> Set<T>st(T... v) Creates a modifiable, insertion-orderedLinkedHashSetfrom the specified elements.static <E> Sets<E>Creates a newSetsbuilder for the specified element type.static booleanReturnstrue if the string starts with the specified prefix (null-safe).static intReturns the size of the specified object (string/collection/map/array).static <T> booleanTests the specified value against the given predicate (null-safe).static <E> List<E>tl(Collection<E> v) Creates a modifiableArrayListcopy of the specified collection.static StringTrims leading/trailing whitespace from the specified string (null-safe).static <E> Set<E>ts(Collection<E> v) Creates a modifiableLinkedHashSetcopy of the specified collection.static <T> List<T>Returns an unmodifiable view of the specified list.static <K,V> Map<K, V> Returns an unmodifiable view of the specified map.static <T> Set<T>Returns an unmodifiable view of the specified set.static <T> SortedSet<T>Returns an unmodifiable view of the specified sorted set.static StringConverts the specified string to upper case (null-safe).static StringConverts the specified string to upper case usingLocale.ROOT(null-safe).uoex()Creates anUnsupportedOperationExceptionwith the message "Not supported."Creates anUnsupportedOperationExceptionwith a formatted message.Creates anUnsupportedOperationExceptionwrapping a cause.Creates anUnsupportedOperationExceptionwith a cause and formatted message.uoroex()Creates anUnsupportedOperationExceptionwith the message "Object is read only."
-
Constructor Details
-
Shorts
protected Shorts()Constructor — this class is meant to be subclassed.
-
-
Method Details
-
nn
Returnstrue if the specified object is not null.- Parameters:
o- The object to check.- Returns:
true if the object is not null.- See Also:
-
n
Returnstrue if the specified value is null.- Type Parameters:
T- The value type.- Parameters:
v- The value to check.- Returns:
true if the value is null.- See Also:
-
n
Returnstrue if the specified array is null or any of its elements are null.- Parameters:
v- The values to check.- Returns:
true if the array is null or contains a null element.- See Also:
-
eq
Returnstrue if the two objects are equal (null-safe).- Type Parameters:
T- The object type.- Parameters:
a- The first object.b- The second object.- Returns:
true if the objects are equal.- See Also:
-
eq
Returnstrue if the two strings are equal, optionally ignoring case.- Parameters:
ci- Iftrue , comparison is case-insensitive.a- The first string.b- The second string.- Returns:
true if the strings are equal.- See Also:
-
eq
Returnstrue if the two objects are equal using the specified equality test.- Type Parameters:
T- The first object type.U- The second object type.- Parameters:
a- The first object.b- The second object.t- The equality predicate.- Returns:
true if the objects are equal per the predicate.- See Also:
-
eqa
Returnstrue if the first object equals any of the remaining objects.- Type Parameters:
T- The object type.- Parameters:
a- The object to look for.b- The candidate values.- Returns:
true if a match is found.- See Also:
-
eqic
Returnstrue if the two objects are equal ignoring case (via their string forms).- Parameters:
a- The first object.b- The second object.- Returns:
true if the objects are equal ignoring case.- See Also:
-
neq
Returnstrue if the two objects are not equal (null-safe).- Type Parameters:
T- The object type.- Parameters:
a- The first object.b- The second object.- Returns:
true if the objects are not equal.- See Also:
-
neq
Returnstrue if the two objects are not equal using the specified equality test.- Type Parameters:
T- The first object type.U- The second object type.- Parameters:
a- The first object.b- The second object.t- The equality predicate.- Returns:
true if the objects are not equal per the predicate.- See Also:
-
cmp
Compares two objects for order (null-safe).- Parameters:
a- The first object.b- The second object.- Returns:
- A negative, zero, or positive integer as
ais less than, equal to, or greater thanb. - See Also:
-
lt
Returnstrue if the first comparable is less than the second.- Type Parameters:
T- The comparable type.- Parameters:
a- The first value.b- The second value.- Returns:
true ifa < b.- See Also:
-
lte
Returnstrue if the first comparable is less than or equal to the second.- Type Parameters:
T- The comparable type.- Parameters:
a- The first value.b- The second value.- Returns:
true ifa <= b.- See Also:
-
gt
Returnstrue if the first comparable is greater than the second.- Type Parameters:
T- The comparable type.- Parameters:
a- The first value.b- The second value.- Returns:
true ifa > b.- See Also:
-
gte
Returnstrue if the first comparable is greater than or equal to the second.- Type Parameters:
T- The comparable type.- Parameters:
a- The first value.b- The second value.- Returns:
true ifa >= b.- See Also:
-
or
Returns the first non-null argument, or null if all are null.- Type Parameters:
T- The value type.- Parameters:
t- The candidate values in priority order.- Returns:
- The first non-null value, or null.
- See Also:
-
any
Returnstrue if any of the specified booleans aretrue .- Parameters:
v- The booleans to check.- Returns:
true if at least one value istrue .- See Also:
-
nm
Null-safe map: returnsnull when the value isnull , else the mapper's result.Replaces
x == null ? null : f(x) . This is notor(Object...), which returns its first non-null argument (sox , notf(x) ) and evaluatesf(x) even whenx is null.- Type Parameters:
T- The value type.R- The result type.- Parameters:
v- The value to map. Can benull .m- The mapping function; never called withnull .- Returns:
- The mapped value, or
null . - See Also:
-
and
Returnstrue if all of the specified booleans aretrue .- Parameters:
v- The booleans to check.- Returns:
true if every value istrue .- See Also:
-
not
Returns the logical negation of the specified boolean.- Parameters:
v- The value to negate.- Returns:
!v.- See Also:
-
b
Converts the specified object to a boolean.- Parameters:
v- The value to convert.- Returns:
- The boolean value.
- See Also:
-
s
Converts the specified object to its string representation (null-safe).- Parameters:
v- The value to stringify.- Returns:
- The string form, or null if the value is null.
- See Also:
-
id
Returns the system identity string of the specified object.- Parameters:
o- The object. Can benull (returnsnull ).- Returns:
- The identity string (class name + identity hashcode), or
null if the object isnull . - See Also:
-
btw
Returnstrue if the specified integer is within the inclusive range.- Parameters:
n- The value to test.lo- The inclusive lower bound.hi- The inclusive upper bound.- Returns:
true iflo <= n <= hi.- See Also:
-
nm1
Returnstrue if the specified number is non-null and not equal to -1.- Type Parameters:
T- The number type.- Parameters:
v- The value to test.- Returns:
true if the value is not -1.- See Also:
-
h
Computes a hash code over the specified values.- Parameters:
v- The values to hash. Must not benull (anull array throwsIllegalArgumentException).- Returns:
- The combined hash code.
- See Also:
-
ie
Returnstrue if the specified object is null or empty (string/collection/map/array).- Parameters:
o- The object to check.- Returns:
true if the object is null or empty.- See Also:
-
ine
Returnstrue if the specified object is not null and not empty.- Parameters:
o- The object to check.- Returns:
true if the object is non-empty.- See Also:
-
o
Wraps the specified value in anOptional.- Type Parameters:
T- The value type.- Parameters:
t- The value (may be null).- Returns:
- An optional containing the value, or empty if null.
- See Also:
-
o
Returns the element at the specified index of a list as anOptional.- Type Parameters:
T- The element type.- Parameters:
l- The list.i- The index.- Returns:
- An optional containing the element, or empty if out of bounds.
- See Also:
-
oe
Returns an emptyOptional.- Type Parameters:
T- The value type.- Returns:
- An empty optional.
- See Also:
-
oo
Returns the value of the optional, or the specified default if empty.- Type Parameters:
T- The value type.- Parameters:
o- The optional.d- The default value.- Returns:
- The optional's value, or
dif empty. - See Also:
-
rnn
Returns the specified value, throwingNullPointerExceptionif it is null.- Type Parameters:
T- The value type.- Parameters:
v- The value.- Returns:
- The non-null value.
- See Also:
-
sz
Returns the size of the specified object (string/collection/map/array).- Parameters:
o- The object.- Returns:
- The size, or 0 if null.
- See Also:
-
req
public static void req(boolean expression, String msg, Object... args) throws IllegalArgumentException Throws anIllegalArgumentExceptionif the specified expression isfalse .Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder timeout(Durationvalue ) {req (!value .isNegative(),"Argument 'value' cannot be negative: %s" ,value ); ... }- Parameters:
expression- The boolean expression to check.msg- The exception message format string (seeStringUtils.format(String, Object...)).args- The exception message args.- Throws:
IllegalArgumentException- If the expression isfalse .
-
reqnn
Throws anIllegalArgumentExceptionif the specified argument isnull .Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder timeout(Durationvalue ) {timeout =reqnn ("value" ,value );return this ; }- Type Parameters:
T- The argument data type.- Parameters:
name- The argument name.o- The object to check.- Returns:
- The same argument.
- Throws:
IllegalArgumentException- If the argument isnull .
-
reqnn
public static void reqnn(String name1, Object o1, String name2, Object o2) throws IllegalArgumentException Throws anIllegalArgumentExceptionif either of the specified arguments isnull .Arguments are checked in order, so the exception names the first
null argument.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Foo(Stringname , Objectvalue ) {reqnn ("name" ,name ,"value" ,value ); ... }- Parameters:
name1- The first argument name.o1- The first object to check.name2- The second argument name.o2- The second object to check.- Throws:
IllegalArgumentException- If any argument isnull .
-
reqnn
public static void reqnn(String name1, Object o1, String name2, Object o2, String name3, Object o3) throws IllegalArgumentException Throws anIllegalArgumentExceptionif any of the three specified arguments isnull .Arguments are checked in order, so the exception names the first
null argument.Example:
import static org.apache.juneau.commons.utils.Shorts.*;reqnn ("a" ,a ,"b" ,b ,"c" ,c );- Parameters:
name1- The first argument name.o1- The first object to check.name2- The second argument name.o2- The second object to check.name3- The third argument name.o3- The third object to check.- Throws:
IllegalArgumentException- If any argument isnull .
-
reqnn
public static void reqnn(String name1, Object o1, String name2, Object o2, String name3, Object o3, String name4, Object o4) throws IllegalArgumentException Throws anIllegalArgumentExceptionif any of the four specified arguments isnull .Arguments are checked in order, so the exception names the first
null argument.Example:
import static org.apache.juneau.commons.utils.Shorts.*;reqnn ("a" ,a ,"b" ,b ,"c" ,c ,"d" ,d );- Parameters:
name1- The first argument name.o1- The first object to check.name2- The second argument name.o2- The second object to check.name3- The third argument name.o3- The third object to check.name4- The fourth argument name.o4- The fourth object to check.- Throws:
IllegalArgumentException- If any argument isnull .
-
reqnn
public static void reqnn(String name1, Object o1, String name2, Object o2, String name3, Object o3, String name4, Object o4, String name5, Object o5) throws IllegalArgumentException Throws anIllegalArgumentExceptionif any of the five specified arguments isnull .Arguments are checked in order, so the exception names the first
null argument.Example:
import static org.apache.juneau.commons.utils.Shorts.*;reqnn ("a" ,a ,"b" ,b ,"c" ,c ,"d" ,d ,"e" ,e );- Parameters:
name1- The first argument name.o1- The first object to check.name2- The second argument name.o2- The second object to check.name3- The third argument name.o3- The third object to check.name4- The fourth argument name.o4- The fourth object to check.name5- The fifth argument name.o5- The fifth object to check.- Throws:
IllegalArgumentException- If any argument isnull .
-
reqnb
Throws anIllegalArgumentExceptionif the specified string argument isnull or blank.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder name(Stringvalue ) {name =reqnb ("value" ,value );return this ; }- Parameters:
name- The argument name.o- The string to check.- Returns:
- The same string.
- Throws:
IllegalArgumentException- If the string isnull or blank.
-
reqnns
Throws anIllegalArgumentExceptionif the specified array argument or any of its elements isnull .Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder tags(String...values ) {tags =l (reqnns ("values" ,values ));return this ; }- Type Parameters:
T- The element type.- Parameters:
name- The argument name.o- The array to check.- Returns:
- The same array.
- Throws:
IllegalArgumentException- If the array or any of its elements isnull .
-
reqnns
public static <T,C extends Collection<T>> C reqnns(String name, C collection) throws IllegalArgumentException Throws anIllegalArgumentExceptionif the specified collection argument or any of its elements isnull .Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder tags(List<String>values ) {tags =tl (reqnns ("values" ,values ));return this ; }- Type Parameters:
T- The element type.C- The collection type.- Parameters:
name- The argument name.collection- The collection to check.- Returns:
- The same collection.
- Throws:
IllegalArgumentException- If the collection or any of its elements isnull .
-
reqt
Throws anIllegalArgumentExceptionif the specified object is not an instance of the specified type.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public void setValue(Objectvalue ) { Strings =reqt (String.class ,value ); ... }- Type Parameters:
T- The expected type.- Parameters:
type- The expected class type. Must not benull (anull type throwsIllegalArgumentException).o- The object to check. Must not benull (anull object throwsIllegalArgumentException).- Returns:
- The object cast to the specified type.
- Throws:
IllegalArgumentException- If the object is not an instance of the specified type, or if either argument isnull .
-
reqt
public static <T> T reqt(Class<T> type, Object o, Supplier<? extends RuntimeException> exceptionSupplier) Throws the exception provided by the supplier if the specified object is not an instance of the specified type.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public void setValue(Objectvalue ) { Strings =reqt (String.class ,value , () ->isex ("Invalid value type" )); ... }- Type Parameters:
T- The expected type.- Parameters:
type- The expected class type. Must not benull (anull type throwsIllegalArgumentException).o- The object to check. Must not benull (anull object throwsIllegalArgumentException).exceptionSupplier- The supplier that provides the exception to throw if validation fails. Must not benull .- Returns:
- The object cast to the specified type.
- Throws:
RuntimeException- If the object is not an instance of the specified type (the exception is provided by the supplier).
-
reqcat
public static <E> Class<E>[] reqcat(String name, Class<E> type, Class<?>[] value) throws IllegalArgumentException Throws anIllegalArgumentExceptionif any element of the specified class array is not a subtype of the specified type.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Builder serializers(Class<?>...values ) {serializers =reqcat ("values" , Serializer.class ,values );return this ; }- Type Parameters:
E- The element type.- Parameters:
name- The argument name.type- The expected parent class. Must not benull (unguarded — anull type throwsNullPointerException).value- The array value being checked. Must not benull (unguarded — anull array throwsNullPointerException).- Returns:
- The value cast to the specified array type.
- Throws:
IllegalArgumentException- If any element is not a subtype of the specified type.
-
chk
Throws anIllegalStateExceptionif the specified expression isfalse .The state-check counterpart of
req(boolean, String, Object...): use it for object or lifecycle state rather than method arguments.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public void start() {chk (!started ,"Already started: %s" ,name ); ... }- Parameters:
expression- The boolean expression to check.msg- The exception message format string (seeStringUtils.format(String, Object...)).args- The exception message args.- Throws:
IllegalStateException- If the expression isfalse .
-
chknn
Throws anIllegalStateExceptionif the specified object isnull .The state-check counterpart of
reqnn(String, Object): use it for object or lifecycle state rather than method arguments.Example:
import static org.apache.juneau.commons.utils.Shorts.*;public Connection connection() {return chknn (connection ,"Not connected: %s" ,name ); }- Type Parameters:
T- The object type.- Parameters:
o- The object to check. Can benull .msg- The exception message format string (seeStringUtils.format(String, Object...)).args- The exception message args.- Returns:
- The same object.
- Throws:
IllegalStateException- If the object isnull .
-
ie
Returnstrue if the specified character sequence is null or empty.- Parameters:
s- The sequence to check.- Returns:
true if null or zero-length.- See Also:
-
ine
Returnstrue if the specified character sequence is not null and not empty.- Parameters:
s- The sequence to check.- Returns:
true if non-empty.- See Also:
-
f
Formats a message using printf-style (%s/%d/…) placeholders.For MessageFormat-style (
{0}) patterns, usemf(String,Object...).- Parameters:
p- The pattern.a- The arguments.- Returns:
- The formatted string.
- See Also:
-
fs
Returns a supplier that lazily formats a printf-style message (deferred untilSupplier.get()).For MessageFormat-style (
{0}) patterns, usemfs(String,Object...).- Parameters:
p- The pattern.a- The arguments.- Returns:
- A supplier of the formatted string.
- See Also:
-
mf
Formats a message usingMessageFormat-style {0} placeholders.MessageFormat counterpart to
f(String,Object...), for patterns that genuinely need MessageFormat semantics (e.g. externally-authored i18n.propertiesstrings).- Parameters:
p- The pattern.a- The arguments.- Returns:
- The formatted string.
- See Also:
-
mfs
Returns a supplier that lazily formats a MessageFormat-style message (deferred untilSupplier.get()).- Parameters:
p- The pattern.a- The arguments.- Returns:
- A supplier of the formatted string.
- See Also:
-
r
Returns a human-readable string representation of the specified object.- Parameters:
o- The object. Can benull (returnsnull ).- Returns:
- The readable representation, or
null if the object isnull . - See Also:
-
ib
Returnstrue if the specified string is null, empty, or whitespace-only.- Parameters:
s- The string to check.- Returns:
true if blank.- See Also:
-
inb
Returnstrue if the specified string contains non-whitespace content.- Parameters:
s- The string to check.- Returns:
true if not blank.- See Also:
-
lc
Converts the specified string to lower case (null-safe).- Parameters:
s- The string.- Returns:
- The lower-cased string, or null if null.
- See Also:
-
lcr
Converts the specified string to lower case usingLocale.ROOT(null-safe).Locale-independent — use for parse/match/normalize/key-fold code paths (as opposed to
lc(String), which uses the default locale and is intended for display casing).- Parameters:
s- The string.- Returns:
- The lower-cased string, or null if null.
- See Also:
-
uc
Converts the specified string to upper case (null-safe).- Parameters:
s- The string.- Returns:
- The upper-cased string, or null if null.
- See Also:
-
ucr
Converts the specified string to upper case usingLocale.ROOT(null-safe).Locale-independent — use for parse/match/normalize/key-fold code paths (as opposed to
uc(String), which uses the default locale and is intended for display casing).- Parameters:
s- The string.- Returns:
- The upper-cased string, or null if null.
- See Also:
-
tr
Trims leading/trailing whitespace from the specified string (null-safe).- Parameters:
s- The string.- Returns:
- The trimmed string, or null if null.
- See Also:
-
sw
Returnstrue if the string starts with the specified prefix (null-safe).- Parameters:
s- The string.p- The prefix.- Returns:
true if it starts with the prefix.- See Also:
-
ew
Returnstrue if the string ends with the specified suffix (null-safe).- Parameters:
s- The string.x- The suffix.- Returns:
true if it ends with the suffix.- See Also:
-
co
Returnstrue if the string contains the specified substring (null-safe).- Parameters:
s- The string.x- The substring.- Returns:
true if it contains the substring.- See Also:
-
eqic
Returnstrue if the two strings are equal ignoring case (null-safe).- Parameters:
a- The first string.b- The second string.- Returns:
true if equal ignoring case.- See Also:
-
neqic
Returnstrue if the two strings are not equal ignoring case (null-safe).- Parameters:
a- The first string.b- The second string.- Returns:
true if not equal ignoring case.- See Also:
-
ein
Returns an empty string if the specified string is null, else the string.- Parameters:
s- The string.- Returns:
- The string, or an empty string if null.
- See Also:
-
ein
Returns an empty string if the specified object is null, else its string form.- Parameters:
o- The object.- Returns:
- The string form, or an empty string if null.
- See Also:
-
bin
Returns a blank (single-space) string if the specified string is null, else the string.- Parameters:
s- The string.- Returns:
- The string, or a blank string if null.
- See Also:
-
nie
Returns null if the specified string is empty, else the string.- Parameters:
s- The string.- Returns:
- The string, or null if empty.
- See Also:
-
sb
Creates a newStringBuilderinitialized with the stringified form of the specified value.- Parameters:
v- The initial value. Can benull (renders as"null").- Returns:
- A new string builder.
- See Also:
-
sb
Creates a newStringBuilderwith the stringified form of each specified value appended in order.- Parameters:
v- The values to append in order (empty builder for no args).- Returns:
- A new string builder.
- See Also:
-
cn
Returns the fully-qualified class name of the specified object (null-safe).- Parameters:
o- The object.- Returns:
- The class name, or null if the object is null.
- See Also:
-
cns
Returns the simple class name of the specified object (null-safe).- Parameters:
o- The object.- Returns:
- The simple class name, or null if the object is null.
- See Also:
-
cnsq
Returns the qualified simple class name of the specified object (includes enclosing classes).- Parameters:
o- The object.- Returns:
- The qualified simple class name.
- See Also:
-
fne
Returns the first non-empty string from the specified values.- Parameters:
v- The candidate strings.- Returns:
- The first non-empty string, or null if all are empty.
- See Also:
-
fnb
Returns the first non-blank string from the specified values.- Parameters:
v- The candidate strings.- Returns:
- The first non-blank string, or null if all are blank.
- See Also:
-
jn
Concatenates the specified strings.- Parameters:
v- The strings to join.- Returns:
- The concatenated string.
- See Also:
-
a
Creates an array from the specified elements.- Type Parameters:
T- The element type.- Parameters:
x- The elements. Can benull (returned as-is).- Returns:
- A new array, or
null if the array wasnull . - See Also:
-
l
Creates a modifiableArrayListfrom the specified elements.- Type Parameters:
T- The element type.- Parameters:
x- The elements. Can benull (returnsnull ).- Returns:
- A new modifiable list, or
null if the array wasnull . - See Also:
-
m
Creates an empty modifiable map.- Type Parameters:
K- The key type.V- The value type.- Returns:
- An empty modifiable map.
- See Also:
-
m
Creates a modifiable map with 1 entry.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The key.v1- The value.- Returns:
- A modifiable map.
- See Also:
-
m
Creates a modifiable map with 2 entries.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The first key.v1- The first value.k2- The second key.v2- The second value.- Returns:
- A modifiable map.
- See Also:
-
m
Creates a modifiable map with 3 entries.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The first key.v1- The first value.k2- The second key.v2- The second value.k3- The third key.v3- The third value.- Returns:
- A modifiable map.
- See Also:
-
m
Creates a modifiable map with 4 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2.k3- Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.- Returns:
- A modifiable map.
- See Also:
-
m
Creates a modifiable map with 5 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3.k4- Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.- Returns:
- A modifiable map.
- See Also:
-
m
public static <K,V> Map<K,V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Creates a modifiable map with 6 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3.k4- Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6.- Returns:
- A modifiable map.
- See Also:
-
m
public static <K,V> Map<K,V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Creates a modifiable map with 7 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.k5- Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7.- Returns:
- A modifiable map.
- See Also:
-
m
public static <K,V> Map<K,V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Creates a modifiable map with 8 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.k5- Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8.- Returns:
- A modifiable map.
- See Also:
-
m
public static <K,V> Map<K,V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Creates a modifiable map with 9 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.k6- Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8. @param k9 Key 9. @param v9 Value 9.- Returns:
- A modifiable map.
- See Also:
-
m
public static <K,V> Map<K,V> m(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Creates a modifiable map with 10 entries (keys/values in alternating order).- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.k6- Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8. @param k9 Key 9. @param v9 Value 9. @param k10 Key 10. @param v10 Value 10.- Returns:
- A modifiable map.
- See Also:
-
at
Returns the element at the specified index of a list (null-safe).- Type Parameters:
E- The element type.- Parameters:
l- The list.i- The index.- Returns:
- The element, or null if out of bounds.
- See Also:
-
na
Returnsnull typed as an array of the specified component type.Intentional
null return (e.g. for assertion testing).- Type Parameters:
T- The component type.- Parameters:
t- The component class.- Returns:
null .- See Also:
-
nie
Returns null if the specified map is empty, else the map.- Type Parameters:
K- The key type.V- The value type.- Parameters:
v- The map.- Returns:
- The map, or null if empty.
- See Also:
-
nie
Returns null if the specified list is empty, else the list.- Type Parameters:
E- The element type.- Parameters:
v- The list.- Returns:
- The list, or null if empty.
- See Also:
-
nie
Returns null if the specified set is empty, else the set.- Type Parameters:
E- The element type.- Parameters:
v- The set.- Returns:
- The set, or null if empty.
- See Also:
-
ie
Returnstrue if the specified collection is null or empty.- Parameters:
c- The collection.- Returns:
true if null or empty.- See Also:
-
ie
Returnstrue if the specified map is null or empty.- Parameters:
m- The map.- Returns:
true if null or empty.- See Also:
-
ine
Returnstrue if the specified collection is not null and not empty.- Parameters:
c- The collection.- Returns:
true if non-empty.- See Also:
-
ine
Returnstrue if the specified map is not null and not empty.- Parameters:
m- The map.- Returns:
true if non-empty.- See Also:
-
a2
Creates a 2-dimensional array from the specified rows.- Type Parameters:
E- The element type.- Parameters:
v- The rows.- Returns:
- A 2-dimensional array.
- See Also:
-
ao
Creates anObject[]from the specified elements.- Parameters:
v- The elements.- Returns:
- A new object array.
- See Also:
-
ll
Creates a mutableLinkedListfrom the specified elements.- Type Parameters:
T- The element type.- Parameters:
v- The elements.- Returns:
- A new linked list.
- See Also:
-
hs
Creates a mutableHashSetfrom the specified elements.- Type Parameters:
T- The element type.- Parameters:
v- The elements.- Returns:
- A new hash set.
- See Also:
-
st
Creates a modifiable, insertion-orderedLinkedHashSetfrom the specified elements.- Type Parameters:
T- The element type.- Parameters:
v- The elements.- Returns:
- A new modifiable set.
- See Also:
-
ss
Creates a sortedTreeSetfrom the specified elements (null values filtered out).- Type Parameters:
E- The element type.- Parameters:
v- The elements.- Returns:
- A new sorted set.
- See Also:
-
tl
Creates a modifiableArrayListcopy of the specified collection.- Type Parameters:
E- The element type.- Parameters:
v- The collection to copy from. Can benull (returns an empty list, notnull ).- Returns:
- A new modifiable list.
- See Also:
-
ts
Creates a modifiableLinkedHashSetcopy of the specified collection.- Type Parameters:
E- The element type.- Parameters:
v- The collection to copy from. Can benull (returnsnull ).- Returns:
- A new modifiable set, or
null if the input wasnull . - See Also:
-
los
Creates a modifiable, emptyArrayListpresized to the specified capacity.- Type Parameters:
E- The element type.- Parameters:
n- The initial capacity.- Returns:
- A new modifiable, empty list.
- See Also:
-
ist
Creates an unmodifiable set from the specified elements. UnlikeSet.of(Object...), permits anull element and preserves insertion order.- Type Parameters:
E- The element type.- Parameters:
v- The elements. Must not benull (anull array throwsIllegalArgumentException).- Returns:
- A new unmodifiable set.
- See Also:
-
im
Creates an unmodifiable, empty map.- Type Parameters:
K- The key type.V- The value type.- Returns:
- A new unmodifiable empty map.
- See Also:
-
im
Creates an unmodifiable map with 1 entry. UnlikeMap.of(Object,Object), permits anull key or value and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The key.v1- The value.- Returns:
- A new unmodifiable map.
- See Also:
-
im
Creates an unmodifiable map with 2 entries. UnlikeMap.of(Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The first key.v1- The first value.k2- The second key.v2- The second value.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- ifk1 andk2 are duplicate keys.- See Also:
-
im
Creates an unmodifiable map with 3 entries. UnlikeMap.of(Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- The first key.v1- The first value.k2- The second key.v2- The second value.k3- The third key.v3- The third value.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
Creates an unmodifiable map with 4 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2.k3- Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
Creates an unmodifiable map with 5 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3.k4- Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
public static <K,V> Map<K,V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Creates an unmodifiable map with 6 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3.k4- Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
public static <K,V> Map<K,V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Creates an unmodifiable map with 7 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.k5- Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
public static <K,V> Map<K,V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Creates an unmodifiable map with 8 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4.k5- Key 5. @param v5 Value 5. @param k6 Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
public static <K,V> Map<K,V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Creates an unmodifiable map with 9 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.k6- Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8. @param k9 Key 9. @param v9 Value 9.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
im
public static <K,V> Map<K,V> im(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Creates an unmodifiable map with 10 entries (keys/values in alternating order). UnlikeMap.of(Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object), permitsnull keys/values and preserves insertion order. Mutating the returned map (e.g.put /remove /clear ) throwsUnsupportedOperationException.- Type Parameters:
K- The key type.V- The value type.- Parameters:
k1- Key 1. @param v1 Value 1. @param k2 Key 2. @param v2 Value 2. @param k3 Key 3. @param v3 Value 3. @param k4 Key 4. @param v4 Value 4. @param k5 Key 5. @param v5 Value 5.k6- Key 6. @param v6 Value 6. @param k7 Key 7. @param v7 Value 7. @param k8 Key 8. @param v8 Value 8. @param k9 Key 9. @param v9 Value 9. @param k10 Key 10. @param v10 Value 10.- Returns:
- A new unmodifiable map.
- Throws:
IllegalArgumentException- if any of the keys are duplicated.- See Also:
-
u
Returns an unmodifiable view of the specified list.- Type Parameters:
T- The element type.- Parameters:
v- The list. Can benull (returnsnull ).- Returns:
- An unmodifiable list, or
null if the argument wasnull . - See Also:
-
u
Returns an unmodifiable view of the specified map.- Type Parameters:
K- The key type.V- The value type.- Parameters:
v- The map. Can benull (returnsnull ).- Returns:
- An unmodifiable map, or
null if the argument wasnull . - See Also:
-
u
Returns an unmodifiable view of the specified set.- Type Parameters:
T- The element type.- Parameters:
v- The set. Can benull (returnsnull ).- Returns:
- An unmodifiable set, or
null if the argument wasnull . - See Also:
-
u
Returns an unmodifiable view of the specified sorted set.- Type Parameters:
T- The element type.- Parameters:
v- The sorted set. Can benull (returnsnull ).- Returns:
- An unmodifiable sorted set, or
null if the argument wasnull . - See Also:
-
len
Returns the length/size of the specified object (array/collection/map/string).- Parameters:
v- The object.- Returns:
- The length, or 0 if null.
- See Also:
-
aa
Adds the specified elements to the given list and returns it.- Type Parameters:
E- The element type.- Parameters:
v- The list to add to. Can benull (a new list is created and returned).e- The elements to add. Can benull (treated as a no-op — the value is returned unchanged).- Returns:
- The same list (or a newly-created list if
v wasnull ). - See Also:
-
ints
Creates anint[]from the specified values.- Parameters:
v- The values.- Returns:
- A new int array.
- See Also:
-
longs
Creates along[]from the specified values.- Parameters:
v- The values.- Returns:
- A new long array.
- See Also:
-
bytes
Creates abyte[]from the specified int values.- Parameters:
v- The values.- Returns:
- A new byte array.
- See Also:
-
chars
Creates achar[]from the specified values.- Parameters:
v- The values.- Returns:
- A new char array.
- See Also:
-
floats
Creates afloat[]from the specified values.- Parameters:
v- The values.- Returns:
- A new float array.
- See Also:
-
doubles
Creates adouble[]from the specified values.- Parameters:
v- The values.- Returns:
- A new double array.
- See Also:
-
booleans
Creates aboolean[]from the specified values.- Parameters:
v- The values.- Returns:
- A new boolean array.
- See Also:
-
shorts
Creates ashort[]from the specified int values.- Parameters:
v- The values.- Returns:
- A new short array.
- See Also:
-
lb
Creates a newListsbuilder for the specified element type.- Type Parameters:
E- The element type.- Parameters:
type- The element type.- Returns:
- A new list builder.
- See Also:
-
mb
Creates a newMapsbuilder.- Type Parameters:
K- The key type.V- The value type.- Returns:
- A new map builder.
- See Also:
-
mb
Creates a newMapsbuilder for the specified key and value types.- Type Parameters:
K- The key type.V- The value type.- Parameters:
keyType- The key type.valueType- The value type.- Returns:
- A new map builder.
- See Also:
-
stb
Creates a newSetsbuilder for the specified element type.- Type Parameters:
E- The element type.- Parameters:
type- The element type.- Returns:
- A new set builder.
- See Also:
-
cp
Creates a new collection from the specified collection.- Type Parameters:
E- The element type.- Parameters:
v- The value to copy from. Can benull (returnsnull ).- Returns:
- A new
LinkedHashSet, ornull if the input was null. - See Also:
-
cp
Returns a mutable copy of the specified list.- Type Parameters:
E- The element type.- Parameters:
v- The list to copy. Can benull (returnsnull ).- Returns:
- A new list containing the same elements, or
null if the list wasnull . - See Also:
-
cp
Makes a deep copy of the specified list, transforming each value.- Type Parameters:
E- The element type.- Parameters:
v- The list to copy.valueMapper- The function to apply to each value in the list.- Returns:
- A new transformed list, or
null if the list being copied was null. - See Also:
-
cp
public static <E> List<E> cp(List<E> v, Function<? super E, ? extends E> valueMapper, Supplier<List<E>> listFactory) Makes a deep copy of the specified list, transforming each value using the specified list factory.- Type Parameters:
E- The element type.- Parameters:
v- The list to copy.valueMapper- The function to apply to each value in the list.listFactory- The factory for creating the list.- Returns:
- A new transformed list, or
null if the list being copied was null. - See Also:
-
cp
Creates a new map from the specified map.- Type Parameters:
K- The key type.V- The value type.- Parameters:
v- The value to copy from. Can benull (returnsnull ).- Returns:
- A new
LinkedHashMap, ornull if the input was null. - See Also:
-
cp
Makes a deep copy of the specified map, transforming each value.- Type Parameters:
K- The key type.V- The value type.- Parameters:
v- The map to copy.valueMapper- The function to apply to each value in the map.- Returns:
- A new transformed map, or
null if the map being copied was null. - See Also:
-
cp
public static <K,V> Map<K,V> cp(Map<K, V> v, Function<? super V, ? extends V> valueMapper, Supplier<Map<K, V>> mapFactory) Makes a deep copy of the specified map, transforming each value using the specified map factory.- Type Parameters:
K- The key type.V- The value type.- Parameters:
v- The map to copy.valueMapper- The function to apply to each value in the map.mapFactory- The factory for creating the map.- Returns:
- A new transformed map, or
null if the map being copied was null. - See Also:
-
cp
Creates a new set from the specified set.- Type Parameters:
E- The element type.- Parameters:
v- The value to copy from. Can benull (returnsnull ).- Returns:
- A new
LinkedHashSet, ornull if the input was null. - See Also:
-
cp
Makes a deep copy of the specified set, transforming each value.- Type Parameters:
E- The element type.- Parameters:
v- The set to copy.valueMapper- The function to apply to each value in the set.- Returns:
- A new transformed set, or
null if the set being copied was null. - See Also:
-
cp
public static <E> Set<E> cp(Set<E> v, Function<? super E, ? extends E> valueMapper, Supplier<Set<E>> setFactory) Makes a deep copy of the specified set, transforming each value using the specified set factory.- Type Parameters:
E- The element type.- Parameters:
v- The set to copy.valueMapper- The function to apply to each value in the set.setFactory- The factory for creating sets.- Returns:
- A new transformed set, or
null if the set being copied was null. - See Also:
-
cp
Makes a copy of the specified array.- Type Parameters:
T- The element type.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cp
Makes a copy of the specified array.- Parameters:
v- The array to copy. Can benull (returnsnull ).- Returns:
- A new copy of the array, or
null if the array wasnull . - See Also:
-
cast
Casts the specified object to the specified type (null-safe).- Type Parameters:
T- The target type.- Parameters:
c- The target class.o- The object to cast.- Returns:
- The cast object, or null if the object is null.
- See Also:
-
sa
Makes the specified method accessible.- Parameters:
m- The method. Must not benull (anull argument throwsIllegalArgumentException).- Returns:
true if the method was made accessible.- See Also:
-
sa
Makes the specified field accessible.- Parameters:
f- The field. Must not benull (anull argument throwsIllegalArgumentException).- Returns:
true if the field was made accessible.- See Also:
-
sa
Makes the specified constructor accessible.- Parameters:
c- The constructor. Must not benull (anull argument throwsIllegalArgumentException).- Returns:
true if the constructor was made accessible.- See Also:
-
rex
Creates aRuntimeExceptionwith a formatted message. -
rex
Creates aRuntimeExceptionwrapping a cause. -
rex
Creates aRuntimeExceptionwith a cause and formatted message. -
iaex
Creates anIllegalArgumentExceptionwith a formatted message. -
iaex
Creates anIllegalArgumentExceptionwrapping a cause. -
iaex
Creates anIllegalArgumentExceptionwith a cause and formatted message. -
brex
Creates aBeanRuntimeExceptionwith a formatted message. -
brex
Creates aBeanRuntimeExceptionwrapping a cause. -
brex
Creates aBeanRuntimeExceptionwith a cause and formatted message. -
brex
Creates aBeanRuntimeExceptionwith an associated class and formatted message. -
brex
Creates aBeanRuntimeExceptionwith an associated class and formatted message. -
brex
Creates aBeanRuntimeExceptionwith a cause, associated class, and formatted message. -
brex
Creates aBeanRuntimeExceptionwith a cause, associated class, and formatted message. -
ioex
Creates anIOExceptionwith a formatted message. -
ioex
Creates anIOExceptionwrapping a cause. -
ioex
Creates anIOExceptionwith a cause and formatted message. -
exex
Creates anExecutableExceptionwith a formatted message. -
exex
Creates anExecutableExceptionwrapping a cause. -
exex
Creates anExecutableExceptionwith a cause and formatted message. -
isex
Creates anIllegalStateExceptionwith a formatted message. -
isex
Creates anIllegalStateExceptionwrapping a cause. -
isex
Creates anIllegalStateExceptionwith a cause and formatted message. -
uoex
Creates anUnsupportedOperationExceptionwith the message "Not supported." -
uoex
Creates anUnsupportedOperationExceptionwith a formatted message. -
uoex
Creates anUnsupportedOperationExceptionwrapping a cause. -
uoex
Creates anUnsupportedOperationExceptionwith a cause and formatted message. -
uoroex
Creates anUnsupportedOperationExceptionwith the message "Object is read only." -
gst
Returns the stack trace of the specified throwable as a string.- Parameters:
t- The throwable. Must not benull (anull argument throwsNullPointerException).- Returns:
- The stack trace string.
- See Also:
-
cex
Casts the specified throwable to the specified type, wrapping if necessary.- Type Parameters:
T- The target type.- Parameters:
c- The target class. Must not benull .t- The throwable. Can benull (produces a wrapper with anull cause).- Returns:
- The cast (or wrapped) throwable.
- See Also:
-
fc
Searches the causal chain of the specified throwable for a cause of the specified type.- Type Parameters:
T- The cause type.- Parameters:
e- The throwable to search. Can benull (returns an emptyOptional).c- The cause class to look for. Must not benull .- Returns:
- An optional containing the matching cause, if found.
- See Also:
-
gtc
Returns the first cause of the specified type from the throwable's causal chain.- Type Parameters:
T- The cause type.- Parameters:
c- The cause class to look for. Must not benull .t- The throwable to search. Can benull (returnsnull ).- Returns:
- The matching cause, or null if not found.
- See Also:
-
lm
Returns the localized message of the specified throwable.- Parameters:
t- The throwable. Must not benull (anull argument throwsNullPointerException).- Returns:
- The localized message, or
null if the throwable has no localized message. - See Also:
-
quiet
Runs the specified snippet, silently swallowing any thrown exception.- Parameters:
s- The snippet to run.- See Also:
-
t
Tests the specified value against the given predicate (null-safe).- Type Parameters:
T- The value type.- Parameters:
p- The predicate. Can benull (returnstrue ).v- The value to test. Can benull .- Returns:
- The result of the predicate, or
true if the predicate isnull . - See Also:
-