diff --git a/src/main/java/org/apache/commons/lang3/BooleanUtils.java b/src/main/java/org/apache/commons/lang3/BooleanUtils.java index bad27b667..9b2bd117a 100644 --- a/src/main/java/org/apache/commons/lang3/BooleanUtils.java +++ b/src/main/java/org/apache/commons/lang3/BooleanUtils.java @@ -263,7 +263,7 @@ public class BooleanUtils { public static boolean oneHot(final boolean... array) { ObjectUtils.requireNonEmpty(array, "array"); boolean result = false; - for (boolean element: array) { + for (final boolean element: array) { if (element) { if (result) { return false; diff --git a/src/main/java/org/apache/commons/lang3/CharSet.java b/src/main/java/org/apache/commons/lang3/CharSet.java index 731c9c297..e3b4728ae 100644 --- a/src/main/java/org/apache/commons/lang3/CharSet.java +++ b/src/main/java/org/apache/commons/lang3/CharSet.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; /** *
A set of characters.
@@ -172,9 +173,7 @@ public class CharSet implements Serializable { * @throws NullPointerException if set is {@code null} */ protected CharSet(final String... set) { - for (final String s : set) { - add(s); - } + Stream.of(set).forEach(this::add); } /** diff --git a/src/main/java/org/apache/commons/lang3/CharSetUtils.java b/src/main/java/org/apache/commons/lang3/CharSetUtils.java index 30d83b7ff..733423dd1 100644 --- a/src/main/java/org/apache/commons/lang3/CharSetUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharSetUtils.java @@ -16,6 +16,8 @@ */ package org.apache.commons.lang3; +import org.apache.commons.lang3.stream.Streams; + /** *Operations on {@link CharSet} instances.
* @@ -101,14 +103,7 @@ public class CharSetUtils { * @return whether or not the String is empty */ private static boolean deepEmpty(final String[] strings) { - if (strings != null) { - for (final String s : strings) { - if (StringUtils.isNotEmpty(s)) { - return false; - } - } - } - return true; + return Streams.of(strings).allMatch(StringUtils::isEmpty); } /** diff --git a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java index 44156bd7e..88fcdd1ac 100644 --- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java @@ -22,6 +22,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; +import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; @@ -578,12 +579,7 @@ public class DurationFormatUtils { * @return boolean {@code true} if contained */ static boolean containsTokenWithValue(final Token[] tokens, final Object value) { - for (final Token token : tokens) { - if (token.getValue() == value) { - return true; - } - } - return false; + return Stream.of(tokens).anyMatch(token -> token.getValue() == value); } private final Object value;