io.github.sinri.keel.mysql.statement.component.UpdateSetAssignmentComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.mysql.statement.component;
import io.github.sinri.keel.core.TechnicalPreview;
import io.github.sinri.keel.mysql.Quoter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* @since 3.0.19
*/
@TechnicalPreview(since = "3.0.19")
public class UpdateSetAssignmentComponent {
private final @Nonnull String fieldName;
private @Nonnull String expression;
public UpdateSetAssignmentComponent(@Nonnull String fieldName) {
this.fieldName = fieldName;
}
public UpdateSetAssignmentComponent assignmentToExpression(@Nonnull String expression) {
this.expression = expression;
return this;
}
public UpdateSetAssignmentComponent assignmentToValue(@Nullable Object expression) {
if(expression==null){
this.expression = "NULL";
}else if (expression instanceof Number){
this.expression = expression.toString();
}else{
this.expression = new Quoter(expression.toString()).toString();
}
return this;
}
public UpdateSetAssignmentComponent assignmentToNull() {
this.expression = "NULL";
return this;
}
public UpdateSetAssignmentComponent assignmentToCaseOperator(@Nonnull CaseOperator caseOperator) {
this.expression = caseOperator.toString();
return this;
}
@Override
public String toString() {
return fieldName + "=" + expression;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy