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 java.util.stream.Stream; 9 10 import javax.xml.namespace.QName; 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 name that supports the 26 * signature of the provided {@code arity}. 27 * 28 * @param name 29 * the 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 String name, int arity) { 37 return getFunction(name, arity) != null; 38 } 39 40 /** 41 * Determine if there is a function with the provided namespace qualified name 42 * that supports the signature of the provided {@code arity}. 43 * 44 * @param name 45 * the namespace qualified name of a group of functions 46 * @param arity 47 * the count of arguments for use in determining an argument signature 48 * match 49 * @return {@code true} if a function signature matches or {@code false} 50 * otherwise 51 */ 52 default boolean hasFunction(@NonNull QName name, int arity) { 53 return getFunction(name, arity) != null; 54 } 55 56 /** 57 * Retrieve the function with the provided name that supports the signature of 58 * the provided {@code arity}, if such a function exists. 59 * 60 * @param name 61 * the name of a group of functions 62 * @param arity 63 * the count of arguments for use in determining an argument signature 64 * match 65 * @return the matching function or {@code null} if no match exists 66 */ 67 IFunction getFunction(@NonNull String name, int arity); 68 69 /** 70 * Retrieve the function with the provided namespace qualified name that 71 * supports the signature of the provided {@code arity}, if such a function 72 * exists. 73 * 74 * @param name 75 * the namespace qualified name of a group of functions 76 * @param arity 77 * the count of arguments for use in determining an argument signature 78 * match 79 * @return the matching function or {@code null} if no match exists 80 */ 81 IFunction getFunction(@NonNull QName name, int arity); 82 }