|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.struct.LpAbstractStructureUnit
lp.struct.LpRule
public class LpRule
Represents a logic programming rule. Each rule has a literal (represented by
a LpLiteral
instance) called its head and a set of such literals
(also represented by LpLiteral
instances) called its body. A rule can
have null
as its head (in that case it is an integrity constraint)
and it can have null
as its body (in that case it is a fact).
Field Summary | |
---|---|
private Set<LpLiteral> |
body
The rule's body. |
private LpLiteral |
head
The rule's head. |
Fields inherited from class lp.struct.LpAbstractStructureUnit |
---|
TO_STRING_BUFFER |
Constructor Summary | |
---|---|
LpRule(LpLiteral ruleHead,
Set<LpLiteral> ruleBody)
Creates a new instance of LpRule with the given ruleHead
and ruleBody . |
Method Summary | |
---|---|
void |
accept(LpStructureUnitVisitor visitor)
Accepts LpStructureUnitVisitor instance, i.e. calls its
visitor.visit(this) . |
boolean |
equals(Object obj)
Returns true if and only if
obj is a LpRule instance,
its head is equal to this rule's head, i.e. either they are
both null or they are equal according to
LpLiteral.equals(Object) ,
its body is equal to this rule's body, i.e. either they are both
null or one is null and the other has Set.size()
equal to 0 or they are equal according to
Set.equals(Object) . |
Set<LpLiteral> |
getBody()
Returns the list literals in the body of this rule. |
int |
getBodySize()
Returns the number of literals in this rule's body. |
LpLiteral |
getHead()
Returns the head of this rule, the same that was given to the constructor. |
int |
hashCode()
Overriden in order to maintain the general contract of Object.hashCode() . |
Methods inherited from class lp.struct.LpAbstractStructureUnit |
---|
toString, toUnmodifiableList, toUnmodifiableSet |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final LpLiteral head
private final Set<LpLiteral> body
Constructor Detail |
---|
public LpRule(LpLiteral ruleHead, Set<LpLiteral> ruleBody)
LpRule
with the given ruleHead
and ruleBody
. Both ruleHead
and ruleBody
can have
a null
value, but not at the same time.
Arguments of the constructor are not copied (especially the
ruleBody
Set
). This class is immutable as long as
ruleBody
is not changed after creating an instance.
ruleHead
- ruleHead of the new ruleruleBody
- ruleBody of the new rule
IllegalArgumentException
- if both ruleHead
and
ruleBody
are null
Method Detail |
---|
public LpLiteral getHead()
LpLiteral
given in the constructor as the head of
this rulepublic Set<LpLiteral> getBody()
public int getBodySize()
public void accept(LpStructureUnitVisitor visitor)
LpStructureUnitVisitor
instance, i.e. calls its
visitor.visit(this)
.
accept
in interface LpStructureUnit
visitor
- the visitor to acceptpublic boolean equals(Object obj)
true
if and only if
obj
is a LpRule
instance,null
or they are equal according to
LpLiteral.equals(Object)
,null
or one is null
and the other has Set.size()
equal to 0 or they are equal according to
Set.equals(Object)
.
equals
in interface LpTerm
equals
in class Object
obj
- the object to compare with
true
if this object is equal to obj
according to
the description above, and false
otherwiseLpLiteral.equals(Object)
,
Set.equals(Object)
public int hashCode()
Object.hashCode()
.
hashCode
in interface LpTerm
hashCode
in class Object
LpLiteral.hashCode()
,
Set.hashCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |