com.github.chengyuxing.sql.yaml.FeaturedConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rabbit-sql Show documentation
Show all versions of rabbit-sql Show documentation
Light wrapper of JDBC, support ddl, dml, query, plsql/procedure/function, transaction and manage sql
file.
package com.github.chengyuxing.sql.yaml;
import com.github.chengyuxing.common.script.expression.Patterns;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.AbstractConstruct;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Yaml custom tag for string join constructor.
*/
public class FeaturedConstructor extends Constructor {
private final static Pattern VAR_PATTERN = Pattern.compile("\\$\\{\\s*(" + Patterns.VAR_KEY_PATTERN + ")\\s*}");
public FeaturedConstructor() {
super(new LoaderOptions());
this.yamlConstructors.put(new Tag("!join"), new ConstructJoin(""));
this.yamlConstructors.put(new Tag("!path"), new ConstructJoin("/"));
this.setPropertyUtils(new HyphenatedPropertyUtil());
}
@Override
protected String constructScalar(ScalarNode node) {
String value = super.constructScalar(node);
return resolveHolders(value);
}
@Override
protected List> constructSequence(SequenceNode node) {
//noinspection unchecked
List