jaskell.sql.Values 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 Values extends Statement {
Directive _insert;
List _fields = new ArrayList<>();
public Values(String fields){
_fields.addAll(
Arrays.stream(fields.split(",")).map(String::trim).map(Name::new).collect(Collectors.toList()));
}
public Values(String ... fields){
_fields.addAll(
Arrays.stream(fields).map(String::trim).map(Name::new).collect(Collectors.toList()));
}
public Values(Directive... fields){
_fields.addAll(Arrays.asList(fields));
}
@Override
public String script() {
return String.format("%s VALUES(%s)",
_insert.script(),
_fields.stream().map(Directive::script).collect(Collectors.joining(", ")));
}
@Override
public List> parameters() {
List> re = _insert.parameters();
_fields.forEach(field->re.addAll(field.parameters()));
return re;
}
public On on(){
On re = new On();
re._prefix = this;
return re;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy