Skip to content

Commit

Permalink
🔥 Remove Zero.Companion.orThrow(Int) function (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
LVMVRQUXL committed Jan 30, 2025
1 parent 6d1de9b commit a9c6e21
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 78 deletions.
2 changes: 0 additions & 2 deletions subprojects/library/src/api/types.api
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ public final class org/kotools/types/Zero {
public final fun hashCode ()I
public static final fun orThrow (D)Lorg/kotools/types/Zero;
public static final fun orThrow (F)Lorg/kotools/types/Zero;
public static final fun orThrow (I)Lorg/kotools/types/Zero;
public static final fun orThrow (J)Lorg/kotools/types/Zero;
public static final fun orThrow (Ljava/lang/Object;)Lorg/kotools/types/Zero;
public static final fun orThrow (Ljava/lang/String;)Lorg/kotools/types/Zero;
Expand All @@ -465,7 +464,6 @@ public final class org/kotools/types/Zero$Companion {
public final synthetic fun orNull (S)Lorg/kotools/types/Zero;
public final fun orThrow (D)Lorg/kotools/types/Zero;
public final fun orThrow (F)Lorg/kotools/types/Zero;
public final fun orThrow (I)Lorg/kotools/types/Zero;
public final fun orThrow (J)Lorg/kotools/types/Zero;
public final fun orThrow (Ljava/lang/Object;)Lorg/kotools/types/Zero;
public final fun orThrow (Ljava/lang/String;)Lorg/kotools/types/Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,43 +715,6 @@ public class Zero {
null
}

/**
* Creates an instance of [Zero] from the specified [number], or throws
* an [IllegalArgumentException] if the [number] is other than zero.
*
* <br>
* <details>
* <summary>
* <b>Calling from Kotlin</b>
* </summary>
*
* Here's an example of calling this function from Kotlin code:
*
* SAMPLE: [org.kotools.types.ZeroCompanionCommonSample.orThrowWithInt]
* </details>
*
* <br>
* <details>
* <summary>
* <b>Calling from Java</b>
* </summary>
*
* Here's an example of calling this function from Java code:
*
* SAMPLE: [org.kotools.types.ZeroCompanionJavaSample.orThrowWithInt]
* </details>
* <br>
*
* See the [orNull] function for returning `null` instead of throwing an
* exception in case of invalid [number].
*/
@ExperimentalSince(KotoolsTypesVersion.V5_0_0)
@JvmStatic
public fun orThrow(number: Int): Zero {
require(number == 0) { ErrorMessage.invalidZero(number) }
return Zero()
}

/**
* Creates an instance of [Zero] from the specified [number], or throws
* an [IllegalArgumentException] if the [number] is other than zero.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ class ZeroCompanionCommonSample {
.forEach(::assertNotNull)
}

@Test
fun orThrowWithInt() {
val isSuccess: Boolean = try {
Zero.orThrow(0)
true
} catch (exception: IllegalArgumentException) {
false
}
assertTrue(isSuccess)
}

@Test
fun orThrowWithLong() {
val isSuccess: Boolean = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,6 @@ class ZeroCompanionTest {
.map(Zero.Companion::orNull)
.forEach(::assertNull)

@Test
fun orThrowShouldPassWithIntThatEqualsZero() {
val number = 0
Zero.orThrow(number)
}

@Test
fun orThrowShouldFailWithIntOtherThanZero() {
val number: Int = setOf(Int.MIN_VALUE..-1, 1..Int.MAX_VALUE)
.random()
.random()
assertFailsWith<IllegalArgumentException> { Zero.orThrow(number) }
.assertIsInvalidZero(number)
}

@Test
fun orThrowShouldPassWithLongThatEqualsZero() {
val number = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@

@SuppressWarnings("NewClassNamingConvention")
class ZeroCompanionJavaSample {
@Test
void orThrowWithInt() {
final int number = 0;
boolean isSuccess;
try {
Zero.orThrow(number);
isSuccess = true;
} catch (final IllegalArgumentException exception) {
isSuccess = false;
}
Assertions.assertTrue(isSuccess);
}

@Test
void orThrowWithLong() {
final long number = 0;
Expand Down

0 comments on commit a9c6e21

Please sign in to comment.