Skip to content

Commit

Permalink
[#noissue] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Aug 25, 2023
1 parent 9ce3ca1 commit 5641312
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,7 @@ public static byte[] concat(final byte[]... arrays) {
if (arrays == null) {
throw new NullPointerException("arrays");
}
int totalLength = 0;
for (byte[] array : arrays) {
totalLength += array.length;
}
final int totalLength = getTotalLength(arrays);

byte[] result = new byte[totalLength];

Expand All @@ -545,6 +542,14 @@ public static byte[] concat(final byte[]... arrays) {
return result;
}

private static int getTotalLength(byte[][] arrays) {
int totalLength = 0;
for (byte[] array : arrays) {
totalLength += array.length;
}
return totalLength;
}


public static byte[] concat(final byte[] b1, final byte[] b2) {
if (b1 == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static boolean isEmpty(final String string) {
}

public static boolean hasLength(final String string) {
return string != null && string.length() > 0;
return string != null && !string.isEmpty();
}

public static boolean hasText(String string) {
Expand All @@ -63,11 +63,11 @@ public static boolean hasText(String string) {
return false;
}

public static <T> int getLength(final String string) {
public static int getLength(final String string) {
return getLength(string, 0);
}

public static <T> int getLength(final String string, final int nullValue) {
public static int getLength(final String string, final int nullValue) {
if (string == null) {
return nullValue;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public static List<String> tokenizeToStringList(final String str, final String d
if (trimTokens) {
token = token.trim();
}
if (!ignoreEmptyTokens || token.length() > 0) {
if (!ignoreEmptyTokens || !token.isEmpty()) {
tokens.add(token);
}
}
Expand Down

0 comments on commit 5641312

Please sign in to comment.