Class ValueCastRegistry
java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.variable.ValueCastRegistry
- All Implemented Interfaces:
org.cyclops.cyclopscore.init.IRegistry
,IValueCastRegistry
Registry for casting
IValue
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.integrateddynamics.api.evaluate.variable.IValueCastRegistry
IValueCastRegistry.IMapping<T1 extends IValueType<V1>,
T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue>, IValueCastRegistry.ValueCastException -
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.static ValueCastRegistry
<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.int
size()
-
Method Details
-
getInstance
- Returns:
- The unique instance.
-
size
public int size()- Specified by:
size
in interfaceIValueCastRegistry
-
register
public <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) Description copied from interface:IValueCastRegistry
Register a mapping between to value types.- Specified by:
register
in interfaceIValueCastRegistry
- 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
public <T1 extends IValueType<V1>,T2 extends IValueType<V2>, V2 castV1 extends IValue, V2 extends IValue> (T2 target, V1 value) throws IValueCastRegistry.ValueCastException Description copied from interface:IValueCastRegistry
Cast the given value to the given type.- Specified by:
cast
in interfaceIValueCastRegistry
- 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
public <T1 extends IValueType<V1>,T2 extends IValueType<V2>, boolean canCastV1 extends IValue, V2 extends IValue> (T2 target, V1 value) Description copied from interface:IValueCastRegistry
Check if the the given value can be cast to the given type.- Specified by:
canCast
in interfaceIValueCastRegistry
- 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.
-