Package chemaxon.calculator
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.
@PublicApi
@FunctionalInterface
public interface CalculatorInputChecker
extends Function<Molecule,List<CalculatorError>>, TaggedCalculatorInputChecker
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 Summary
Modifier and TypeMethodDescriptiondefault List<CalculatorError>
apply
(TaggedCalculator calculator, Molecule molecule) Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.static CalculatorInputChecker
combine
(Collection<? extends CalculatorInputChecker> checkers) Combines the given checkers into a single one that reports all errors reported by the given checkers.static CalculatorInputChecker
heavyAtomLimit
(int maximumHeavyAtoms) Creates a new input checker that only accepts molecules with at most the given number of heavy atoms.static CalculatorInputChecker
Creates a new input checker that accepts those molecules which satisfy the given lambda.
-
Method Details
-
of
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 predicatepredicate
- a lambda to check the molecule- Returns:
- the new checker
-
heavyAtomLimit
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
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
Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.- Specified by:
apply
in interfaceFunction<Molecule,
List<CalculatorError>> - Parameters:
molecule
- the input molecule- Returns:
- a list of found errors, typically empty or containing a single element
-
apply
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 interfaceTaggedCalculatorInputChecker
- Parameters:
calculator
- the calculator instancemolecule
- the input molecule- Returns:
- a list of found errors, typically empty or containing a single element
-