Interface CalculatorInputChecker

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

    @PublicAPI
    @FunctionalInterface
    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.
        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 of 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