io.polyglotted.pgmodel.search.query.Expression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pg-model Show documentation
Show all versions of pg-model Show documentation
Standard set of models for geo coding, access control and elastic search abstraction
The newest version!
package io.polyglotted.pgmodel.search.query;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static io.polyglotted.pgmodel.util.ModelUtil.jsonEquals;
@RequiredArgsConstructor
public final class Expression {
public static final Expression NilExpression = new Expression("_nil_", "_nil_", ImmutableMap.of(), ImmutableList.of());
public static final String ValueKey = "_val";
public final String operation;
public final String label;
public final ImmutableMap args;
public final ImmutableList children;
public static Expression withMap(String operation, String label, java.util.Map args) {
return new Expression(checkNotNull(operation), checkNotNull(label), ImmutableMap.copyOf(args), ImmutableList.of());
}
public static Expression withValue(ExpressionType expressionType, String label, Object valueArg) {
return new Expression(expressionType.name(), checkNotNull(label), ImmutableMap.of(ValueKey, valueArg), ImmutableList.of());
}
public static > Expression withArray(ExpressionType expressionType, String label, List valueArg) {
return new Expression(expressionType.name(), checkNotNull(label), ImmutableMap.of(ValueKey, valueArg), ImmutableList.of());
}
public static Expression withOnlyChildren(ExpressionType expressionType, String label, Iterable list) {
return new Expression(expressionType.name(), checkNotNull(label), ImmutableMap.of(), ImmutableList.copyOf(list));
}
public static Expression withLabel(ExpressionType expressionType, String label) {
return new Expression(expressionType.name(), checkNotNull(label), ImmutableMap.of(), ImmutableList.of());
}
public T valueArg() {
return argFor(ValueKey, null);
}
public List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy