|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.struct.LpAbstractStructureUnit
lp.struct.LpVariable
public class LpVariable
Represents a variable in logic programming. Variables are, together with
function symbols and constants (see LpFunction
and
LpConstant
) building units of terms (see LpTerm
). Each
variable has a unique non-empty name.
LpTerm
Field Summary | |
---|---|
private String |
name
This variable's name. |
private static Map<String,LpVariable> |
pool
A pool of instances of this immutable class. |
Fields inherited from class lp.struct.LpAbstractStructureUnit |
---|
TO_STRING_BUFFER |
Constructor Summary | |
---|---|
protected |
LpVariable(String name)
Creates a new instance of LpVariable with the given name. |
Method Summary | |
---|---|
void |
accept(LpStructureUnitVisitor visitor)
Accepts LpStructureUnitVisitor instance, i.e. calls
visitor.visit(this) . |
boolean |
equals(Object obj)
Returns true if and only if
obj is a LpVariable instance,
its name is equal to this variable's name as
defined by String.equals(Object) ,
|
static LpVariable |
getInstance(String name)
Returns an instance of LpVariable with the given name. |
String |
getName()
Returns this variable's name, 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 static final Map<String,LpVariable> pool
getInstance(String)
method first looks here for the requested
instances and if it is forced to create a new one, it is added to this
pool.
private final String name
Constructor Detail |
---|
protected LpVariable(String name)
LpVariable
with the given name.
name
- the new variable's name
IllegalArgumentException
- if name
is null
or an
empty stringMethod Detail |
---|
public static LpVariable getInstance(String name)
LpVariable
with the given name.
name
- the requested variable's name
IllegalArgumentException
- if name
is null
or an
empty stringpublic String getName()
public void accept(LpStructureUnitVisitor visitor)
LpStructureUnitVisitor
instance, i.e. calls
visitor.visit(this)
.
accept
in interface LpStructureUnit
visitor
- the visitor to acceptpublic boolean equals(Object obj)
true
if and only if
obj
is a LpVariable
instance,String.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
otherwiseString.equals(Object)
,
LpTerm.equals(Object)
public int hashCode()
Object.hashCode()
.
hashCode
in interface LpTerm
hashCode
in class Object
String.hashCode()
,
LpTerm.equals(Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |