protobuf4j.orm.sql.UpdateSql Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protobuf4j-sql Show documentation
Show all versions of protobuf4j-sql Show documentation
A Facility Framework to Develop with Google Protobuf
The newest version!
package protobuf4j.orm.sql;
import lombok.Data;
import lombok.NonNull;
import protobuf4j.orm.sql.clause.SetClause;
import protobuf4j.orm.sql.clause.WhereClause;
import javax.annotation.Nonnull;
import java.util.List;
/**
* author: yuanwq
* date: 2018/7/15
*/
@Data
public class UpdateSql extends AbstractSqlObject implements ISqlStatement {
@NonNull
private final ITableRef table;
@NonNull
private final SetClause set;
private WhereClause where;
/**
* create {@link WhereClause} if necessary
*/
public WhereClause where() {
if (this.where == null) {
this.where = new WhereClause();
}
return this.where;
}
@Override
public StringBuilder toSqlTemplate(@Nonnull StringBuilder sb) {
sb.append("UPDATE ");
table.toSqlTemplate(sb);
sb.append(" ");
set.toSqlTemplate(sb);
if (where != null) {
sb.append(" ");
where.toSqlTemplate(sb);
}
return sb;
}
@Override
public StringBuilder toSolidSql(@Nonnull StringBuilder sb) {
sb.append("UPDATE ");
table.toSolidSql(sb);
sb.append(" ");
set.toSolidSql(sb);
if (where != null) {
sb.append(" ");
where.toSolidSql(sb);
}
return sb;
}
@Override
public List collectSqlValue(@Nonnull List sqlValues) {
set.collectSqlValue(sqlValues);
if (where != null) {
where.collectSqlValue(sqlValues);
}
return sqlValues;
}
}