style(commons): Clean up Throwable*.of
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Johannes Frohnmeyer 2024-05-04 22:01:56 +02:00
parent 0e15fe3abd
commit e1d6f578a8
Signed by: Johannes
GPG Key ID: E76429612C2929F4
8 changed files with 8 additions and 16 deletions

View File

@ -9,8 +9,7 @@ import java.util.function.*;
@FunctionalInterface @FunctionalInterface
public interface ThrowingBiConsumer<T, U, TEx extends Throwable> { public interface ThrowingBiConsumer<T, U, TEx extends Throwable> {
static <T, U, TEx extends Throwable> @NotNull ThrowingBiConsumer<T, U, TEx> of(@NotNull BiConsumer<T, U> consumer) { static <T, U, TEx extends Throwable> @NotNull ThrowingBiConsumer<T, U, TEx> of(@NotNull BiConsumer<T, U> consumer) {
Objects.requireNonNull(consumer); return Objects.requireNonNull(consumer)::accept;
return consumer::accept;
} }
void accept(T var1, U var2) throws TEx; void accept(T var1, U var2) throws TEx;

View File

@ -10,8 +10,7 @@ import java.util.function.Function;
@FunctionalInterface @FunctionalInterface
public interface ThrowingBiFunction<T, U, R, TEx extends Throwable> { public interface ThrowingBiFunction<T, U, R, TEx extends Throwable> {
static <T, U, R, TEx extends Throwable> @NotNull ThrowingBiFunction<T, U, R, TEx> of(@NotNull BiFunction<T, U, R> function) { static <T, U, R, TEx extends Throwable> @NotNull ThrowingBiFunction<T, U, R, TEx> of(@NotNull BiFunction<T, U, R> function) {
Objects.requireNonNull(function); return Objects.requireNonNull(function)::apply;
return function::apply;
} }
R apply(T var1, U var2) throws TEx; R apply(T var1, U var2) throws TEx;

View File

@ -8,8 +8,7 @@ import java.util.function.*;
@FunctionalInterface @FunctionalInterface
public interface ThrowingBooleanSupplier<TEx extends Throwable> { public interface ThrowingBooleanSupplier<TEx extends Throwable> {
static <TEx extends Throwable> @NotNull ThrowingBooleanSupplier<TEx> of(@NotNull BooleanSupplier supplier) { static <TEx extends Throwable> @NotNull ThrowingBooleanSupplier<TEx> of(@NotNull BooleanSupplier supplier) {
Objects.requireNonNull(supplier); return Objects.requireNonNull(supplier)::getAsBoolean;
return supplier::getAsBoolean;
} }
boolean get() throws TEx; boolean get() throws TEx;

View File

@ -9,8 +9,7 @@ import java.util.function.Function;
@FunctionalInterface @FunctionalInterface
public interface ThrowingConsumer<T, TEx extends Throwable> { public interface ThrowingConsumer<T, TEx extends Throwable> {
static <T> @NotNull ThrowingConsumer<T, RuntimeException> of(@NotNull Consumer<T> consumer) { static <T> @NotNull ThrowingConsumer<T, RuntimeException> of(@NotNull Consumer<T> consumer) {
Objects.requireNonNull(consumer); return Objects.requireNonNull(consumer)::accept;
return consumer::accept;
} }
void accept(T var1) throws TEx; void accept(T var1) throws TEx;

View File

@ -8,8 +8,7 @@ import java.util.function.Function;
@FunctionalInterface @FunctionalInterface
public interface ThrowingFunction<T, R, TEx extends Throwable> { public interface ThrowingFunction<T, R, TEx extends Throwable> {
static <T, R> @NotNull ThrowingFunction<T, R, RuntimeException> of(@NotNull Function<T, R> function) { static <T, R> @NotNull ThrowingFunction<T, R, RuntimeException> of(@NotNull Function<T, R> function) {
Objects.requireNonNull(function); return Objects.requireNonNull(function)::apply;
return function::apply;
} }
R apply(T var1) throws TEx; R apply(T var1) throws TEx;

View File

@ -9,8 +9,7 @@ import java.util.function.Predicate;
@FunctionalInterface @FunctionalInterface
public interface ThrowingPredicate<T, TEx extends Throwable> { public interface ThrowingPredicate<T, TEx extends Throwable> {
static <T> @NotNull ThrowingPredicate<T, RuntimeException> of(@NotNull Predicate<T> predicate) { static <T> @NotNull ThrowingPredicate<T, RuntimeException> of(@NotNull Predicate<T> predicate) {
Objects.requireNonNull(predicate); return Objects.requireNonNull(predicate)::test;
return predicate::test;
} }
boolean test(T var1) throws TEx; boolean test(T var1) throws TEx;

View File

@ -9,8 +9,7 @@ import java.util.function.Function;
@FunctionalInterface @FunctionalInterface
public interface ThrowingRunnable<TEx extends Throwable> { public interface ThrowingRunnable<TEx extends Throwable> {
static @NotNull ThrowingRunnable<RuntimeException> of(@NotNull Runnable runnable) { static @NotNull ThrowingRunnable<RuntimeException> of(@NotNull Runnable runnable) {
Objects.requireNonNull(runnable); return Objects.requireNonNull(runnable)::run;
return runnable::run;
} }
void run() throws TEx; void run() throws TEx;

View File

@ -9,8 +9,7 @@ import java.util.function.Supplier;
@FunctionalInterface @FunctionalInterface
public interface ThrowingSupplier<T, TEx extends Throwable> { public interface ThrowingSupplier<T, TEx extends Throwable> {
static <T> @NotNull ThrowingSupplier<T, RuntimeException> of(@NotNull Supplier<T> supplier) { static <T> @NotNull ThrowingSupplier<T, RuntimeException> of(@NotNull Supplier<T> supplier) {
Objects.requireNonNull(supplier); return Objects.requireNonNull(supplier)::get;
return supplier::get;
} }
T get() throws TEx; T get() throws TEx;