Interface CalculatorInputChecker

  • All Superinterfaces:
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    public interface CalculatorInputChecker
    extends Function<Molecule,​List<CalculatorError>>
    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.
    • Method Detail

      • of

        static CalculatorInputChecker of​(String errorMessage,
                                         Predicate<Molecule> predicate)
        Creates a new input checker that accepts those molecules which satisfy the given lambda.
        errorMessage - the message of the error to report if the molecule fails the predicate
        predicate - a lambda to check the molecule
        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.
        maximumHeavyAtoms - the maximum allowed number of heavy atoms in input molecules
        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.
        checkers - the checkers to combine
        the new checker
      • apply

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