public final class X extends Object
notNull(Object) or ints(int...).empty() or asX(List) are NOT constructor-like methods
because they do not (always) create new instances.| Modifier and Type | Method and Description |
|---|---|
static _longKeyValue |
_longKeyValue(long key,
long value) |
static <T extends Throwable> |
addSuppressed(T throwable,
Throwable... suppresseds) |
static <T extends Throwable> |
addSuppressed(T throwable,
Throwable suppressed) |
static <E> E[] |
Array(Class<E> componentType,
E element) |
static <E> E[] |
Array(Class<E> componentType,
E element,
int length) |
static <E> E[] |
Array(Class<E> componentType,
int length,
_intIndexedSupplier<E> supplier) |
static <E> E[] |
Array(Class<E> componentType,
int length) |
static <E> E[] |
Array(Class<E> componentType,
int length,
Supplier<E> supplier)
|
static <T,E extends T> |
Array(Class<T> type,
XGettingCollection<E> collection)
Static workaround for the Java typing deficiency that it is not possible to
define
public <T super E> T[] toArray(Class<T> type). |
static <E> E[] |
Array(E element) |
static <E> E[] |
Array(int length,
E element) |
static <T> T[] |
array(T... elements) |
static <T> T[] |
ArrayForElementType(T sampleInstance,
int length) |
static <E> E[] |
ArrayOfSameType(E[] sampleArray) |
static <E> E[] |
ArrayOfSameType(E[] sampleArray,
int length) |
static <E> ArrayView<E> |
ArrayView(E... elements) |
static VarString |
assembleString(VarString vs,
XGettingCollection<?> collection) |
RuntimeException |
asUnchecked(Exception e) |
static <E> XList<E> |
asX(List<E> oldList) |
static <K,V> XMap<K,V> |
asX(Map<K,V> oldMap) |
static <E> XSet<E> |
asX(Set<E> oldSet) |
static boolean[] |
booleans(boolean... elements) |
static Boolean[] |
box(boolean... values) |
static Byte[] |
box(byte... values) |
static Character[] |
box(char... values) |
static Double[] |
box(double... values) |
static Float[] |
box(float... values) |
static Integer[] |
box(int... values) |
static Long[] |
box(long... values) |
static Short[] |
box(short... values) |
static ThrowBreak |
BREAK() |
static byte[] |
bytes(byte... elements) |
static char[] |
chars(char... elements) |
static void |
check(BooleanTerm condition)
Forces the passed condition to evaluate to true by throwing an
Error otherwise. |
static void |
check(BooleanTerm condition,
String message)
Forces the passed condition to evaluate to true by throwing an
Error otherwise. |
static void |
check(BooleanTerm condition,
String message,
int stackLevels)
Forces the passed condition to evaluate to true by throwing an
Error otherwise. |
static int |
checkArrayRange(long capacity)
Central validation point for Java's current technical limitation of max int as max array capacity.
|
static <T> T |
coalesce(T... elements) |
static <T> T |
coalesce(T firstElement,
T secondElement) |
static <T> WeakReference<T>[] |
consolidateWeakReferences(WeakReference<T>[] array)
Removes all
null entries and entries with null-referents. |
static <E> Constant<E> |
Constant(E element) |
static <E> ConstHashEnum<E> |
ConstEnum(E... elements) |
static <E> ConstList<E> |
ConstList(E... elements) |
static double[] |
doubles(double... elements) |
static <T> Empty<T> |
empty() |
static <K,V> EmptyTable<K,V> |
emptyTable() |
static <E> HashEnum<E> |
Enum(E... elements) |
static <E> HashEnum<E> |
Enum(Iterable<? extends E> elements) |
static <T> boolean |
equal(T o1,
T o2) |
static float[] |
floats(float... elements) |
static boolean |
hasNoContent(XGettingCollection<?> collection) |
static IllegalArgumentException |
illegalArgument(Object object) |
static IndexBoundsException |
IndexBoundsException(long startIndex,
long indexBound,
long index,
String message,
int stackTraceCutDepth) |
static int[] |
ints(int... elements) |
static boolean |
isFalse(Boolean b)
Helper method to project ternary values to binary logic.
Useful for checking "really false" (not true and not unknown). |
static boolean |
isNotFalse(Boolean b)
Helper method to project ternary values to binary logic.
Useful for checking "really not false" (either true or unknown). |
static boolean |
isNotNull(Object reference) |
static boolean |
isNotTrue(Boolean b)
Helper method to project ternary values to binary logic.
Useful for checking "really not true" (either false or unknown). |
static boolean |
isNull(Object reference) |
static boolean |
isTrue(Boolean b)
Helper method to project ternary values to binary logic.
Useful for checking "really true" (not false and not unknown). |
static Iterable<?> |
Iterable(Object array) |
static <K,V> KeyValue<K,V> |
KeyValue(K key,
V value) |
static <E> XList<E> |
List(E... elements) |
static <E> XList<E> |
List(Iterable<? extends E> elements) |
static long[] |
longs(long... elements) |
static <T> T |
mayNull(T object)
This method is a complete dummy, simply serving as a semantical counterpart to
notNull(Object).The use is small, but still there: - the sourcecode is easier to read if the same structure is used next to a notNull(Object) call
instead of missing method calls and comments (like "may be null" or "optional"). |
static <E> E[] |
notEmpty(E[] array) |
static <S extends Sized> |
notEmpty(S sized) |
static <T> T |
notNull(T object)
Transiently ensures the passed object to be not
null by either returning it in case it is
not null or throwing a NullPointerException otherwise. |
static Object[] |
objects(Object... elements) |
static <S> S |
on(S subject,
Consumer<? super S> logic)
Abbreviation for "execute on".
|
static XList<Integer> |
range(int firstValue,
int lastValue)
Utility method to create a list of integers from
firstValue to lastValue. |
static <T> XReference<T> |
Reference(T object) |
static <P extends Runnable> |
repeat(int startValue,
int length,
P logic) |
static <P extends _intProcedure> |
repeat(int startValue,
int length,
P logic) |
static <P extends Runnable> |
repeat(int amount,
P logic) |
static <P extends _intProcedure> |
repeat(int amount,
P logic) |
static short[] |
shorts(short... elements) |
static <E> Singleton<E> |
Singleton(E element) |
static String[] |
strings(String... elements) |
static <E> XCollection<E> |
synchronize(XCollection<E> collection)
Ensures that the returned
XCollection instance based on the passed collection is thread safe to use.This normally means wrapping the passed collection in a SynchCollection, making it effectively synchronized.If the passed collection already is thread safe (indicated by the marker interface ThreadSafe), then the collection
itself is returned without further actions. |
static <E> XList<E> |
synchronize(XList<E> list)
Ensures that the returned
XList instance based on the passed list is thread safe to use.This normally means wrapping the passed list in a SynchList, making it effectively synchronized.If the passed list already is thread safe (indicated by the marker interface ThreadSafe), then the list
itself is returned without further actions. |
static <E> XSet<E> |
synchronize(XSet<E> set)
Ensures that the returned
XSet instance based on the passed set is thread safe to use.This normally means wrapping the passed set in a SynchSet, making it effectively synchronized.If the passed set already is thread safe (indicated by the marker interface ThreadSafe), then the set
itself is returned without further actions. |
static <K,V> HashTable<K,V> |
Table(KeyValue<? extends K,? extends V>... elements) |
static <K,V> HashTable<K,V> |
Table(K key,
V value) |
static XList<Integer> |
times(int n)
Utility method to create a list of integers from 1 to the passed
n value. |
static <E> E[] |
toArray(Iterable<? extends E> iterable,
Class<E> type)
Converts an
Iterable into an array. |
static byte[] |
toBytes(int value) |
static byte[] |
toBytes(long value) |
static <T,K,V> KeyValue<K,V> |
toKeyValue(T instance,
Function<? super T,KeyValue<K,V>> mapper) |
static String |
toString(XGettingCollection<?> collection) |
static boolean |
unbox(Boolean d) |
static boolean |
unbox(Boolean d,
boolean nullSubstitute) |
static byte |
unbox(Byte d) |
static byte |
unbox(Byte d,
byte nullSubstitute) |
static char |
unbox(Character d) |
static char |
unbox(Character d,
char nullSubstitute) |
static double |
unbox(Double d) |
static double |
unbox(Double d,
double nullSubstitute) |
static float |
unbox(Float d) |
static float |
unbox(Float d,
float nullSubstitute) |
static int |
unbox(Integer d) |
static int[] |
unbox(Integer[] array) |
static int[] |
unbox(Integer[] array,
int nullReplacement) |
static int |
unbox(Integer d,
int nullSubstitute) |
static long |
unbox(Long d) |
static long[] |
unbox(Long[] array) |
static long[] |
unbox(Long[] array,
long nullReplacement) |
static long |
unbox(Long d,
long nullSubstitute) |
static short |
unbox(Short d) |
static short |
unbox(Short d,
short nullSubstitute) |
static int[] |
unbox(XGettingCollection<Integer> ints) |
static int[] |
unbox(XGettingCollection<Integer> ints,
int nullReplacement) |
static <T> T |
validate(T value,
Predicate<? super T> validator) |
static <T,E extends Exception> |
validate(T value,
Predicate<? super T> validator,
Function<? super T,E> exceptor) |
static long |
validateIndex(long availableLength,
long index) |
static long |
validateRange(long bound,
long startIndex,
long length) |
static <T> WeakReference<T> |
WeakReference(T referent) |
static <T> WeakReference<T>[] |
WeakReferences(int length) |
static <T> WeakReference<T>[] |
WeakReferences(T... referents) |
public static final <T> Empty<T> empty()
public static final <K,V> EmptyTable<K,V> emptyTable()
public static ThrowBreak BREAK()
public static final int checkArrayRange(long capacity)
throws ArrayCapacityException
capacity - the desired (array-dependent) capacity which may effectively be not greater than
Integer.MAX_VALUE.ArrayCapacityException - if the passed capacity is greater than Integer.MAX_VALUEpublic static final <T> T notNull(T object)
throws NullPointerException
null by either returning it in case it is
not null or throwing a NullPointerException otherwise.
(Really, no idea why java.util.Objects.notNull got renamed to requireNotNull after some odd objection from
some guy in the mailing list that the name would be misleading.
Of course "notNull" means "the thing you pass has to be not null, otherwise you'll get an exception".
What else could the meaning of a transient method named "notNull" be?
If "requireNotNull" is needed to express this behavior, than what would "notNull" alone mean?
In the end, "requireNotNull" is just additional clutter, hence not usable and is replaced by
this, still properly named "notNull" method.)
T - the type of the object to be ensured to be not null.object - the object to be ensured to be not null.null.NullPointerException - if null was passed.public static final <T> T mayNull(T object)
notNull(Object).notNull(Object) call
instead of missing method calls and comments (like "may be null" or "optional").
- the IDE can search for all occurances of this method, listing all places where something may be null.T - the object's typeobject - the passed reference.public static final boolean isTrue(Boolean b)
b - a Boolean object.false if b is null or falsepublic static final boolean isFalse(Boolean b)
b - a Boolean object.false if b is null or true, otherwise truepublic static final boolean isNotTrue(Boolean b)
b - a Boolean object.true if b is null or false, otherwise falsepublic static final boolean isNotFalse(Boolean b)
b - a Boolean object.true if b is null or true, otherwise falsepublic static final boolean isNull(Object reference)
public static final boolean isNotNull(Object reference)
public static final <T> T coalesce(T firstElement,
T secondElement)
@SafeVarargs public static final <T> T coalesce(T... elements)
public static final <T> boolean equal(T o1,
T o2)
public static final byte unbox(Byte d)
public static final byte unbox(Byte d, byte nullSubstitute)
public static final boolean unbox(Boolean d)
public static final boolean unbox(Boolean d, boolean nullSubstitute)
public static final short unbox(Short d)
public static final short unbox(Short d, short nullSubstitute)
public static final char unbox(Character d)
public static final int unbox(Integer d)
public static final int unbox(Integer d, int nullSubstitute)
public static final char unbox(Character d, char nullSubstitute)
public static final float unbox(Float d)
public static final float unbox(Float d, float nullSubstitute)
public static final long unbox(Long d)
public static final long unbox(Long d, long nullSubstitute)
public static final double unbox(Double d)
public static final double unbox(Double d, double nullSubstitute)
public static final Byte[] box(byte... values)
public static final Boolean[] box(boolean... values)
public static final Short[] box(short... values)
public static final Integer[] box(int... values)
public static final Character[] box(char... values)
public static final Float[] box(float... values)
public static final Long[] box(long... values)
public static final Double[] box(double... values)
public static final int[] unbox(Integer[] array)
public static final int[] unbox(Integer[] array, int nullReplacement)
public static final long[] unbox(Long[] array)
public static final long[] unbox(Long[] array, long nullReplacement)
public static final int[] unbox(XGettingCollection<Integer> ints)
public static final int[] unbox(XGettingCollection<Integer> ints, int nullReplacement)
public static boolean[] booleans(boolean... elements)
public static byte[] bytes(byte... elements)
public static byte[] toBytes(int value)
public static byte[] toBytes(long value)
public static short[] shorts(short... elements)
public static int[] ints(int... elements)
public static long[] longs(long... elements)
public static float[] floats(float... elements)
public static double[] doubles(double... elements)
public static char[] chars(char... elements)
@SafeVarargs public static <T> T[] array(T... elements)
public static XList<Integer> times(int n)
n value.
Useful for executing a logic via XList.iterate(Consumer) exactely n times.n - the amount of integersnpublic static XList<Integer> range(int firstValue, int lastValue)
firstValue to lastValue.firstValue - the lower limitlastValue - the upper limitfirstValue to lastValue@SafeVarargs public static <E> XList<E> List(E... elements)
@SafeVarargs public static <E> ConstList<E> ConstList(E... elements) throws NullPointerException
NullPointerException@SafeVarargs public static <E> ArrayView<E> ArrayView(E... elements)
public static <E> Singleton<E> Singleton(E element)
public static <E> Constant<E> Constant(E element)
@SafeVarargs public static <E> HashEnum<E> Enum(E... elements)
@SafeVarargs public static <E> ConstHashEnum<E> ConstEnum(E... elements) throws NullPointerException
NullPointerExceptionpublic static <K,V> HashTable<K,V> Table(K key, V value)
@SafeVarargs public static <K,V> HashTable<K,V> Table(KeyValue<? extends K,? extends V>... elements)
public static <T> XReference<T> Reference(T object)
public static final <T> T[] ArrayForElementType(T sampleInstance,
int length)
public static <E> E[] ArrayOfSameType(E[] sampleArray,
int length)
public static final <E> E[] ArrayOfSameType(E[] sampleArray)
public static <E> E[] Array(E element)
public static <E> E[] Array(int length,
E element)
public static <E> E[] Array(Class<E> componentType, E element)
public static <E> E[] Array(Class<E> componentType, E element, int length)
public static <E> E[] Array(Class<E> componentType, int length)
public static <T,E extends T> T[] Array(Class<T> type, XGettingCollection<E> collection)
public <T super E> T[] toArray(Class<T> type).E - the collection's element type.T - the component type used to create the array, possibly a super type of Ecollection - the collection whose elements shall be copied to the array.type - the Class representing type T at runtime.T containing all elements of the passed collection.public static <E> E[] Array(Class<E> componentType, int length, Supplier<E> supplier)
Class
componentType,
a length as defined by the passed length value and that is filled in order with elements supplied
by the passed Supplier instance.E - the component typelength - the length of the array to be created.componentType - the component type of the array to be created.supplier - the function supplying the instances that make up the array's elements.Array(Class, int, Supplier)public static <E> E[] Array(Class<E> componentType, int length, _intIndexedSupplier<E> supplier)
public static <T> WeakReference<T> WeakReference(T referent)
public static <T> WeakReference<T>[] WeakReferences(int length)
@SafeVarargs public static <T> WeakReference<T>[] WeakReferences(T... referents)
public static <T> WeakReference<T>[] consolidateWeakReferences(WeakReference<T>[] array)
null entries and entries with null-referents.T - the component typearray - the array to consolidatepublic static boolean hasNoContent(XGettingCollection<?> collection)
public static final <S extends Sized> S notEmpty(S sized)
public static final <E> E[] notEmpty(E[] array)
public static <T,K,V> KeyValue<K,V> toKeyValue(T instance, Function<? super T,KeyValue<K,V>> mapper)
public static <K,V> KeyValue<K,V> KeyValue(K key, V value)
public static _longKeyValue _longKeyValue(long key, long value)
public static String toString(XGettingCollection<?> collection)
public static VarString assembleString(VarString vs, XGettingCollection<?> collection)
public static <E> XList<E> synchronize(XList<E> list)
XList instance based on the passed list is thread safe to use.SynchList, making it effectively synchronized.ThreadSafe), then the list
itself is returned without further actions. This automatically ensures that a SynchList is not
redundantly wrapped again in another SynchList.public static <E> XSet<E> synchronize(XSet<E> set)
XSet instance based on the passed set is thread safe to use.SynchSet, making it effectively synchronized.ThreadSafe), then the set
itself is returned without further actions. This automatically ensures that a SynchSet is not
redundantly wrapped again in another SynchSet.public static <E> XCollection<E> synchronize(XCollection<E> collection)
XCollection instance based on the passed collection is thread safe to use.SynchCollection, making it effectively synchronized.ThreadSafe), then the collection
itself is returned without further actions. This automatically ensures that a SynchCollection is not
redundantly wrapped again in another SynchCollection.E - the element type.collection - the XCollection instance to be synchronized.XCollection using the passed collection.public static <E> E[] toArray(Iterable<? extends E> iterable, Class<E> type)
Iterable into an array.E - the element type.iterable - the iterable to converttype - the component type of the array to be createdpublic static final <T extends Throwable> T addSuppressed(T throwable, Throwable suppressed)
public static final <T extends Throwable> T addSuppressed(T throwable, Throwable... suppresseds)
public RuntimeException asUnchecked(Exception e)
public static final <S> S on(S subject,
Consumer<? super S> logic)
S - the subject's typesubject - the subject to execute the logic onlogic - the logic to executepublic static void check(BooleanTerm condition) throws Error
Error otherwise.condition - the condition to checkError - if the passed condition fails.public static void check(BooleanTerm condition, String message) throws Error
Error otherwise.condition - the condition to checkmessage - the custom error messageError - if the passed condition fails.public static void check(BooleanTerm condition, String message, int stackLevels) throws Error
Error otherwise.condition - the condition to checkmessage - the custom error messagestackLevels - the amount of stack levels for the resulting errorError - if the passed condition fails.public static <T> T validate(T value,
Predicate<? super T> validator)
throws IllegalArgumentException
IllegalArgumentExceptionpublic static IllegalArgumentException illegalArgument(Object object)
public static <T,E extends Exception> T validate(T value, Predicate<? super T> validator, Function<? super T,E> exceptor) throws E extends Exception
E extends Exceptionpublic static <P extends _intProcedure> P repeat(int amount, P logic)
public static <P extends _intProcedure> P repeat(int startValue, int length, P logic)
public static <P extends Runnable> P repeat(int amount, P logic)
public static <P extends Runnable> P repeat(int startValue, int length, P logic)
public static final long validateIndex(long availableLength,
long index)
throws IndexBoundsException
IndexBoundsExceptionpublic static final long validateRange(long bound,
long startIndex,
long length)
public static final IndexBoundsException IndexBoundsException(long startIndex, long indexBound, long index, String message, int stackTraceCutDepth)
Copyright © 2022 MicroStream Software. All rights reserved.