Interface CalculatorInputChecker

All Superinterfaces:
Function<Molecule,List<CalculatorError>>, TaggedCalculatorInputChecker
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Instances of this interface are used by calculators to check if they can process an input molecule. Calculators can use multiple checkers, which validate different properties of the input.

This interface extends TaggedCalculatorInputChecker and implements its only method by delegating to apply(Molecule).

  • Method Details

    • of

      static CalculatorInputChecker of(String errorMessage, Predicate<Molecule> predicate)
      Creates a new input checker that accepts those molecules which satisfy the given lambda.
      Parameters:
      errorMessage - the message of the error to report if the molecule fails the predicate
      predicate - a lambda to check the molecule
      Returns:
      the new checker
    • heavyAtomLimit

      static CalculatorInputChecker heavyAtomLimit(int maximumHeavyAtoms)
      Creates a new input checker that only accepts molecules with at most the given number of heavy atoms.
      Parameters:
      maximumHeavyAtoms - the maximum allowed number of heavy atoms in input molecules
      Returns:
      the new checker
    • combine

      static CalculatorInputChecker combine(Collection<? extends CalculatorInputChecker> checkers)
      Combines the given checkers into a single one that reports all errors reported by the given checkers.
      Parameters:
      checkers - the checkers to combine
      Returns:
      the new checker
    • apply

      List<CalculatorError> apply(Molecule molecule)
      Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.
      Specified by:
      apply in interface Function<Molecule,List<CalculatorError>>
      Parameters:
      molecule - the input molecule
      Returns:
      a list of found errors, typically empty or containing a single element
    • apply

      default List<CalculatorError> apply(TaggedCalculator calculator, Molecule molecule)
      Description copied from interface: TaggedCalculatorInputChecker
      Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.

      Apart from the molecule that should be checked, this method also receives the calculator instance.

      Specified by:
      apply in interface TaggedCalculatorInputChecker
      Parameters:
      calculator - the calculator instance
      molecule - the input molecule
      Returns:
      a list of found errors, typically empty or containing a single element