Class PlatformConverter

java.lang.Object
net.tnemc.item.platform.conversion.PlatformConverter

public class PlatformConverter extends Object
PlatformConverter is used for converting TNIL-based data strings to the Platform's enum/registry entries.
Since:
0.2.0.0
Author:
creatorfromhell
  • Constructor Details

  • Method Details

    • registerConversion

      public <I, O> void registerConversion(Class<I> inputClass, Class<O> outputClass, Function<I,O> converter)
      Registers a conversion between input and output classes using a provided converter function.
      Type Parameters:
      I - The input class type
      O - The output class type
      Parameters:
      inputClass - The class of the input object to convert from
      outputClass - The class of the output object to convert to
      converter - The function that performs the conversion from input to output
      Since:
      0.2.0.0, 0.2.0.0
    • convert

      public <I, O> O convert(I input, Class<O> outputClass)
      Performs a conversion from input type to output type using registered converters.
      Type Parameters:
      I - The type of the input object
      O - The class of the output object
      Parameters:
      input - The input object to be converted
      outputClass - The class of the output type to be converted to
      Returns:
      The converted output object
      Throws:
      IllegalArgumentException - if the input is null or if no conversion is registered for the specified types
      Since:
      0.2.0.0, 0.2.0.0