commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject [commons-lang] 02/02: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang
Date Fri, 14 Feb 2020 21:38:02 GMT
This is an automated email from the ASF dual-hosted git repository.

jochen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit ee87df847299c55c97347e6c11e00a283feb189d
Merge: 83dd32b b19b2d3
Author: Jochen Wiedmann <jochen@apache.org>
AuthorDate: Fri Feb 14 22:32:54 2020 +0100

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang

 NOTICE.txt                                         |  2 +-
 pom.xml                                            |  8 +-
 src/changes/changes.xml                            |  4 +
 .../java/org/apache/commons/lang3/ArrayUtils.java  | 22 ++---
 .../java/org/apache/commons/lang3/CharRange.java   |  8 +-
 .../java/org/apache/commons/lang3/ClassUtils.java  | 15 ++--
 .../java/org/apache/commons/lang3/Functions.java   | 84 +++++++++----------
 .../java/org/apache/commons/lang3/ObjectUtils.java |  2 +-
 .../java/org/apache/commons/lang3/Streams.java     | 93 ++++++++++++----------
 .../java/org/apache/commons/lang3/StringUtils.java |  8 +-
 .../java/org/apache/commons/lang3/ThreadUtils.java | 20 ++---
 .../commons/lang3/builder/EqualsBuilder.java       |  2 +-
 .../commons/lang3/builder/HashCodeBuilder.java     |  2 +-
 .../commons/lang3/compare/ComparableUtils.java     |  2 +
 .../lang3/concurrent/AtomicSafeInitializer.java    |  2 +-
 .../commons/lang3/event/EventListenerSupport.java  |  2 +-
 .../apache/commons/lang3/reflect/MethodUtils.java  |  2 +-
 .../apache/commons/lang3/reflect/TypeUtils.java    |  6 +-
 .../commons/lang3/text/ExtendedMessageFormat.java  |  2 +-
 .../commons/lang3/text/FormattableUtils.java       |  2 +-
 .../org/apache/commons/lang3/time/DateUtils.java   |  2 +-
 .../apache/commons/lang3/time/FastDateParser.java  | 16 ++--
 .../java/org/apache/commons/lang3/tuple/Pair.java  |  2 +-
 .../org/apache/commons/lang3/ArchUtilsTest.java    |  2 +-
 .../org/apache/commons/lang3/ArrayUtilsTest.java   | 82 +++++++++----------
 .../org/apache/commons/lang3/CharRangeTest.java    |  2 +-
 .../org/apache/commons/lang3/FunctionsTest.java    | 36 ++++-----
 .../org/apache/commons/lang3/LocaleUtilsTest.java  |  2 +-
 .../org/apache/commons/lang3/ObjectUtilsTest.java  |  8 +-
 .../commons/lang3/RandomStringUtilsTest.java       |  2 +-
 .../commons/lang3/SerializationUtilsTest.java      |  4 +-
 .../java/org/apache/commons/lang3/StreamsTest.java | 18 ++---
 .../org/apache/commons/lang3/StringUtilsTest.java  | 14 ++--
 .../org/apache/commons/lang3/ValidateTest.java     |  4 +-
 .../commons/lang3/builder/EqualsBuilderTest.java   |  2 +-
 .../ReflectionToStringBuilderSummaryTest.java      |  4 +-
 .../concurrent/BackgroundInitializerTest.java      |  4 +-
 .../lang3/concurrent/ConcurrentUtilsTest.java      | 22 ++---
 .../concurrent/EventCountCircuitBreakerTest.java   |  4 +-
 .../concurrent/MultiBackgroundInitializerTest.java |  2 +-
 .../apache/commons/lang3/event/EventUtilsTest.java |  4 +-
 .../lang3/exception/ExceptionUtilsTest.java        | 10 +--
 .../commons/lang3/reflect/FieldUtilsTest.java      | 15 ++--
 .../apache/commons/lang3/text/StrBuilderTest.java  | 16 ++--
 .../commons/lang3/text/StrSubstitutorTest.java     |  4 +-
 .../apache/commons/lang3/time/DateUtilsTest.java   |  4 +-
 .../commons/lang3/time/FastDateParserSDFTest.java  |  4 +-
 .../lang3/time/FastDatePrinterTimeZonesTest.java   |  2 +-
 .../apache/commons/lang3/time/WeekYearTest.java    |  4 +-
 .../commons/lang3/tuple/ImmutablePairTest.java     | 22 ++---
 .../commons/lang3/tuple/ImmutableTripleTest.java   | 22 ++---
 .../commons/lang3/tuple/MutablePairTest.java       |  2 +-
 .../org/apache/commons/lang3/tuple/PairTest.java   |  2 +-
 53 files changed, 326 insertions(+), 305 deletions(-)

diff --cc src/main/java/org/apache/commons/lang3/Streams.java
index 86edb2f,9898d06..6a35725
--- a/src/main/java/org/apache/commons/lang3/Streams.java
+++ b/src/main/java/org/apache/commons/lang3/Streams.java
@@@ -422,63 -426,7 +431,63 @@@ public class Streams 
       * @return The {@link FailableStream}, which has been created by
       *   converting the stream.
       */
-     public static <O> FailableStream<O> stream(Collection<O> pStream)
{
-         return stream(pStream.stream());
+     public static <O> FailableStream<O> stream(final Collection<O> stream)
{
+         return stream(stream.stream());
      }
 +
 +    public static class ArrayCollector<O> implements Collector<O, List<O>,
O[]> {
 +        private static final Set<Characteristics> characteristics = Collections.emptySet();
 +        private final Class<O> elementType;
 +
 +        public ArrayCollector(Class<O> pElementType) {
 +            elementType = pElementType;
 +        }
 +
 +        @Override
 +        public Supplier<List<O>> supplier() {
 +            return () -> new ArrayList<O>();
 +        }
 +
 +        @Override
 +        public BiConsumer<List<O>, O> accumulator() {
 +            return (list, o) -> {
 +                list.add(o);
 +            };
 +        }
 +
 +        @Override
 +        public BinaryOperator<List<O>> combiner() {
 +            return (left, right) -> {
 +                left.addAll(right);
 +                return left;
 +            };
 +        }
 +
 +        @Override
 +        public Function<List<O>, O[]> finisher() {
 +            return (list) -> {
 +                @SuppressWarnings("unchecked")
 +                final O[] array = (O[]) Array.newInstance(elementType, list.size());
 +                return list.toArray(array);
 +            };
 +        }
 +
 +        @Override
 +        public Set<Characteristics> characteristics() {
 +            return characteristics;
 +        }
 +    }
 +
 +    /**
 +     * Returns a {@code Collector} that accumulates the input elements into a
 +     * new array.
 +     *
 +     * @param pElementType Type of an element in the array.
 +     * @param <O> the type of the input elements
 +     * @return a {@code Collector} which collects all the input elements into an
 +     * array, in encounter order
 +     */
 +    public static <O extends Object> Collector<O, ?, O[]> toArray(Class<O>
pElementType) {
 +        return new ArrayCollector<O>(pElementType);
 +    }
  }
diff --cc src/test/java/org/apache/commons/lang3/StreamsTest.java
index da98397,6769c9b..48f7818
--- a/src/test/java/org/apache/commons/lang3/StreamsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StreamsTest.java
@@@ -65,17 -64,7 +65,17 @@@ class StreamsTest 
          }
      }
  
 +    @Test
 +    void testToArray() {
 +        final String[] array = Arrays.asList("2", "3", "1").stream().collect(Streams.toArray(String.class));
 +        assertNotNull(array);
 +        assertEquals(3, array.length);
 +        assertEquals("2", array[0]);
 +        assertEquals("3", array[1]);
 +        assertEquals("1", array[2]);
 +    }
 +
-     protected <T extends Throwable> FailableConsumer<String, T> asIntConsumer(T
pThrowable) {
+     protected <T extends Throwable> FailableConsumer<String, T> asIntConsumer(final
T pThrowable) {
          return (s) -> {
              final Integer i = Integer.valueOf(s);
              if (i.intValue() == 4) {


Mime
View raw message