From aa52a60258bc7b62ec040208de8c26163581bb08 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Fri, 16 Dec 2022 15:12:20 -0500 Subject: [PATCH] Clenup unused code in JavaUtils --- .../pulsar/support/JavaUtils.java | 130 ------------------ 1 file changed, 130 deletions(-) diff --git a/spring-pulsar/src/main/java/org/springframework/pulsar/support/JavaUtils.java b/spring-pulsar/src/main/java/org/springframework/pulsar/support/JavaUtils.java index 9ead0326..398413d5 100644 --- a/spring-pulsar/src/main/java/org/springframework/pulsar/support/JavaUtils.java +++ b/spring-pulsar/src/main/java/org/springframework/pulsar/support/JavaUtils.java @@ -16,14 +16,9 @@ package org.springframework.pulsar.support; -import java.util.List; -import java.util.function.BiConsumer; import java.util.function.Consumer; import org.springframework.lang.Nullable; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; /** * Chained utility methods to simplify some Java repetitive code. Obtain a reference to @@ -41,21 +36,6 @@ public final class JavaUtils { private JavaUtils() { } - /** - * Invoke {@link Consumer#accept(Object)} with the value if the condition is true. - * @param condition the condition. - * @param value the value. - * @param consumer the consumer. - * @param the value type. - * @return this. - */ - public JavaUtils acceptIfCondition(boolean condition, T value, Consumer consumer) { - if (condition) { - consumer.accept(value); - } - return this; - } - /** * Invoke {@link Consumer#accept(Object)} with the value if it is not null. * @param value the value. @@ -70,114 +50,4 @@ public final class JavaUtils { return this; } - /** - * Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty. - * @param value the value. - * @param consumer the consumer. - * @return this. - */ - public JavaUtils acceptIfHasText(String value, Consumer consumer) { - if (StringUtils.hasText(value)) { - consumer.accept(value); - } - return this; - } - - /** - * Invoke {@link Consumer#accept(Object)} with the cast value if the object is an - * instance of the provided class. - * @param the type of the class to check and cast. - * @param type the type. - * @param value the value to be checked and cast. - * @param consumer the consumer. - * @return this. - * @since 2.9 - */ - @SuppressWarnings("unchecked") - public JavaUtils acceptIfInstanceOf(Class type, Object value, Consumer consumer) { - if (type.isAssignableFrom(value.getClass())) { - consumer.accept((T) value); - } - return this; - } - - /** - * Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty. - * @param value the value. - * @param consumer the consumer. - * @param the value type. - * @return this. - */ - public JavaUtils acceptIfNotEmpty(List value, Consumer> consumer) { - if (!CollectionUtils.isEmpty(value)) { - consumer.accept(value); - } - return this; - } - - /** - * Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty. - * @param value the value. - * @param consumer the consumer. - * @param the value type. - * @return this. - */ - public JavaUtils acceptIfNotEmpty(T[] value, Consumer consumer) { - if (!ObjectUtils.isEmpty(value)) { - consumer.accept(value); - } - return this; - } - - /** - * Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the - * condition is true. - * @param condition the condition. - * @param t1 the first consumer argument - * @param t2 the second consumer argument - * @param consumer the consumer. - * @param the first argument type. - * @param the second argument type. - * @return this. - */ - public JavaUtils acceptIfCondition(boolean condition, T1 t1, T2 t2, BiConsumer consumer) { - if (condition) { - consumer.accept(t1, t2); - } - return this; - } - - /** - * Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the t2 - * argument is not null. - * @param t1 the first argument - * @param t2 the second consumer argument - * @param consumer the consumer. - * @param the first argument type. - * @param the second argument type. - * @return this. - */ - public JavaUtils acceptIfNotNull(T1 t1, T2 t2, BiConsumer consumer) { - if (t2 != null) { - consumer.accept(t1, t2); - } - return this; - } - - /** - * Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the value - * argument is not null or empty. - * @param t1 the first consumer argument. - * @param value the second consumer argument - * @param the first argument type. - * @param consumer the consumer. - * @return this. - */ - public JavaUtils acceptIfHasText(T t1, String value, BiConsumer consumer) { - if (StringUtils.hasText(value)) { - consumer.accept(t1, value); - } - return this; - } - }