1
2
3
4
5
6 package dev.metaschema.core.metapath.impl;
7
8 import dev.metaschema.core.metapath.item.function.IMapKey;
9 import nl.talsmasoftware.lazy4j.Lazy;
10
11 public abstract class AbstractMapKey implements IMapKey {
12 private final Lazy<Integer> hashCode = Lazy.of(this::generateHashCode);
13
14 @Override
15 public int hashCode() {
16 return hashCode.get();
17 }
18
19
20
21
22
23
24 protected int generateHashCode() {
25 return getKey().hashCode();
26 }
27
28 @Override
29 public boolean equals(Object obj) {
30 return this == obj
31 || (obj instanceof IMapKey && isSameKey((IMapKey) obj));
32 }
33
34 @Override
35 public String toString() {
36 return getKey().toSignature();
37 }
38 }