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.
  • Method Details

    • size

      int size()
    • register

      <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)
      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>, V1 extends IValue, V2 extends IValue> V2 cast(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>, V1 extends IValue, V2 extends IValue> boolean canCast(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.