|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.struct.LpAbstractStructureUnit
lp.struct.LpConstant
public class LpConstant
Represents a constant in logic programming. Constants are, together with
function symbols and variables (see LpFunction
and
LpVariable
) building units of terms (see LpTerm
. Each
constant has a unique non-empty name. LpConstant
s are immutable.
LpTerm
Field Summary | |
---|---|
private String |
name
This constant's name. |
private static Map<String,LpConstant> |
pool
A pool of instances of this immutable class. |
Fields inherited from class lp.struct.LpAbstractStructureUnit |
---|
TO_STRING_BUFFER |
Constructor Summary | |
---|---|
protected |
LpConstant(String name)
Creates a new instance of LpConstant 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 LpConstant instance,
its name is equal to this constant's name as
defined by String.equals(Object) ,
|
static LpConstant |
getInstance(String name)
Returns an instance of LpConstant with the given name. |
String |
getName()
Returns this constant'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,LpConstant> 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 LpConstant(String name)
LpConstant
with the given name.
name
- the new constant's name
IllegalArgumentException
- if name
is null
or an
empty stringMethod Detail |
---|
public static LpConstant getInstance(String name)
LpConstant
with the given name.
name
- the requested constant'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 LpConstant
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 |