1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.core.metapath.impl;
7   
8   import gov.nist.secauto.metaschema.core.metapath.function.IFunction;
9   import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
10  import gov.nist.secauto.metaschema.core.metapath.type.ISequenceType;
11  import gov.nist.secauto.metaschema.core.metapath.type.Occurrence;
12  import gov.nist.secauto.metaschema.core.util.ObjectUtils;
13  
14  import java.util.EnumSet;
15  import java.util.Set;
16  
17  import edu.umd.cs.findbugs.annotations.NonNull;
18  
19  /**
20   * Provides default methods for node items that represent collections of
21   * Metapath items and sequences.
22   */
23  public interface IFeatureCollectionFunctionItem extends IFunction {
24    /**
25     * The function properties.
26     */
27    @NonNull
28    Set<FunctionProperty> PROPERTIES = ObjectUtils.notNull(
29        EnumSet.of(FunctionProperty.DETERMINISTIC));
30    /**
31     * The function result.
32     */
33    @NonNull
34    ISequenceType RESULT = ISequenceType.of(
35        IAnyAtomicItem.type(), Occurrence.ZERO_OR_ONE);
36  
37    @Override
38    default boolean isDeterministic() {
39      return true;
40    }
41  
42    @Override
43    default boolean isContextDepenent() {
44      return false;
45    }
46  
47    @Override
48    default boolean isFocusDependent() {
49      return false;
50    }
51  
52    @Override
53    default Set<FunctionProperty> getProperties() {
54      return PROPERTIES;
55    }
56  
57    @Override
58    default int arity() {
59      return 1;
60    }
61  
62    @Override
63    default boolean isArityUnbounded() {
64      return false;
65    }
66  
67    @Override
68    default ISequenceType getResult() {
69      return RESULT;
70    }
71  
72    @Override
73    default boolean isNamedFunction() {
74      // these functions are not named, since they refer to anonymous collections
75      return false;
76    }
77  }