Interface Conversion<Input,Output>


public interface Conversion<Input,Output>
Represent a conversion factor from any measurement to another.

For instance you can have a Conversion<Double, Double> which could convert between motor RPM to wheel MPS

  • Method Details

    • create

      static <I, O> Conversion<I,O> create(Function<I,O> inputToOutput, Function<O,I> outputToInput)
      Creates a Conversion<I, O> object.
      Type Parameters:
      I - Input class type.
      O - Output class type.
      Parameters:
      inputToOutput - Function<I, O> which converts input measurement to output measurement.
      outputToInput - Function<O, I> which converts output measurement to input measurement.
      Returns:
      A Conversion object representing the two functions.
    • invert

      default Conversion<Output,Input> invert()
      Returns:
      A new Conversion object which flips the input and output of this object such that Conversion<I, O>.invert() would return Conversion<O, I>.
    • fromInput

      Output fromInput(Input input)
      Parameters:
      input - Measurement representing type Input to convert to type Output.
      Returns:
      Type Output converted from Input.
    • fromOutput

      Input fromOutput(Output output)
      Parameters:
      output - Measurement representing type Output to convert to type Input.
      Returns:
      Type Input converted from Output.