public enum ObjectUtils extends Enum<ObjectUtils>
Modifier and Type | Class and Description |
---|---|
static class |
ObjectUtils.Immutability |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
addAll(T first,
T... additional) |
static @NotNull ClassCastException |
asCCE(Exception e) |
static void |
checkNonNull(Object obj)
|
static <E> E |
convertTo(@Nullable Class<E> eClass,
@Nullable Object o) |
static void |
defaultObjectForInterface(ThrowingFunction<Class,Class,ClassNotFoundException> defaultObjectForInterface) |
static Object |
defaultValue(Class<?> type) |
static Class<?>[] |
getAllInterfaces(Object o) |
static void |
getAllInterfaces(Object o,
Function<Class<?>,Boolean> accumulator) |
static <E extends Enum<E>> |
getSingletonForEnum(Class<E> eClass) |
static @NotNull Class |
getTypeFor(@NotNull Class clazz,
@NotNull Class interfaceClass)
Deprecated.
|
static @NotNull Class |
getTypeFor(@NotNull Class clazz,
@NotNull Class interfaceClass,
int index)
Deprecated.
|
static void |
immutabile(Class clazz,
boolean isImmutable) |
static <T> Class<T> |
implementationToUse(Class<T> tClass) |
static boolean |
isConcreteClass(@NotNull Class tClass) |
static boolean |
isFalse(CharSequence s) |
static ObjectUtils.Immutability |
isImmutable(@NotNull Class clazz) |
static boolean |
isTrue(CharSequence s) |
protected static @NotNull Class |
lookForImplEnum(Class c2) |
static boolean |
matchingClass(@NotNull Class base,
@NotNull Class toMatch) |
static <T> T |
newInstance(@NotNull Class<T> clazz) |
static <T> T |
newInstance(@NotNull String className) |
static @Nullable Object |
newInstanceOrNull(Class type) |
static <T> T |
onMethodCall(@NotNull BiFunction<Method,Object[],Object> biFunction,
@NotNull Class<T> tClass,
Class... additional) |
static Class |
primToWrapper(Class eClass)
If the class is a primitive type, change it to the equivalent wrapper.
|
static Object |
readResolve(@NotNull Object o) |
static <T> T |
requireNonNull(T o)
Standard mechanism to determine objects as not null.
|
static @NotNull Boolean |
toBoolean(String s) |
static ObjectUtils |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static <E extends Enum<E>> |
valueOfIgnoreCase(@NotNull Class<E> eClass,
@NotNull String name) |
static ObjectUtils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static ObjectUtils[] values()
for (ObjectUtils c : ObjectUtils.values()) System.out.println(c);
public static ObjectUtils valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static void immutabile(Class clazz, boolean isImmutable)
public static ObjectUtils.Immutability isImmutable(@NotNull @NotNull Class clazz)
public static boolean isTrue(CharSequence s)
public static boolean isFalse(CharSequence s)
public static Class primToWrapper(Class eClass)
eClass
- to check@Nullable public static <E> E convertTo(@Nullable @Nullable Class<E> eClass, @Nullable @Nullable Object o) throws ClassCastException, IllegalArgumentException
@NotNull public static <E extends Enum<E>> E valueOfIgnoreCase(@NotNull @NotNull Class<E> eClass, @NotNull @NotNull String name)
@NotNull public static @NotNull ClassCastException asCCE(Exception e)
@NotNull public static <T> T newInstance(@NotNull @NotNull String className)
@NotNull public static <T> T newInstance(@NotNull @NotNull Class<T> clazz)
public static <T> T[] addAll(@NotNull T first, @NotNull T... additional)
public static boolean matchingClass(@NotNull @NotNull Class base, @NotNull @NotNull Class toMatch)
@NotNull public static <T> T onMethodCall(@NotNull @NotNull BiFunction<Method,Object[],Object> biFunction, @NotNull @NotNull Class<T> tClass, Class... additional) throws IllegalArgumentException
IllegalArgumentException
@Deprecated @NotNull public static @NotNull Class getTypeFor(@NotNull @NotNull Class clazz, @NotNull @NotNull Class interfaceClass) throws IllegalArgumentException
IllegalArgumentException
@Deprecated @NotNull public static @NotNull Class getTypeFor(@NotNull @NotNull Class clazz, @NotNull @NotNull Class interfaceClass, int index) throws IllegalArgumentException
IllegalArgumentException
public static boolean isConcreteClass(@NotNull @NotNull Class tClass)
public static void getAllInterfaces(Object o, Function<Class<?>,Boolean> accumulator) throws IllegalArgumentException
IllegalArgumentException
public static void defaultObjectForInterface(ThrowingFunction<Class,Class,ClassNotFoundException> defaultObjectForInterface)
public static <T> T requireNonNull(@NotNull T o)
Objects.requireNonNull(Object)
and also decorated with NotNull
so that IntelliJ and other static analysis tools can work their magic.o
- reference to check for nullityNullPointerException
- if o is nullthrowing an {@link IllegalArgumentException} instead
public static void checkNonNull(Object obj)
object
reference is not null
throwing an IllegalArgumentException
.
if it is.
By default, instrumented classes will throw an IllegalArgumentException if annotated with NotNull
and
this method can be used to mimic that behaviour.
This method is designed primarily for doing parameter validation in methods
and constructors, as demonstrated below:
public Foo(Bar bar) { checkNonNull(bar); }
obj
- the object reference to check for nullityIllegalArgumentException
- if obj
is null
throwing a {@link NullPointerException} instead
Copyright © 2021. All rights reserved.