public final class Functions
extends java.lang.Object
EntityFunction
implementations.Modifier and Type | Field and Description |
---|---|
static java.util.function.Supplier<java.util.UUID> |
RANDOM_ID_SUPPLIER
An supplier for random IDs.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkHasParams(java.lang.reflect.Method m)
Checks whether the method has params.
|
static void |
checkHasReturnType(java.lang.reflect.Method m)
Checks whether the method has a return type.
|
static void |
checkNoParams(java.lang.reflect.Method m)
Checks whether the method has no params.
|
static void |
checkNoReturnType(java.lang.reflect.Method m)
Checks whether the method has a void return type.
|
static void |
checkNotDefault(java.lang.reflect.Method m)
Checks whether the method is not default.
|
static java.lang.Object |
defaultValue(java.lang.Class<?> type)
Gets the default value for a primitive wrapper.
|
static java.lang.reflect.Type |
firstGenericTypeArg(java.lang.reflect.Type pt)
Gets the first generic type argument for a parameterised type.
|
static java.util.Set<java.util.function.Supplier<java.util.UUID>> |
getIDSuppliers(java.lang.reflect.Method m)
Gets all the
EntityID annotations and transforms into ID suppliers. |
static java.util.function.Supplier<java.util.UUID> |
getSingleIDSupplier(java.lang.reflect.Method m)
Gets a single ID supplier from a method.
|
static boolean |
hasParams(java.lang.reflect.Method m)
Wether the method has parameters.
|
static boolean |
hasReturnType(java.lang.reflect.Method m)
Checks whether a method has a return type.
|
static boolean |
isPrimitive(java.lang.reflect.Type t)
Whether the type represents a primitive type.
|
static boolean |
isWrapper(java.lang.Class<?> type)
Checks to see if the specified type is a primitive wrapper.
|
static boolean |
returnTypeIs(java.lang.reflect.Method m,
java.lang.Class<?> clazz)
Whether the method return type matches the supplied type.
|
static java.lang.Class<?> |
toClass(java.lang.reflect.Type type)
Attempts to resolve raw class from type.
|
static java.util.function.Supplier<java.util.UUID> |
toIDSupplier(EntityID id)
Transforms the
EntityID to a UUID supplier. |
static java.lang.Class<?> |
unwrap(java.lang.Class<?> type)
Unwraps the primitive wrapper to the primitive type.
|
static void |
validateEntityID(EntityID id)
Validates an
EntityID annotation is correctly formed. |
static java.lang.Class<?> |
wrap(java.lang.Class<?> type)
Gets the wrapper type for the primitive type.
|
public static final java.util.function.Supplier<java.util.UUID> RANDOM_ID_SUPPLIER
UUID.randomUUID()
public static void checkHasParams(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.java.lang.IllegalArgumentException
- If method has no params.public static void checkHasReturnType(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.java.lang.IllegalArgumentException
- If method has no return type.public static void checkNoParams(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.java.lang.IllegalArgumentException
- If method has params.public static void checkNoReturnType(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.java.lang.IllegalArgumentException
- If method has a non-void return type.public static void checkNotDefault(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.java.lang.IllegalArgumentException
- If method is default.public static java.lang.Object defaultValue(java.lang.Class<?> type)
type
- Primitive wrapper type.public static java.lang.reflect.Type firstGenericTypeArg(java.lang.reflect.Type pt)
pt
- Type to take from.public static java.util.Set<java.util.function.Supplier<java.util.UUID>> getIDSuppliers(java.lang.reflect.Method m)
EntityID
annotations and transforms into ID suppliers.m
- Method to check.toIDSupplier(EntityID)
public static java.util.function.Supplier<java.util.UUID> getSingleIDSupplier(java.lang.reflect.Method m) throws java.lang.IllegalArgumentException
m
- Method to check.null
if none found.java.lang.IllegalArgumentException
- If there are multiple ID suppliers found.public static boolean hasParams(java.lang.reflect.Method m)
m
- Method to check.public static boolean hasReturnType(java.lang.reflect.Method m)
m
- Method to check.public static boolean isPrimitive(java.lang.reflect.Type t)
t
- Type to check.public static boolean isWrapper(java.lang.Class<?> type)
type
- Type to check.public static boolean returnTypeIs(java.lang.reflect.Method m, java.lang.Class<?> clazz)
m
- Method to check.clazz
- Possible return type to check.public static java.lang.Class<?> toClass(java.lang.reflect.Type type)
type
- Type to resolve for.public static java.util.function.Supplier<java.util.UUID> toIDSupplier(EntityID id)
EntityID
to a UUID
supplier.id
- ID annotation.validateEntityID(EntityID)
public static java.lang.Class<?> unwrap(java.lang.Class<?> type)
type
- Wrapper type to unwrap.java.lang.IllegalArgumentException
- If the type is not a primitive wrapper.public static void validateEntityID(EntityID id)
EntityID
annotation is correctly formed.id
- ID to check.public static java.lang.Class<?> wrap(java.lang.Class<?> type)
type
- Primitive type to wrap.java.lang.IllegalArgumentException
- If the type is not primitive.