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 /**
15 * Provides access to a collection of Metapath function signatures.
16 */
17 public interface IFunctionLibrary {
18
19 /**
20 * Retrieve the collection of function signatures in this library as a stream.
21 *
22 * @return a stream of function signatures
23 */
24 @NonNull
25 Stream<IFunction> stream();
26
27 /**
28 * Determine if there is a function with the provided namespace qualified name
29 * that supports the signature of the provided {@code arity}.
30 *
31 * @param name
32 * the namespace qualified name of a group of functions
33 * @param arity
34 * the count of arguments for use in determining an argument signature
35 * match
36 * @return {@code true} if a function signature matches or {@code false}
37 * otherwise
38 */
39 default boolean hasFunction(@NonNull IEnhancedQName name, int arity) {
40 return getFunction(name, arity) != null;
41 }
42
43 /**
44 * Retrieve the function with the provided namespace qualified name that
45 * supports the signature of the provided {@code arity}, if such a function
46 * exists.
47 *
48 * @param name
49 * the namespace qualified name of a group of functions
50 * @param arity
51 * the count of arguments for use in determining an argument signature
52 * match
53 * @return the matching function or {@code null} if no match exists
54 */
55 IFunction getFunction(@NonNull IEnhancedQName name, int arity);
56 }