jaskell.sql.Coalesce Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaskell-java8 Show documentation
Show all versions of jaskell-java8 Show documentation
This is a utils library for java 8 project.
It include parsec combinators and sql generators library.
package jaskell.sql;
import jaskell.script.Directive;
import jaskell.script.Parameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Coalesce implements Directive {
List _args = new ArrayList<>();
Coalesce(){
}
Coalesce(String names){
_args.addAll(Arrays.stream(names.split(","))
.map(String::trim)
.map(Name::new)
.collect(Collectors.toList()));
}
Coalesce(String... names){
_args.addAll(Arrays.stream(names).map(Name::new).collect(Collectors.toList()));
}
Coalesce(Directive... directives){
_args.addAll(Arrays.asList(directives));
}
public Coalesce coalesce(String names){
_args.addAll(Arrays.stream(names.split(","))
.map(String::trim)
.map(Name::new)
.collect(Collectors.toList()));
return this;
}
public Coalesce coalesce(String ... names){
_args.addAll(Arrays.stream(names).map(Name::new).collect(Collectors.toList()));
return this;
}
public Coalesce coalesce(Directive ... directives){
_args.addAll(Arrays.asList(directives));
return this;
}
@Override
public String script() {
return String.format("COALESCE(%s)",
_args.stream().map(Directive::script).collect(Collectors.joining(", ")));
}
@Override
public List> parameters() {
List> re = new ArrayList>();
_args.forEach(p->re.addAll(p.parameters()));
return re;
}
public Coalesce arg(Directive a){
_args.add(a);
return this;
}
public Coalesce args(Directive ... as){
_args.addAll(Arrays.asList(as));
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy