com.aerospike.jdbc.predicate.QueryPredicateBinary Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-jdbc Show documentation
Show all versions of aerospike-jdbc Show documentation
A JDBC driver for the Aerospike database
The newest version!
package com.aerospike.jdbc.predicate;
import com.aerospike.client.exp.Exp;
import com.aerospike.client.query.Filter;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
public class QueryPredicateBinary extends QueryPredicateBase {
private final Operator operator;
private final Object value;
public QueryPredicateBinary(String binName, Operator operator, Object value) {
super(binName, getValueType(value));
this.operator = operator;
this.value = value;
}
@Override
public Exp toFilterExpression(boolean withPrimaryKey) {
if (isPrimaryKeyPredicate() && !withPrimaryKey) {
return null;
}
return operator.exp(buildLeftExp(), getValueExp(value));
}
@Override
public Optional toFilter(String binName) {
if (binName.equals(this.binName) && operator == OperatorBinary.EQ) {
if (valueType == Exp.Type.INT) {
return Optional.of(Filter.equal(binName, (long) value));
} else if (valueType == Exp.Type.STRING) {
return Optional.of(Filter.equal(binName, (String) value));
}
}
return Optional.empty();
}
@Override
public Collection
© 2015 - 2024 Weber Informatics LLC | Privacy Policy