br.com.anteros.nosql.persistence.mongodb.aggregation.Accumulator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Anteros NoSQL Persistence MongoDB.
package br.com.anteros.nosql.persistence.mongodb.aggregation;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import java.util.ArrayList;
import java.util.List;
public class Accumulator implements AggregationElement {
private final String operation;
private final Object value;
public Accumulator(final String operation, final String field) {
this(operation, (Object) ("$" + field));
}
public Accumulator(final String operation, final Object field) {
this.operation = operation;
this.value = field;
}
public static Accumulator accumulator(final String operation, final String field) {
return new Accumulator(operation, field);
}
public static Accumulator accumulator(final String operation, final Object field) {
return new Accumulator(operation, field);
}
public String getOperation() {
return operation;
}
public Object getValue() {
return value;
}
@Override
public DBObject toDBObject() {
BasicDBObject dbObject = new BasicDBObject();
if (value instanceof List) {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy