1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package io.github.prolobjectlink.prolog.jlog;
23
24 import java.util.Map.Entry;
25
26 import io.github.prolobjectlink.prolog.PrologEntry;
27 import io.github.prolobjectlink.prolog.PrologProvider;
28 import io.github.prolobjectlink.prolog.PrologTerm;
29 import io.github.prolobjectlink.prolog.PrologTermType;
30
31
32
33
34
35
36
37
38 public final class JLogEntry extends JLogTerm implements PrologEntry {
39
40 private final PrologTerm key;
41 private PrologTerm value;
42
43 JLogEntry(PrologProvider provider, PrologTerm key, PrologTerm value) {
44 super(PrologTermType.MAP_ENTRY_TYPE, provider);
45 this.value = value;
46 this.key = key;
47 }
48
49 public PrologTerm getKey() {
50 return key;
51 }
52
53 public PrologTerm getValue() {
54 return value;
55 }
56
57 public PrologTerm setValue(PrologTerm value) {
58 this.value = value;
59 return value;
60 }
61
62 public int getArity() {
63 return 2;
64 }
65
66 public String getFunctor() {
67 return "-";
68 }
69
70 public PrologTerm[] getArguments() {
71 return new PrologTerm[] { key, value };
72 }
73
74 @Override
75 public int hashCode() {
76 int result = 0;
77 final int prime = 31;
78 result = prime * result + ((key == null) ? 0 : key.hashCode());
79 result = prime * result + ((value == null) ? 0 : value.hashCode());
80 return result;
81 }
82
83 @Override
84 public boolean equals(Object obj) {
85 if (this == obj)
86 return true;
87 if (obj == null)
88 return false;
89 if (getClass() != obj.getClass())
90 return false;
91 JLogEntry other = (JLogEntry) obj;
92 if (key == null) {
93 if (other.key != null)
94 return false;
95 } else if (!key.equals(other.key)) {
96 return false;
97 }
98 if (value == null) {
99 if (other.value != null)
100 return false;
101 } else if (!value.equals(other.value)) {
102 return false;
103 }
104 return true;
105 }
106
107 @Override
108 public String toString() {
109 return "" + key + "-" + value + "";
110 }
111
112 @Override
113 public PrologTerm getTerm() {
114 return this;
115 }
116
117 @Override
118 public boolean isEvaluable() {
119 return false;
120 }
121
122 @Override
123 public boolean isCompound() {
124 return true;
125 }
126
127 }