public class IntegerElement extends AbstractElement implements NumericElement
Modifier and Type | Field and Description |
---|---|
static ElementType |
TYPE
The BSON type for a integer.
|
ELEMENT_TYPE
Constructor and Description |
---|
IntegerElement(String name,
int value)
Constructs a new
IntegerElement . |
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the
Visitor.visitInteger(java.lang.String, int) method. |
boolean |
equals(Object object)
Determines if the passed object is of this same type as this object and
if so that its fields are equal.
|
double |
getDoubleValue()
Returns the value cast to a double.
|
int |
getIntValue()
Returns the value cast to an integer.
|
long |
getLongValue()
Returns the value cast to a long.
|
ElementType |
getType()
Returns the type for the BSON type.
|
int |
getValue()
Returns the BSON integer value.
|
int |
hashCode()
Computes a reasonable hash code.
|
IntegerElement |
withName(String name)
Creates a new element with the same type and value as this element but
with the specified name.
|
asElement, find, find, findFirst, findFirst, getName, nullSafeEquals, queryPath, queryPath, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
find, find, findFirst, findFirst, getName, queryPath, queryPath
asElement
public static final ElementType TYPE
public IntegerElement(String name, int value)
IntegerElement
.name
- The name for the BSON integer.value
- The BSON integer value.IllegalArgumentException
- If the name
is null
.public void accept(Visitor visitor)
Visitor.visitInteger(java.lang.String, int)
method.accept
in interface Element
visitor
- The visitor for the element.Element.accept(Visitor)
public boolean equals(Object object)
equals
in class AbstractElement
object
- The object to compare to.Object.equals(java.lang.Object)
public double getDoubleValue()
Note: There may be a loss of precision using this method if the
NumericElement
is not a
DoubleElement
.
Overridden to return the integer value as a double.
getDoubleValue
in interface NumericElement
public int getIntValue()
Note: There may be a loss of precision using this method if the
NumericElement
is not a
IntegerElement
.
Overridden to return the integer value.
getIntValue
in interface NumericElement
public long getLongValue()
Note: There may be a loss of precision using this method if the
NumericElement
is not a
LongElement
.
Overridden to return the integer value as a long.
getLongValue
in interface NumericElement
public ElementType getType()
public int getValue()
public int hashCode()
hashCode
in class AbstractElement
public IntegerElement withName(String name)
Returns a new IntegerElement
.
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.