Skip to content

Commit

Permalink
#30 simplify condition
Browse files Browse the repository at this point in the history
  • Loading branch information
doom369 committed Sep 1, 2019
1 parent cfc6dae commit 8bebee6
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public final class ClickHousePreparedStatementParameter {
private final String stringValue;
private final boolean quoteNeeded;

public static ClickHousePreparedStatementParameter fromObject(Object x,
static ClickHousePreparedStatementParameter fromObject(Object x,
TimeZone dateTimeZone, TimeZone dateTimeTimeZone) {
if (x == null) {
return NULL_PARAM;
Expand All @@ -22,24 +22,25 @@ public static ClickHousePreparedStatementParameter fromObject(Object x,
ClickHouseValueFormatter.needsQuoting(x));
}

public static ClickHousePreparedStatementParameter nullParameter() {
static ClickHousePreparedStatementParameter nullParameter() {
return NULL_PARAM;
}

public ClickHousePreparedStatementParameter(String stringValue,
boolean quoteNeeded) {
ClickHousePreparedStatementParameter(String stringValue, boolean quoteNeeded) {
this.stringValue = stringValue == null
? ClickHouseValueFormatter.NULL_MARKER
: stringValue;
this.quoteNeeded = quoteNeeded;
}

String getRegularValue() {
return !ClickHouseValueFormatter.NULL_MARKER.equals(stringValue)
? quoteNeeded
? "'" + stringValue + "'"
: stringValue
: "null";
if (ClickHouseValueFormatter.NULL_MARKER.equals(stringValue)) {
return "null";
}
if (quoteNeeded) {
return "'" + stringValue + "'";
}
return stringValue;
}

String getBatchValue() {
Expand Down

0 comments on commit 8bebee6

Please sign in to comment.