aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2024-05-29 16:16:10 -0400
committerGary Gregory <garydgregory@gmail.com>2024-05-29 16:16:10 -0400
commita37e8de046a328c3400ea2f78b51d792152e9569 (patch)
tree75a42d1d6474f1abcefdb91aec49470cdf55da21
parent4b99af5ebf9fb973c18ba73aef8a3516fb61d8a0 (diff)
downloadapache-commons-lang-a37e8de046a328c3400ea2f78b51d792152e9569.tar.gz
Sort members
-rw-r--r--src/main/java/org/apache/commons/lang3/JavaVersion.java10
-rw-r--r--src/main/java/org/apache/commons/lang3/SystemProperties.java28
-rw-r--r--src/main/java/org/apache/commons/lang3/function/Consumers.java30
-rw-r--r--src/main/java/org/apache/commons/lang3/function/Functions.java30
-rw-r--r--src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java8
-rw-r--r--src/test/java/org/apache/commons/lang3/function/ConsumersTest.java46
-rw-r--r--src/test/java/org/apache/commons/lang3/function/FunctionsTest.java16
-rw-r--r--src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java8
8 files changed, 88 insertions, 88 deletions
diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java
index 355b6ab6e..feb53bd16 100644
--- a/src/main/java/org/apache/commons/lang3/JavaVersion.java
+++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java
@@ -184,6 +184,11 @@ public enum JavaVersion {
JAVA_RECENT(maxVersion(), Float.toString(maxVersion()));
/**
+ * The regex to split version strings.
+ */
+ private static final String VERSION_SPLIT_REGEX = "\\.";
+
+ /**
* Transforms the given string with a Java version number to the
* corresponding constant of this enumeration class. This method is used
* internally.
@@ -314,11 +319,6 @@ public enum JavaVersion {
private final String name;
/**
- * The regex to split version strings.
- */
- private static final String VERSION_SPLIT_REGEX = "\\.";
-
- /**
* Constructs a new instance.
*
* @param value the float value
diff --git a/src/main/java/org/apache/commons/lang3/SystemProperties.java b/src/main/java/org/apache/commons/lang3/SystemProperties.java
index 54137332d..1c2d03653 100644
--- a/src/main/java/org/apache/commons/lang3/SystemProperties.java
+++ b/src/main/java/org/apache/commons/lang3/SystemProperties.java
@@ -3715,6 +3715,20 @@ public final class SystemProperties {
* </p>
*
* @param property the system property name.
+ * @param defaultIfAbsent use this value when the property is empty or throws SecurityException.
+ * @return the system property value or {@code null} if a security problem occurs
+ */
+ static String getProperty(final String property, final String defaultIfAbsent) {
+ return getProperty(property, () -> defaultIfAbsent);
+ }
+
+ /**
+ * Gets a System property, defaulting to {@code null} if the property cannot be read.
+ * <p>
+ * If a {@link SecurityException} is caught, the return value is {@code null}.
+ * </p>
+ *
+ * @param property the system property name.
* @param defaultIfAbsent get this Supplier when the property is empty or throws SecurityException.
* @return the system property value or {@code null} if a security problem occurs
*/
@@ -3735,20 +3749,6 @@ public final class SystemProperties {
}
/**
- * Gets a System property, defaulting to {@code null} if the property cannot be read.
- * <p>
- * If a {@link SecurityException} is caught, the return value is {@code null}.
- * </p>
- *
- * @param property the system property name.
- * @param defaultIfAbsent use this value when the property is empty or throws SecurityException.
- * @return the system property value or {@code null} if a security problem occurs
- */
- static String getProperty(final String property, final String defaultIfAbsent) {
- return getProperty(property, () -> defaultIfAbsent);
- }
-
- /**
* Gets the current value from the system properties map.
* <p>
* Returns {@code null} if the property cannot be read due to a {@link SecurityException}.
diff --git a/src/main/java/org/apache/commons/lang3/function/Consumers.java b/src/main/java/org/apache/commons/lang3/function/Consumers.java
index 43f161d07..49b514ec1 100644
--- a/src/main/java/org/apache/commons/lang3/function/Consumers.java
+++ b/src/main/java/org/apache/commons/lang3/function/Consumers.java
@@ -32,21 +32,6 @@ public class Consumers {
private static final Consumer NOP = Function.identity()::apply;
/**
- * Gets the NOP Consumer singleton.
- *
- * @param <T> type type to consume.
- * @return the NOP Consumer singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Consumer<T> nop() {
- return NOP;
- }
-
- private Consumers() {
- // No instances.
- }
-
- /**
* Applies the given {@link Consumer} action to the object if the consumer is not {@code null}. Otherwise, does
* nothing.
*
@@ -60,4 +45,19 @@ public class Consumers {
consumer.accept(object);
}
}
+
+ /**
+ * Gets the NOP Consumer singleton.
+ *
+ * @param <T> type type to consume.
+ * @return the NOP Consumer singleton.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Consumer<T> nop() {
+ return NOP;
+ }
+
+ private Consumers() {
+ // No instances.
+ }
}
diff --git a/src/main/java/org/apache/commons/lang3/function/Functions.java b/src/main/java/org/apache/commons/lang3/function/Functions.java
index cf8309f8f..8d9313ca5 100644
--- a/src/main/java/org/apache/commons/lang3/function/Functions.java
+++ b/src/main/java/org/apache/commons/lang3/function/Functions.java
@@ -27,6 +27,21 @@ import java.util.function.Function;
public final class Functions {
/**
+ * Applies the {@link Function} on the object if the function is not {@code null}. Otherwise, does nothing and
+ * returns {@code null}.
+ *
+ * @param object the object to apply the function.
+ * @param function the function to apply.
+ * @param <T> the type of the argument the function applies.
+ * @param <R> the type of the result the function returns.
+ * @return the value the function returns if the function is not {@code null}; {@code null} otherwise.
+ * @since 3.15.0
+ */
+ public static <T, R> R apply(final T object, final Function<T, R> function) {
+ return function != null ? function.apply(object) : null;
+ }
+
+ /**
* Starts a fluent chain like {@code function(foo::bar).andThen(...).andThen(...).apply(...);}
*
* @param <T> Input type.
@@ -41,19 +56,4 @@ public final class Functions {
private Functions() {
// no instances needed.
}
-
- /**
- * Applies the {@link Function} on the object if the function is not {@code null}. Otherwise, does nothing and
- * returns {@code null}.
- *
- * @param object the object to apply the function.
- * @param function the function to apply.
- * @param <T> the type of the argument the function applies.
- * @param <R> the type of the result the function returns.
- * @return the value the function returns if the function is not {@code null}; {@code null} otherwise.
- * @since 3.15.0
- */
- public static <T, R> R apply(final T object, final Function<T, R> function) {
- return function != null ? function.apply(object) : null;
- }
}
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java
index aa827ddf5..96aef4d64 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java
@@ -111,13 +111,13 @@ public class StringUtilsTrimStripTest extends AbstractLangTest {
}
@Test
- public void testStripAccentsUWithBar() {
- assertEquals("U u U u", StringUtils.stripAccents("\u0244 \u0289 \u1D7E \u1DB6"));
+ public void testStripAccentsTWithStroke() {
+ assertEquals("T t", StringUtils.stripAccents("\u0166 \u0167"));
}
@Test
- public void testStripAccentsTWithStroke() {
- assertEquals("T t", StringUtils.stripAccents("\u0166 \u0167"));
+ public void testStripAccentsUWithBar() {
+ assertEquals("U u U u", StringUtils.stripAccents("\u0244 \u0289 \u1D7E \u1DB6"));
}
@Test
diff --git a/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java b/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
index 47828debf..e649c25db 100644
--- a/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
+++ b/src/test/java/org/apache/commons/lang3/function/ConsumersTest.java
@@ -31,22 +31,13 @@ import org.junit.jupiter.api.Test;
*/
public class ConsumersTest extends AbstractLangTest {
- /**
- * Tests {@link Consumers#nop()}.
- */
- @Test
- public void testNop() {
- Stream.of("").forEach(Consumers.nop());
- //
- final Consumer<?> c1 = Consumers.nop();
- c1.accept(null);
- final Consumer<Object> c2 = Consumers.nop();
- c2.accept(null);
- final Consumer<String> c3 = Consumers.nop();
- c3.accept(null);
- //
- Consumers.nop().accept(null);
- Consumers.nop().accept("");
+ private static final class TestConsumer<T> implements Consumer<T> {
+ private boolean isCalled;
+
+ @Override
+ public void accept(T t) {
+ isCalled = true;
+ }
}
/**
@@ -67,12 +58,21 @@ public class ConsumersTest extends AbstractLangTest {
assertEquals("foo", builder2.toString());
}
- private static final class TestConsumer<T> implements Consumer<T> {
- private boolean isCalled;
-
- @Override
- public void accept(T t) {
- isCalled = true;
- }
+ /**
+ * Tests {@link Consumers#nop()}.
+ */
+ @Test
+ public void testNop() {
+ Stream.of("").forEach(Consumers.nop());
+ //
+ final Consumer<?> c1 = Consumers.nop();
+ c1.accept(null);
+ final Consumer<Object> c2 = Consumers.nop();
+ c2.accept(null);
+ final Consumer<String> c3 = Consumers.nop();
+ c3.accept(null);
+ //
+ Consumers.nop().accept(null);
+ Consumers.nop().accept("");
}
}
diff --git a/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java b/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
index 4693eb00a..8f5825134 100644
--- a/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
+++ b/src/test/java/org/apache/commons/lang3/function/FunctionsTest.java
@@ -30,14 +30,6 @@ import org.junit.jupiter.api.Test;
public class FunctionsTest {
/**
- * Tests {@link Functions#function(Function)}.
- */
- @Test
- public void testFunction() {
- assertEquals("foo", Functions.function(String::valueOf).andThen(String::toString).apply("foo"));
- }
-
- /**
* Tests {@link Functions#apply(Object, Function)}.
*/
@Test
@@ -46,4 +38,12 @@ public class FunctionsTest {
assertEquals("foo-bar", Functions.apply(null, object -> "foo-bar"));
assertNull(Functions.apply("foo", null));
}
+
+ /**
+ * Tests {@link Functions#function(Function)}.
+ */
+ @Test
+ public void testFunction() {
+ assertEquals("foo", Functions.function(String::valueOf).andThen(String::toString).apply("foo"));
+ }
}
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 29404044d..46f46630c 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -141,19 +141,19 @@ public class NumberUtilsTest extends AbstractLangTest {
return parsable;
}
- private boolean isParsableFloat(final String s) {
+ private boolean isParsableDouble(final String s) {
final boolean parsable = NumberUtils.isParsable(s);
assertTrue(isNumberFormatParsable(s), s);
assertTrue(isNumberIntegerOnlyFormatParsable(s), s);
- assertEquals(parsable, isApplyNonNull(s, Float::parseFloat), s);
+ assertEquals(parsable, isApplyNonNull(s, Double::parseDouble), s);
return parsable;
}
- private boolean isParsableDouble(final String s) {
+ private boolean isParsableFloat(final String s) {
final boolean parsable = NumberUtils.isParsable(s);
assertTrue(isNumberFormatParsable(s), s);
assertTrue(isNumberIntegerOnlyFormatParsable(s), s);
- assertEquals(parsable, isApplyNonNull(s, Double::parseDouble), s);
+ assertEquals(parsable, isApplyNonNull(s, Float::parseFloat), s);
return parsable;
}