All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hcjf.bson.BsonPrimitive Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package org.hcjf.bson;

/**
 * Bson element that store a primitive value.
 * @author javaito
 */
public class BsonPrimitive extends BsonElement {

    private final BsonType type;

    /**
     * Defautl constructor.
     * @param name Name of the element.
     * @param value Value of the element.
     */
    public BsonPrimitive(String name, Object value) {
        super(name, value);
        this.type = BsonType.fromValue(value);
    }

    /**
     * Return the value of the element.
     * @return Value of the element.
     */
    public final Object get() {
        return getValue();
    }

    /**
     * Return the bson type that represent the implementation of the stored value.
     * @return Bson type.
     */
    public BsonType getType() {
        return type;
    }
}