Minor cleanups

- Remove forgotten test assertion
- Make utils class final
- Change RandomString to use char array
This commit is contained in:
ljacqu 2017-02-20 22:20:48 +01:00
parent 922101d755
commit ee51bb3971
3 changed files with 4 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
/**
* Player utilities.
*/
public class PlayerUtils {
public final class PlayerUtils {
// Utility class
private PlayerUtils() {

View File

@ -8,7 +8,7 @@ import java.util.Random;
*/
public final class RandomStringUtils {
private static final String CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final char[] CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
private static final Random RANDOM = new SecureRandom();
private static final int HEX_MAX_INDEX = 16;
private static final int LOWER_ALPHANUMERIC_INDEX = 36;
@ -46,7 +46,7 @@ public final class RandomStringUtils {
* @return The random string
*/
public static String generateLowerUpper(int length) {
return generate(length, CHARS.length());
return generate(length, CHARS.length);
}
private static String generate(int length, int maxIndex) {
@ -55,7 +55,7 @@ public final class RandomStringUtils {
}
StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
sb.append(CHARS.charAt(RANDOM.nextInt(maxIndex)));
sb.append(CHARS[RANDOM.nextInt(maxIndex)]);
}
return sb.toString();
}

View File

@ -38,7 +38,6 @@ public class LogFilterHelperTest {
.toArray(String[]::new);
// when / then
assertThat(Arrays.asList("test", "toast"), containsInAnyOrder("toast", "test"));
assertThat(Arrays.asList(LogFilterHelper.COMMANDS_TO_SKIP), containsInAnyOrder(expectedEntries));
}