public final class Var<E> extends ImmutableBOp implements IVariable<E>, Comparable<IVariable<E>>
Note: This implementation provides reference testing for equality. The rest of the package assumes that it can use reference testing for equality when comparing variables.
BOp.Annotations
DEFAULT_INITIAL_CAPACITY
Modifier and Type | Method and Description |
---|---|
Var<E> |
clone()
Clone is overridden to prevent variables from becoming aliased (this is
part of the canonicalizing mapping).
|
int |
compareTo(IVariable<E> o)
Orders variables alphabetically.
|
boolean |
equals(IVariableOrConstant<E> o)
Return
true if this is the same variable or if both values
are Constant whose values are the same. |
boolean |
equals(Object o)
true if all arguments and annotations are the same. |
E |
get()
Return the bound value.
|
E |
get(IBindingSet bindingSet)
Return the as bound value of the variable, constant, or
expression.
|
String |
getName()
Return the name of a variable.
|
int |
hashCode()
The hash code is based on the hash of the operands (cached).
|
boolean |
isAnonymous()
Return
true iff this is an anonymous variable. |
boolean |
isConstant()
Return
true iff this is a constant. |
boolean |
isVar()
Return
true iff this is a variable. |
boolean |
isWildcard()
Return
true iff this is the special variable * |
void |
setAnonymous(boolean anonymous) |
String |
toString()
Return a non-recursive representation of the arguments and annotations
for this
BOp . |
static Var<?> |
var()
Generate an anonymous random variable.
|
static Var |
var(String name)
Singleton factory for
Var s. |
_clearProperty, _setProperty
__replaceArg, _set, annotations, annotationsCopy, annotationsEqual, annotationsRef, argIterator, args, argsCopy, arity, clearAnnotations, clearProperty, deepCopy, deepCopy, get, getProperty, setArg, setProperty, setUnboundProperty, toArray, toArray
annotationsEqual, annotationsToString, annotationsToString, annotationValueToString, checkArgs, getEvaluationContext, getId, getProperty, getRequiredProperty, indent, isController, mutation, shortenName, toShortString, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
toString
annotations, argIterator, args, arity, get, getEvaluationContext, getId, getProperty, getRequiredProperty, isController, setProperty, toArray, toArray, toShortString
getProperty
public void setAnonymous(boolean anonymous)
public boolean isAnonymous()
IVariable
true
iff this is an anonymous variable.isAnonymous
in interface IVariable<E>
public final boolean isVar()
IVariableOrConstant
true
iff this is a variable.isVar
in interface IVariableOrConstant<E>
public final boolean isConstant()
IVariableOrConstant
true
iff this is a constant.isConstant
in interface IVariableOrConstant<E>
public final Var<E> clone()
clone
in interface BOp
clone
in class CoreBaseBOp
public final boolean equals(IVariableOrConstant<E> o)
IVariableOrConstant
true
if this is the same variable or if both values
are Constant
whose values are the same.equals
in interface IVariableOrConstant<E>
public final boolean equals(Object o)
CoreBaseBOp
true
if all arguments and annotations are the same.equals
in class CoreBaseBOp
public final int hashCode()
CoreBaseBOp
hashCode
in interface IVariable<E>
hashCode
in class CoreBaseBOp
public String toString()
CoreBaseBOp
BOp
.toString
in interface BOp
toString
in class CoreBaseBOp
public boolean isWildcard()
IVariable
true
iff this is the special variable *
isWildcard
in interface IVariable<E>
public E get()
IVariableOrConstant
get
in interface IVariableOrConstant<E>
public E get(IBindingSet bindingSet)
IValueExpression
IConstant
is the
contant's value. The as bound value of an IVariable
is the
bound value in the given IBindingSet
-or- null
if
the variable is not bound in the IBindingSet
.get
in interface IValueExpression<E>
bindingSet
- The binding set.public String getName()
IVariableOrConstant
getName
in interface IVariableOrConstant<E>
public static Var<?> var()
public static Var var(String name)
Var
s.
Note: While only a single instance of a variable object will be created for any given variable name, the "scope" of the variable is always constrained by the rule within which it is used. The purpose of the singleton factory is to let us test for the same variable using "==" (reference testing) and also to have a shorthand for variable creation.
name
- The variable name.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.