1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.core.metapath.function;
7
8 import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
9
10 import java.util.stream.Stream;
11
12 import edu.umd.cs.findbugs.annotations.NonNull;
13
14 public interface IFunctionLibrary {
15
16 /**
17 * Retrieve the collection of function signatures in this library as a stream.
18 *
19 * @return a stream of function signatures
20 */
21 @NonNull
22 Stream<IFunction> stream();
23
24 /**
25 * Determine if there is a function with the provided namespace qualified name
26 * that supports the signature of the provided {@code arity}.
27 *
28 * @param name
29 * the namespace qualified name of a group of functions
30 * @param arity
31 * the count of arguments for use in determining an argument signature
32 * match
33 * @return {@code true} if a function signature matches or {@code false}
34 * otherwise
35 */
36 default boolean hasFunction(@NonNull IEnhancedQName name, int arity) {
37 return getFunction(name, arity) != null;
38 }
39
40 /**
41 * Retrieve the function with the provided namespace qualified name that
42 * supports the signature of the provided {@code arity}, if such a function
43 * exists.
44 *
45 * @param name
46 * the namespace qualified name of a group of functions
47 * @param arity
48 * the count of arguments for use in determining an argument signature
49 * match
50 * @return the matching function or {@code null} if no match exists
51 */
52 IFunction getFunction(@NonNull IEnhancedQName name, int arity);
53 }