Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorprone :: UnnecessaryDefaultInEnumSwitch #789

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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