![JAR search and dependency download from the Maven repository](/logo.png)
com.github.tonivade.puredbc.sql.SQL1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of puredbc Show documentation
Show all versions of puredbc Show documentation
Pure Functional Database Connection Layer
The newest version!
/*
* Copyright (c) 2020-2024, Antonio Gabriel Muñoz Conejo
* Distributed under the terms of the MIT License
*/
package com.github.tonivade.puredbc.sql;
import static com.github.tonivade.purefun.core.Precondition.checkNonEmpty;
import static com.github.tonivade.purefun.data.Sequence.arrayOf;
public final class SQL1 {
private final String query;
protected SQL1(String query) {
this.query = checkNonEmpty(query);
}
public SQL bind(A a) {
return new SQL(query, arrayOf(a));
}
public SQL1 from(SQL other) {
return new SQL1<>(other.getQuery() + " from (" + query + ")");
}
public SQL2 and(Condition condition) {
return new SQL2<>(query + " and " + condition.expression());
}
public SQL2 where(Condition condition) {
return new SQL2<>(query + " where " + condition.expression());
}
public SQL1 groupBy(Field field) {
return new SQL1<>(query + " group by " + field.render());
}
public SQL1 orderBy(Field field) {
return new SQL1<>(query + " order by " + field.render());
}
public SQL1 asc() {
return new SQL1<>(query + " asc");
}
public SQL1 desc() {
return new SQL1<>(query + " desc");
}
public SQL1 limit(int limit) {
return new SQL1<>(query + " limit " + limit);
}
public SQL1 offset(int offset) {
return new SQL1<>(query + " offset " + offset);
}
@Override
public String toString() {
return String.format("SQL1{query='%s'}", query);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy