Class SimplificationWorker

java.lang.Object
tech.units.indriya.internal.simplify.SimplificationWorker

final class SimplificationWorker extends Object
Worker for the Simplifier.
Since:
2.0
Version:
1.0
  • Field Details

  • Constructor Details

  • Method Details

    • simplify

      public AbstractConverter simplify(List<? extends javax.measure.UnitConverter> conversionSteps)
      Description of a brute-force approach:

      Given 'conversionSteps' a list of converters, where order matters, we form a permutation group of all allowed permutations 'reachable' through 'allowed' swapping. Swapping is allowed for 2 consecutive converters that are both multiply transformations (x.isLinear()==true). We search this permutation group for any sequence of converters, that allows simplification:

      For every pair of consecutive converters within a sequence, check whether a simplification is possible (a.isSimpleCompositionWith(b)), then apply simplification and start over.

      Finally sort according to normal-form order.

      Parameters:
      conversionSteps -
      Returns:
    • trySimplify

      private int trySimplify()
    • sortToNormalFormOrder

      private static void sortToNormalFormOrder(AbstractConverter[] arrayOfConverters)
    • sequenceToConverter

      private static AbstractConverter sequenceToConverter(AbstractConverter[] sequence)