Skip to content

Commit 5440d89

Browse files
simplified if else logic
1 parent dfbd02f commit 5440d89

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

vector/src/main/java/org/apache/arrow/vector/TimeStampMicroTZVector.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ public void set(int index, NullableTimeStampMicroTZHolder holder)
155155
throws IllegalArgumentException {
156156
if (holder.isSet < 0) {
157157
throw new IllegalArgumentException();
158-
} else if (holder.isSet > 0 && !this.timeZone.equals(holder.timezone)) {
159-
throw new IllegalArgumentException(
160-
String.format(
161-
"holder.timezone: %s not equal to vector timezone: %s",
162-
holder.timezone, this.timeZone));
163158
} else if (holder.isSet > 0) {
159+
if (!this.timeZone.equals(holder.timezone)) {
160+
throw new IllegalArgumentException(
161+
String.format(
162+
"holder.timezone: %s not equal to vector timezone: %s",
163+
holder.timezone, this.timeZone));
164+
}
164165
BitVectorHelper.setBit(validityBuffer, index);
165166
setValue(index, holder.value);
166167
} else {

vector/src/main/java/org/apache/arrow/vector/TimeStampMilliTZVector.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ public void set(int index, NullableTimeStampMilliTZHolder holder)
155155
throws IllegalArgumentException {
156156
if (holder.isSet < 0) {
157157
throw new IllegalArgumentException();
158-
} else if (holder.isSet > 0 && !this.timeZone.equals(holder.timezone)) {
159-
throw new IllegalArgumentException(
160-
String.format(
161-
"holder.timezone: %s not equal to vector timezone: %s",
162-
holder.timezone, this.timeZone));
163158
} else if (holder.isSet > 0) {
159+
if (!this.timeZone.equals(holder.timezone)) {
160+
throw new IllegalArgumentException(
161+
String.format(
162+
"holder.timezone: %s not equal to vector timezone: %s",
163+
holder.timezone, this.timeZone));
164+
}
164165
BitVectorHelper.setBit(validityBuffer, index);
165166
setValue(index, holder.value);
166167
} else {

vector/src/main/java/org/apache/arrow/vector/TimeStampNanoTZVector.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,13 @@ public Long getObject(int index) {
154154
public void set(int index, NullableTimeStampNanoTZHolder holder) throws IllegalArgumentException {
155155
if (holder.isSet < 0) {
156156
throw new IllegalArgumentException();
157-
} else if (holder.isSet > 0 && !this.timeZone.equals(holder.timezone)) {
158-
throw new IllegalArgumentException(
159-
String.format(
160-
"holder.timezone: %s not equal to vector timezone: %s",
161-
holder.timezone, this.timeZone));
162157
} else if (holder.isSet > 0) {
158+
if (!this.timeZone.equals(holder.timezone)) {
159+
throw new IllegalArgumentException(
160+
String.format(
161+
"holder.timezone: %s not equal to vector timezone: %s",
162+
holder.timezone, this.timeZone));
163+
}
163164
BitVectorHelper.setBit(validityBuffer, index);
164165
setValue(index, holder.value);
165166
} else {

vector/src/main/java/org/apache/arrow/vector/TimeStampSecTZVector.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ public Long getObject(int index) {
150150
public void set(int index, NullableTimeStampSecTZHolder holder) throws IllegalArgumentException {
151151
if (holder.isSet < 0) {
152152
throw new IllegalArgumentException();
153-
} else if (holder.isSet > 0 && !this.timeZone.equals(holder.timezone)) {
154-
throw new IllegalArgumentException(
155-
String.format(
156-
"holder.timezone: %s not equal to vector timezone: %s",
157-
holder.timezone, this.timeZone));
158153
} else if (holder.isSet > 0) {
154+
if (!this.timeZone.equals(holder.timezone)) {
155+
throw new IllegalArgumentException(
156+
String.format(
157+
"holder.timezone: %s not equal to vector timezone: %s",
158+
holder.timezone, this.timeZone));
159+
}
159160
BitVectorHelper.setBit(validityBuffer, index);
160161
setValue(index, holder.value);
161162
} else {

0 commit comments

Comments
 (0)