com.jaregu.database.queries.compiling.expr.Constant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of queries Show documentation
Show all versions of queries Show documentation
Java based SQL templating project. Store your queries in *.sql files and build queries for execution. Supports simple expressions and conditional clauses and interface proxying for java-sql bridge.
package com.jaregu.database.queries.compiling.expr;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
public interface Constant extends Operand {
static final List>> STRING_PARSERS = Arrays.asList(ConstantNull::parse,
ConstantBoolean::parse, ConstantString::parse, ConstantInteger::parse, ConstantLong::parse,
ConstantDecimal::parse);
static final List>> VALUE_PARSERS = Arrays.asList(ConstantNull::of,
ConstantBoolean::of, ConstantString::of, ConstantInteger::of, ConstantLong::of, ConstantDecimal::of);
public static Optional parse(String value) {
for (Function> parser : STRING_PARSERS) {
Optional result = parser.apply(value);
if (result.isPresent()) {
return result;
}
}
return Optional.empty();
}
public static Constant of(Object value) {
for (Function