io.polyglotted.elastic.search.Expression Maven / Gradle / Ivy
package io.polyglotted.elastic.search;
import io.polyglotted.common.model.MapResult.ImmutableResult;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Objects;
import static io.polyglotted.common.model.MapResult.immutableResult;
import static io.polyglotted.common.util.BaseSerializer.serialize;
import static io.polyglotted.common.util.ListBuilder.immutableList;
import static io.polyglotted.common.util.StrUtil.nullOrEmpty;
import static java.util.Objects.requireNonNull;
@RequiredArgsConstructor
public final class Expression {
static final Expression NilExpression = new Expression("_nil_", "_nil_", immutableResult());
static final String ValueKey = "_val";
public final String operation;
public final String label;
public final ImmutableResult args;
static Expression withMap(String operation, String label, ImmutableResult args) {
return new Expression(requireNonNull(operation), requireNonNull(label), args);
}
static Expression withValue(String expressionType, String label, Object valueArg) {
return new Expression(expressionType, requireNonNull(label), immutableResult(ValueKey, valueArg));
}
static > Expression withArray(String expressionType, String label, List valueArg) {
return new Expression(expressionType, requireNonNull(label), immutableResult(ValueKey, valueArg));
}
static Expression withLabel(String expressionType, String label) {
return new Expression(expressionType, requireNonNull(label), immutableResult());
}
T valueArg() { return argFor(ValueKey, null); }
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy