- java.lang.Object
-
- com.rezzedup.util.constants.types.Cast.Unsafe
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Function<@NullOr Object,Optional<T>>generic(TypeCompatible<T> type)Creates a function that attempts to cast objects into the specified generic type.<T> Optional<T>generic(TypeCompatible<T> type, @NullOr Object object)Attempts to cast an object into the specified generic type.<T> Optional<T>genericOptional(TypeCompatible<T> type, Optional<?> optional)Attempts to cast anOptional's contents into the specified generic type.
-
-
-
Method Detail
-
generic
public <T> Optional<T> generic(TypeCompatible<T> type, @NullOr Object object)
Attempts to cast an object into the specified generic type.Warning: since generic type information is erased, casting will "succeed" for any instance of a generic class.
- Type Parameters:
T- the generic type- Parameters:
type- generic type to cast intoobject- object to cast- Returns:
- the potentially cast object, otherwise empty
-
generic
public <T> Function<@NullOr Object,Optional<T>> generic(TypeCompatible<T> type)
Creates a function that attempts to cast objects into the specified generic type.Warning: since generic type information is erased, casting will "succeed" for any instance of a generic class.
- Type Parameters:
T- the generic type- Parameters:
type- generic type to cast into- Returns:
- a function that casts objects into the specified generic type
- See Also:
generic(TypeCompatible, Object)
-
genericOptional
public <T> Optional<T> genericOptional(TypeCompatible<T> type, Optional<?> optional)
Attempts to cast anOptional's contents into the specified generic type.Warning: since generic type information is erased, casting will "succeed" for any instance of a generic class.
- Type Parameters:
T- the generic type- Parameters:
type- generic type to cast intooptional- optional to cast- Returns:
- a present Optional if its contents were successfully cast, otherwise empty
-
-