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.Objects;
9   
10  import edu.umd.cs.findbugs.annotations.NonNull;
11  
12  class ArgumentImpl implements IArgument {
13    @NonNull
14    private final String name;
15    @NonNull
16    private final ISequenceType sequenceType;
17  
18    protected ArgumentImpl(@NonNull String name, @NonNull ISequenceType sequenceType) {
19      this.name = name;
20      this.sequenceType = sequenceType;
21    }
22  
23    @Override
24    public String getName() {
25      return name;
26    }
27  
28    @Override
29    public ISequenceType getSequenceType() {
30      return sequenceType;
31    }
32  
33    @SuppressWarnings("null")
34    @Override
35    public String toSignature() {
36      StringBuilder builder = new StringBuilder();
37  
38      // name
39      builder.append(getName())
40          .append(" as ")
41          .append(getSequenceType().toSignature());
42  
43      return builder.toString();
44    }
45  
46    @Override
47    public int hashCode() {
48      return Objects.hash(name, sequenceType);
49    }
50  
51    @Override
52    public boolean equals(Object obj) {
53      if (this == obj) {
54        return true; // NOPMD - readability
55      }
56      if (obj == null) {
57        return false; // NOPMD - readability
58      }
59      if (getClass() != obj.getClass()) {
60        return false; // NOPMD - readability
61      }
62      ArgumentImpl other = (ArgumentImpl) obj;
63      return Objects.equals(name, other.name) && Objects.equals(sequenceType, other.sequenceType);
64    }
65  }