diff --git a/src/main/java/com/github/robtimus/tryparse/TryParse.java b/src/main/java/com/github/robtimus/tryparse/TryParse.java index d817a40..a7ad818 100644 --- a/src/main/java/com/github/robtimus/tryparse/TryParse.java +++ b/src/main/java/com/github/robtimus/tryparse/TryParse.java @@ -46,7 +46,7 @@ public final class TryParse { private static final int DEFAULT_RADIX = 10; private TryParse() { - throw new Error("cannot create instances of " + getClass().getName()); //$NON-NLS-1$ + throw new IllegalStateException("cannot create instances of " + getClass().getName()); //$NON-NLS-1$ } // int diff --git a/src/main/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBounds.java b/src/main/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBounds.java index 03e79f6..cc03645 100644 --- a/src/main/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBounds.java +++ b/src/main/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBounds.java @@ -61,7 +61,7 @@ final class UnsignedMultiplyLongBounds { } private UnsignedMultiplyLongBounds() { - throw new Error("cannot create instances of " + getClass().getName()); //$NON-NLS-1$ + throw new IllegalStateException("cannot create instances of " + getClass().getName()); //$NON-NLS-1$ } static long get(int radix) { diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseBooleanTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseBooleanTest.java index 08bb6b6..1abe4e1 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseBooleanTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseBooleanTest.java @@ -23,11 +23,11 @@ import java.util.Optional; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseBooleanTest { +@SuppressWarnings("nls") +class TryParseBooleanTest { @Test - public void testTryParseBoolean() { + void testTryParseBoolean() { checkWithAndWithoutSubsequences(true, "true"); checkWithAndWithoutSubsequences(true, "TRUE"); checkWithAndWithoutSubsequences(false, "false"); diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseCatchingTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseCatchingTest.java index ee3dac0..993de80 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseCatchingTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseCatchingTest.java @@ -49,11 +49,11 @@ import java.util.OptionalDouble; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseCatchingTest { +@SuppressWarnings("nls") +class TryParseCatchingTest { @Test - public void testParseDouble() { + void testParseDouble() { assertEquals(OptionalDouble.empty(), tryParseDouble(null)); assertEquals(OptionalDouble.empty(), tryParseDouble("")); assertEquals(123.456, tryParseDouble("123.456").getAsDouble(), 0.00001); @@ -61,7 +61,7 @@ public void testParseDouble() { } @Test - public void testParseURI() { + void testParseURI() { assertEquals(Optional.empty(), tryParseURI(null)); // an empty URI is valid assertEquals(Optional.of(URI.create("http://example.org")), tryParseURI("http://example.org")); @@ -69,7 +69,7 @@ public void testParseURI() { } @Test - public void testParseURL() throws MalformedURLException { + void testParseURL() throws MalformedURLException { assertEquals(Optional.empty(), tryParseURL(null)); assertEquals(Optional.empty(), tryParseURL("")); assertEquals(Optional.of(new URL("http://example.org")), tryParseURL("http://example.org")); @@ -77,7 +77,7 @@ public void testParseURL() throws MalformedURLException { } @Test - public void testParseInstant() { + void testParseInstant() { assertEquals(Optional.empty(), tryParseInstant(null)); assertEquals(Optional.empty(), tryParseInstant("")); assertEquals(Optional.of(Instant.parse("2007-12-03T10:15:30.00Z")), tryParseInstant("2007-12-03T10:15:30.00Z")); @@ -85,7 +85,7 @@ public void testParseInstant() { } @Test - public void testParseLocalDate() { + void testParseLocalDate() { assertEquals(Optional.empty(), tryParseLocalDate(null)); assertEquals(Optional.empty(), tryParseLocalDate("")); assertEquals(Optional.of(LocalDate.of(2007, 12, 3)), tryParseLocalDate("2007-12-03")); @@ -99,7 +99,7 @@ public void testParseLocalDate() { } @Test - public void testParseLocalDateTime() { + void testParseLocalDateTime() { assertEquals(Optional.empty(), tryParseLocalDateTime(null)); assertEquals(Optional.empty(), tryParseLocalDateTime("")); assertEquals(Optional.of(LocalDateTime.of(2007, 12, 3, 10, 15, 30)), tryParseLocalDateTime("2007-12-03T10:15:30")); @@ -113,7 +113,7 @@ public void testParseLocalDateTime() { } @Test - public void testParseLocalTime() { + void testParseLocalTime() { assertEquals(Optional.empty(), tryParseLocalTime(null)); assertEquals(Optional.empty(), tryParseLocalTime("")); assertEquals(Optional.of(LocalTime.of(10, 15, 30)), tryParseLocalTime("10:15:30")); @@ -127,7 +127,7 @@ public void testParseLocalTime() { } @Test - public void testParseOffsetDateTime() { + void testParseOffsetDateTime() { assertEquals(Optional.empty(), tryParseOffsetDateTime(null)); assertEquals(Optional.empty(), tryParseOffsetDateTime("")); assertEquals(Optional.of(OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 0, ZoneOffset.ofHours(1))), @@ -143,7 +143,7 @@ public void testParseOffsetDateTime() { } @Test - public void testParseOffsetTime() { + void testParseOffsetTime() { assertEquals(Optional.empty(), tryParseOffsetTime(null)); assertEquals(Optional.empty(), tryParseOffsetTime("")); assertEquals(Optional.of(OffsetTime.of(10, 15, 30, 0, ZoneOffset.ofHours(1))), tryParseOffsetTime("10:15:30+01:00")); @@ -157,7 +157,7 @@ public void testParseOffsetTime() { } @Test - public void testParseZonedDateTime() { + void testParseZonedDateTime() { assertEquals(Optional.empty(), tryParseZonedDateTime(null)); assertEquals(Optional.empty(), tryParseZonedDateTime("")); assertEquals(Optional.of(ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 0, ZoneId.of("Europe/Paris"))), @@ -173,7 +173,7 @@ public void testParseZonedDateTime() { } @Test - public void testParseTemporal() { + void testParseTemporal() { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); assertEquals(Optional.empty(), tryParseTemporal(null, formatter, LocalDate::from)); assertEquals(Optional.empty(), tryParseTemporal("", formatter, LocalDate::from)); @@ -182,7 +182,7 @@ public void testParseTemporal() { } @Test - public void testParse() { + void testParse() { assertEquals(Optional.empty(), tryParse(null, o -> o)); assertEquals(Optional.of(""), tryParse("", o -> o)); assertEquals(Optional.of("foo"), tryParse("foo", o -> o)); diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseIntTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseIntTest.java index 1beded8..ab7aa73 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseIntTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseIntTest.java @@ -23,11 +23,11 @@ import java.util.OptionalInt; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseIntTest { +@SuppressWarnings("nls") +class TryParseIntTest { @Test - public void testTryParseInt() { + void testTryParseInt() { checkNegativeNumber(-128); for (int i = -32; i < 0; i++) { checkNegativeNumber(i); diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseLongTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseLongTest.java index 76ac90b..798f43c 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseLongTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseLongTest.java @@ -24,11 +24,11 @@ import java.util.OptionalLong; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseLongTest { +@SuppressWarnings("nls") +class TryParseLongTest { @Test - public void testTryParseLong() { + void testTryParseLong() { checkNegativeNumber(-128); for (long i = -32; i < 0; i++) { checkNegativeNumber(i); diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedIntTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedIntTest.java index cbd214f..5bd37e6 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedIntTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedIntTest.java @@ -23,13 +23,13 @@ import java.util.OptionalInt; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseUnsignedIntTest { +@SuppressWarnings("nls") +class TryParseUnsignedIntTest { private static final long MAX_UNSIGNED_INT_VALUE = 0xFFFF_FFFFL; @Test - public void testTryParseUnsignedInt() { + void testTryParseUnsignedInt() { checkNegativeNumber(-128); for (int i = -32; i < 0; i++) { checkNegativeNumber(i); diff --git a/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedLongTest.java b/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedLongTest.java index 1d71be4..95ff388 100644 --- a/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedLongTest.java +++ b/src/test/java/com/github/robtimus/tryparse/TryParseUnsignedLongTest.java @@ -25,13 +25,13 @@ import java.util.OptionalLong; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "javadoc", "nls" }) -public class TryParseUnsignedLongTest { +@SuppressWarnings("nls") +class TryParseUnsignedLongTest { private static final BigInteger MAX_UNSIGNED_LONG_VALUE = BigInteger.valueOf(2).pow(64).subtract(BigInteger.ONE); @Test - public void testTryParseUnsignedLong() { + void testTryParseUnsignedLong() { checkNegativeNumber(-128); for (long i = -32; i < 0; i++) { checkNegativeNumber(i); diff --git a/src/test/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBoundsTest.java b/src/test/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBoundsTest.java index 0fd0d22..4259fb7 100644 --- a/src/test/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBoundsTest.java +++ b/src/test/java/com/github/robtimus/tryparse/UnsignedMultiplyLongBoundsTest.java @@ -22,13 +22,12 @@ import java.math.BigInteger; import org.junit.jupiter.api.Test; -@SuppressWarnings("javadoc") -public class UnsignedMultiplyLongBoundsTest { +class UnsignedMultiplyLongBoundsTest { private static final BigInteger MAX_UNSIGNED_LONG_VALUE = BigInteger.valueOf(2).pow(64).subtract(BigInteger.ONE); @Test - public void testGet() { + void testGet() { for (int radix = Character.MIN_RADIX; radix <= Character.MAX_RADIX; radix++) { long expected = MAX_UNSIGNED_LONG_VALUE.divide(BigInteger.valueOf(radix)).longValueExact(); assertEquals(expected, UnsignedMultiplyLongBounds.get(radix)); @@ -36,7 +35,7 @@ public void testGet() { } @Test - public void testGetRadixToHigh() { + void testGetRadixToHigh() { assertThrows(IndexOutOfBoundsException.class, () -> UnsignedMultiplyLongBounds.get(Character.MAX_RADIX + 1)); } }