public final class PredicateKey extends Object implements Comparable<PredicateKey>
Term
.
Defines Term
s by their name (functor) and number of arguments (arity). This "metadata" or "descriptor
information" allows rules whose heads (consequences) share the same structure to be grouped together.
As Atom
and Structure
are the only subclasses of
Term
that can be the head (consequent) of a rule they are the only subclasses of
Term
that PredicateKey
is intended to describe.
PredicateKeys are constant; their values cannot be changed after they are created.
Constructor and Description |
---|
PredicateKey(String name,
int numArgs) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(PredicateKey o)
Ordered on name or, if names identical, number of arguments.
|
static PredicateKey |
createForTerm(Term t)
Returns a
PredicateKey for the specified term. |
static PredicateKey |
createFromNameAndArity(Term t) |
boolean |
equals(Object o) |
String |
getName() |
int |
getNumArgs() |
int |
hashCode() |
String |
toString() |
Term |
toTerm() |
public PredicateKey(String name, int numArgs)
public static PredicateKey createForTerm(Term t)
PredicateKey
for the specified term.t
- a term the returned PredicateKey
should represent (needs to have a Term.getType()
value
of TermType.ATOM
or TermType.STRUCTURE
)PredicateKey
for the specified term.ProjogException
- if t
is not of type TermType.ATOM
or TermType.STRUCTURE
public static PredicateKey createFromNameAndArity(Term t)
t
- must be a structure named /
where the first argument is the name of the predicate to represent
and the second (and final) argument is the arity.public String getName()
public int getNumArgs()
public Term toTerm()
public boolean equals(Object o)
public int compareTo(PredicateKey o)
compareTo
in interface Comparable<PredicateKey>
Copyright © 2024. All rights reserved.