Skip to content

Commit

Permalink
refactor: Removing redundant type checks in Value (#2108)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravpurohit06 committed Oct 13, 2022
1 parent 68c2089 commit ebfed27
Showing 1 changed file with 0 additions and 26 deletions.
Expand Up @@ -1084,7 +1084,6 @@ private BoolImpl(boolean isNull, boolean value) {

@Override
public boolean getBool() {
checkType(Type.bool());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1120,7 +1119,6 @@ private Int64Impl(boolean isNull, long value) {

@Override
public long getInt64() {
checkType(Type.int64());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1156,7 +1154,6 @@ private Float64Impl(boolean isNull, double value) {

@Override
public double getFloat64() {
checkType(Type.float64());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1215,7 +1212,6 @@ private DateImpl(boolean isNull, Date value) {

@Override
public Date getDate() {
checkType(Type.date());
checkNotNull();
return value;
}
Expand All @@ -1234,7 +1230,6 @@ private StringImpl(boolean isNull, @Nullable String value) {

@Override
public String getString() {
checkType(Type.string());
checkNotNull();
return value;
}
Expand All @@ -1257,7 +1252,6 @@ private JsonImpl(boolean isNull, @Nullable String value) {

@Override
public String getJson() {
checkType(Type.json());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1285,7 +1279,6 @@ private PgJsonbImpl(boolean isNull, @Nullable String value) {

@Override
public String getPgJsonb() {
checkType(Type.pgJsonb());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1313,7 +1306,6 @@ private BytesImpl(boolean isNull, ByteArray value) {

@Override
public ByteArray getBytes() {
checkType(Type.bytes());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -1341,7 +1333,6 @@ private TimestampImpl(boolean isNull, boolean isCommitTimestamp, Timestamp value

@Override
public Timestamp getTimestamp() {
checkType(Type.timestamp());
checkNotNull();
Preconditions.checkState(!isCommitTimestamp, "Commit timestamp value");
return value;
Expand Down Expand Up @@ -1399,7 +1390,6 @@ private NumericImpl(boolean isNull, BigDecimal value) {

@Override
public BigDecimal getNumeric() {
checkType(Type.numeric());
checkNotNull();
return value;
}
Expand All @@ -1422,14 +1412,12 @@ private PgNumericImpl(boolean isNull, String value) {

@Override
public String getString() {
checkType(Type.pgNumeric());
checkNotNull();
return value;
}

@Override
public BigDecimal getNumeric() {
checkType(Type.pgNumeric());
checkNotNull();
if (bigDecimalConversionError != null) {
throw bigDecimalConversionError;
Expand All @@ -1447,7 +1435,6 @@ public BigDecimal getNumeric() {

@Override
public double getFloat64() {
checkType(Type.pgNumeric());
checkNotNull();
if (doubleConversionError != null) {
throw doubleConversionError;
Expand Down Expand Up @@ -1482,7 +1469,6 @@ boolean isElementNull(int i) {
}

List<T> getArray() {
checkType(getType());
checkNotNull();
List<T> r = new ArrayList<>(size());
for (int i = 0; i < size(); ++i) {
Expand Down Expand Up @@ -1707,7 +1693,6 @@ private StringArrayImpl(boolean isNull, @Nullable List<String> values) {

@Override
public List<String> getStringArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1726,7 +1711,6 @@ private JsonArrayImpl(boolean isNull, @Nullable List<String> values) {

@Override
public List<String> getJsonArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1750,7 +1734,6 @@ private PgJsonbArrayImpl(boolean isNull, @Nullable List<String> values) {

@Override
public List<String> getPgJsonbArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1773,7 +1756,6 @@ private BytesArrayImpl(boolean isNull, @Nullable List<ByteArray> values) {

@Override
public List<ByteArray> getBytesArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1797,7 +1779,6 @@ private TimestampArrayImpl(boolean isNull, @Nullable List<Timestamp> values) {

@Override
public List<Timestamp> getTimestampArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1816,7 +1797,6 @@ private DateArrayImpl(boolean isNull, @Nullable List<Date> values) {

@Override
public List<Date> getDateArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1835,7 +1815,6 @@ private NumericArrayImpl(boolean isNull, @Nullable List<BigDecimal> values) {

@Override
public List<BigDecimal> getNumericArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand All @@ -1859,14 +1838,12 @@ private PgNumericArrayImpl(boolean isNull, @Nullable List<String> values) {

@Override
public List<String> getStringArray() {
checkType(getType());
checkNotNull();
return value;
}

@Override
public List<BigDecimal> getNumericArray() {
checkType(getType());
checkNotNull();
if (bigDecimalConversionError != null) {
throw bigDecimalConversionError;
Expand All @@ -1887,7 +1864,6 @@ public List<BigDecimal> getNumericArray() {

@Override
public List<Double> getFloat64Array() {
checkType(getType());
checkNotNull();
if (doubleConversionError != null) {
throw doubleConversionError;
Expand Down Expand Up @@ -1926,7 +1902,6 @@ private StructImpl(Type structType) {

@Override
public Struct getStruct() {
checkType(getType());
checkNotNull();
return value;
}
Expand Down Expand Up @@ -2039,7 +2014,6 @@ private StructArrayImpl(Type elementType, @Nullable List<Struct> values) {

@Override
public List<Struct> getStructArray() {
checkType(getType());
checkNotNull();
return value;
}
Expand Down

0 comments on commit ebfed27

Please sign in to comment.