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 io.github.prolobjectlink.prolog.AbstractClause;
25 import io.github.prolobjectlink.prolog.PrologClause;
26 import io.github.prolobjectlink.prolog.PrologIndicator;
27 import io.github.prolobjectlink.prolog.PrologProvider;
28 import io.github.prolobjectlink.prolog.PrologTerm;
29
30
31
32
33
34
35 class JLogClause extends AbstractClause implements PrologClause {
36
37 private final PrologIndicator indicator;
38
39 protected JLogClause(PrologProvider provider, PrologTerm head, boolean dynamic, boolean multifile,
40 boolean discontiguous) {
41 super(provider, head, dynamic, multifile, discontiguous);
42 this.indicator = new JLogIndicator(head.getFunctor(), head.getArity());
43 }
44
45 protected JLogClause(PrologProvider provider, PrologTerm head, PrologTerm body, boolean dynamic, boolean multifile,
46 boolean discontiguous) {
47 super(provider, head, body, dynamic, multifile, discontiguous);
48 this.indicator = new JLogIndicator(head.getFunctor(), head.getArity());
49 }
50
51 public PrologIndicator getPrologIndicator() {
52 return indicator;
53 }
54
55 @Override
56 public int hashCode() {
57 final int prime = 31;
58 int result = super.hashCode();
59 result = prime * result + ((indicator == null) ? 0 : indicator.hashCode());
60 return result;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj)
66 return true;
67 if (!super.equals(obj))
68 return false;
69 if (getClass() != obj.getClass())
70 return false;
71 JLogClause other = (JLogClause) obj;
72 if (indicator == null) {
73 if (other.indicator != null)
74 return false;
75 } else if (!indicator.equals(other.indicator)) {
76 return false;
77 }
78 return true;
79 }
80
81 }