Skip to content

Commit

Permalink
errorprone :: UnnecessaryDefaultInEnumSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed May 29, 2024
1 parent 210526e commit 1f898f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/emissary/core/BaseDataObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.google.common.collect.LinkedListMultimap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
Expand Down Expand Up @@ -367,6 +368,7 @@ public void setChannelFactory(final SeekableByteChannelFactory sbcf) {
*/
@Nullable
@Override
@SuppressWarnings("UnnecessaryDefaultInEnumSwitch")
public SeekableByteChannelFactory getChannelFactory() {
switch (getDataState()) {
case BYTE_ARRAY_AND_CHANNEL:
Expand Down Expand Up @@ -413,6 +415,7 @@ public InputStream newInputStream() {
*/
@Nullable
@Override
@SuppressWarnings("UnnecessaryDefaultInEnumSwitch")
public byte[] data() {
switch (getDataState()) {
case BYTE_ARRAY_AND_CHANNEL:
Expand Down Expand Up @@ -490,12 +493,13 @@ public boolean hasContent() throws IOException {
* @return the channel size
*/
@Override
@SuppressWarnings("UnnecessaryDefaultInEnumSwitch")
public long getChannelSize() throws IOException {
switch (getDataState()) {
case BYTE_ARRAY_AND_CHANNEL:
throw new IllegalStateException(String.format(INVALID_STATE_MSG, shortName()));
case BYTE_ARRAY_ONLY:
return theData.length;
return ArrayUtils.getLength(theData);
case CHANNEL_ONLY:
try (final SeekableByteChannel sbc = this.seekableByteChannelFactory.create()) {
return sbc.size();
Expand All @@ -513,12 +517,13 @@ public long getChannelSize() throws IOException {
* {@link BaseDataObject#MAX_BYTE_ARRAY_SIZE}.
*/
@Override
@SuppressWarnings("UnnecessaryDefaultInEnumSwitch")
public int dataLength() {
switch (getDataState()) {
case BYTE_ARRAY_AND_CHANNEL:
throw new IllegalStateException(String.format(INVALID_STATE_MSG, shortName()));
case BYTE_ARRAY_ONLY:
return theData.length;
return ArrayUtils.getLength(theData);
case CHANNEL_ONLY:
try {
return (int) Math.min(getChannelSize(), MAX_BYTE_ARRAY_SIZE);
Expand Down

0 comments on commit 1f898f6

Please sign in to comment.