java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.variable.ValueCastRegistry
All Implemented Interfaces:
org.cyclops.cyclopscore.init.IRegistry, IValueCastRegistry

public final class ValueCastRegistry extends Object implements IValueCastRegistry
Registry for casting IValue.
  • Method Details

    • getInstance

      public static ValueCastRegistry getInstance()
      Returns:
      The unique instance.
    • size

      public int size()
      Specified by:
      size in interface IValueCastRegistry
    • register

      public <T1 extends IValueType<V1>, T2 extends IValueType<V2>, V1 extends IValue, V2 extends IValue> void register(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 interface IValueCastRegistry
      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>, V1 extends IValue, V2 extends IValue> V2 cast(T2 target, V1 value) throws IValueCastRegistry.ValueCastException
      Description copied from interface: IValueCastRegistry
      Cast the given value to the given type.
      Specified by:
      cast in interface IValueCastRegistry
      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>, V1 extends IValue, V2 extends IValue> boolean canCast(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 interface IValueCastRegistry
      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.