-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLiteral.java
103 lines (83 loc) · 1.96 KB
/
Literal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Represents a literal; a variable
*/
public class Literal implements Comparable<Literal>
{
//The name of the literal
private String Name;
//Whether or not the literal is negated; if negation is true then it is negated
private boolean negation;
// whether has been inferred by pl-fc-entails
private boolean inferred;
public Literal(String n, boolean neg)
{
this.Name = n;
this.negation = neg;
this.inferred = false; // initially false
}
public void print()
{
if(negation)
System.out.print("NOT_" + Name);
else
System.out.print(Name);
}
public void setName(String n)
{
this.Name = n;
}
public String getName()
{
return this.Name;
}
public void setNeg(boolean b)
{
this.negation = b;
}
public boolean getNeg()
{
return this.negation;
}
public void setInferred() {
this.inferred = true;
}
public boolean isInferred() {
return this.inferred;
}
//Override
public boolean equals(Object obj)
{
Literal l = (Literal)obj;
if(l.getName().compareTo(this.Name) ==0 && l.getNeg() == this.negation)
{
return true;
}
else
{
return false;
}
}
//@Override
public int hashCode()
{
if(this.negation)
{
return this.Name.hashCode() + 1;
}
else
{
return this.Name.hashCode() + 0;
}
}
//@Override
public int compareTo(Literal x)
{
int a = 0;
int b = 0;
if(x.getNeg())
a = 1;
if(this.getNeg())
b = 1;
return x.getName().compareTo(Name) + a-b;
}
}