Interface IValueCastRegistry
- All Superinterfaces:
org.cyclops.cyclopscore.init.IRegistry
- All Known Implementing Classes:
ValueCastRegistry
public interface IValueCastRegistry
extends org.cyclops.cyclopscore.init.IRegistry
Registry for casting
IValue.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceIValueCastRegistry.IMapping<T1 extends IValueType<V1>,T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue> static class -
Method Summary
Modifier and TypeMethodDescription<T1 extends IValueType<V1>,T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue>
booleancanCast(T2 target, V1 value) Check if the the given value can be cast to the given type.<T1 extends IValueType<V1>,T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue>
V2cast(T2 target, V1 value) Cast the given value to the given type.<T1 extends IValueType<V1>,T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue>
voidregister(T1 from, T2 to, IValueCastRegistry.IMapping<T1, T2, V1, V2> mapping) Register a mapping between to value types.intsize()
-
Method Details
-
size
int size() -
register
<T1 extends IValueType<V1>,T2 extends IValueType<V2>, void registerV1 extends IValue, V2 extends IValue> (T1 from, T2 to, IValueCastRegistry.IMapping<T1, T2, V1, V2> mapping) Register a mapping between to value types.- Type Parameters:
T1- The source type type.T2- The target type type.V1- The source type.V2- The target type.- Parameters:
from- The source type.to- The target type.mapping- The mapping logic.
-
cast
<T1 extends IValueType<V1>,T2 extends IValueType<V2>, V2 castV1 extends IValue, V2 extends IValue> (T2 target, V1 value) throws IValueCastRegistry.ValueCastException Cast the given value to the given type.- Type Parameters:
T1- The source type type.T2- The target type type.V1- The source type.V2- The target type.- Parameters:
target- The target type.value- The value to cast.- Returns:
- The cast value
- Throws:
IValueCastRegistry.ValueCastException- If casting failed because the type mapping did not exist.
-
canCast
<T1 extends IValueType<V1>,T2 extends IValueType<V2>, boolean canCastV1 extends IValue, V2 extends IValue> (T2 target, V1 value) Check if the the given value can be cast to the given type.- Type Parameters:
T1- The source type type.T2- The target type type.V1- The source type.V2- The target type.- Parameters:
target- The target type.value- The value to cast.- Returns:
- If the value can be cast to the given type.
-