public class MongoTimestampElement extends AbstractElement
Modifier and Type | Field and Description |
---|---|
static ElementType |
TYPE
The BSON type for a long.
|
ELEMENT_TYPE
Constructor and Description |
---|
MongoTimestampElement(String name,
long value)
Constructs a new
MongoTimestampElement . |
MongoTimestampElement(String name,
long value,
long size)
Constructs a new
MongoTimestampElement . |
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the
Visitor.visitMongoTimestamp(java.lang.String, long)
method. |
int |
compareTo(Element otherElement) |
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.
|
long |
getTime()
Returns the BSON Mongo timestamp value as 4 byte increment and 4 byte
timestamp.
|
ElementType |
getType()
Returns the type for the BSON type.
|
Long |
getValueAsObject()
Returns the value for BSON element as a Java
Object type. |
int |
hashCode()
Computes a reasonable hash code.
|
MongoTimestampElement |
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, getValueAsString, nullSafeEquals, size, toString
public static final ElementType TYPE
public MongoTimestampElement(String name, long value)
MongoTimestampElement
.name
- The name for the BSON long.value
- The BSON timestamp value as 4 byte increment and 4 byte
timestamp.IllegalArgumentException
- If the name
is null
.public MongoTimestampElement(String name, long value, long size)
MongoTimestampElement
.name
- The name for the BSON long.value
- The BSON timestamp value as 4 byte increment and 4 byte
timestamp.size
- The size of the element when encoded in bytes. If not known
then use the
MongoTimestampElement(String, long)
constructor instead.IllegalArgumentException
- If the name
is null
.public void accept(Visitor visitor)
Visitor.visitMongoTimestamp(java.lang.String, long)
method.visitor
- The visitor for the element.Element.accept(Visitor)
public int compareTo(Element otherElement)
Overridden to compare the elements based on the tuple (name, type, value).
Overridden to compare the elements based on the tuple (name, type). Derived classes are responsible for the value portion of the full comparison.
Overridden to compare the times if the base class comparison is equals.
Note that for MongoDB MongoTimestampElement
and
TimestampElement
will return equal based on the type. Care is
taken here to make sure that the values return the same value regardless
of comparison order.
compareTo
in interface Element
compareTo
in interface Comparable<Element>
compareTo
in class AbstractElement
public boolean equals(Object object)
equals
in class AbstractElement
object
- The object to compare to.Object.equals(java.lang.Object)
public long getTime()
public ElementType getType()
public Long getValueAsObject()
Object
type.
Automatic conversion from the Object-ified value to an element is
provided via the DocumentBuilder.add(String, Object)
method. Not
all element types will be successfully converted to the same element
duing a Element-->Object value-->Element conversion. This cases are noted
in the appropriate sub-type's JavaDoc.
Sub-types will also overload this method with the appropriate type
returned. e.g., The
StringElement.getValueAsObject()
method signature returns a String
.
Returns a Long
with the value of the timestamp.
Note: This value will not be recreated is a Object-->Element conversion. Long with the value of the timestamp is created instead.
Object
type.public int hashCode()
hashCode
in class AbstractElement
public MongoTimestampElement withName(String name)
Returns a new MongoTimestampElement
.
name
- The new name for the element.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.