commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [commons-lang] branch master updated: - Javadoc. - Don't use 'p' as a parameter name prefix (we don't do that anywhere else.)
Date Fri, 14 Feb 2020 14:50:57 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 05588e4  - Javadoc. - Don't use 'p' as a parameter name prefix (we don't do that
anywhere else.)
05588e4 is described below

commit 05588e4ebb03fb0c9c5f908d7bae049849565afb
Author: Gary Gregory <garydgregory@gmail.com>
AuthorDate: Fri Feb 14 09:50:53 2020 -0500

    - Javadoc.
    - Don't use 'p' as a parameter name prefix (we don't do that anywhere
    else.)
---
 .../java/org/apache/commons/lang3/Streams.java     | 93 ++++++++++++----------
 .../commons/lang3/compare/ComparableUtils.java     |  2 +
 2 files changed, 53 insertions(+), 42 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Streams.java b/src/main/java/org/apache/commons/lang3/Streams.java
index 9510c58..f89cf16 100644
--- a/src/main/java/org/apache/commons/lang3/Streams.java
+++ b/src/main/java/org/apache/commons/lang3/Streams.java
@@ -32,10 +32,10 @@ import org.apache.commons.lang3.Functions.FailableFunction;
 import org.apache.commons.lang3.Functions.FailablePredicate;
 
 /**
- * This class provides utility functions, and classes for working with the
- * java.util.stream package, or more generally, with Java 8 lambdas. More
+ * Provides utility functions, and classes for working with the
+ * {@code java.util.stream} package, or more generally, with Java 8 lambdas. More
  * specifically, it attempts to address the fact that lambdas are supposed
- * not to throw Exceptions, at least not checked Exceptions, aka instances
+ * not to throw Exceptions, at least not checked Exceptions, AKA instances
  * of {@link Exception}. This enforces the use of constructs like
  * <pre>
  *     Consumer&lt;java.lang.reflect.Method&gt; consumer = (m) -&gt; {
@@ -53,20 +53,29 @@ import org.apache.commons.lang3.Functions.FailablePredicate;
  * </pre>
  * Obviously, the second version is much more concise and the spirit of
  * Lambda expressions is met better than in the first version.
+ *
  * @see Stream
  * @see Functions
+ * @since 3.10
  */
 public class Streams {
-   /** A reduced, and simplified version of a {@link Stream} with
-     * failable method signatures.
-     * @param <O> The streams element type.
-     */
+
+   /** 
+    * A reduced, and simplified version of a {@link Stream} with
+    * failable method signatures.
+    * @param <O> The streams element type.
+    */
     public static class FailableStream<O extends Object> {
+
         private Stream<O> stream;
         private boolean terminated;
 
-        public FailableStream(final Stream<O> pStream) {
-            stream = pStream;
+        /**
+         * Constructs a new instance with the given {@code stream}.
+         * @param stream The stream.
+         */
+        public FailableStream(final Stream<O> stream) {
+            this.stream = stream;
         }
 
         protected void assertNotTerminated() {
@@ -86,13 +95,13 @@ public class Streams {
          *
          * <p>This is an intermediate operation.
          *
-         * @param pPredicate a non-interfering, stateless predicate to apply to each
+         * @param predicate a non-interfering, stateless predicate to apply to each
          * element to determine if it should be included.
          * @return the new stream
          */
-        public FailableStream<O> filter(final FailablePredicate<O, ?> pPredicate){
+        public FailableStream<O> filter(final FailablePredicate<O, ?> predicate){
             assertNotTerminated();
-            stream = stream.filter(Functions.asPredicate(pPredicate));
+            stream = stream.filter(Functions.asPredicate(predicate));
             return this;
         }
 
@@ -109,11 +118,11 @@ public class Streams {
          * library chooses.  If the action accesses shared state, it is
          * responsible for providing the required synchronization.
          *
-         * @param pAction a non-interfering action to perform on the elements
+         * @param action a non-interfering action to perform on the elements
          */
-        public void forEach(final FailableConsumer<O, ?> pAction) {
+        public void forEach(final FailableConsumer<O, ?> action) {
             makeTerminated();
-            stream().forEach(Functions.asConsumer(pAction));
+            stream().forEach(Functions.asConsumer(action));
         }
 
         /**
@@ -159,14 +168,14 @@ public class Streams {
          *
          * @param <R> the type of the result
          * @param <A> the intermediate accumulation type of the {@code Collector}
-         * @param pCollector the {@code Collector} describing the reduction
+         * @param collector the {@code Collector} describing the reduction
          * @return the result of the reduction
          * @see #collect(Supplier, BiConsumer, BiConsumer)
          * @see Collectors
          */
-        public <A, R> R collect(final Collector<? super O, A, R> pCollector)
{
+        public <A, R> R collect(final Collector<? super O, A, R> collector) {
             makeTerminated();
-            return stream().collect(pCollector);
+            return stream().collect(collector);
         }
 
         /**
@@ -204,19 +213,19 @@ public class Streams {
          *
          * @param <R> type of the result
          * @param <A> Type of the accumulator.
-         * @param pSupplier a function that creates a new result container. For a
+         * @param pupplier a function that creates a new result container. For a
          *                 parallel execution, this function may be called
          *                 multiple times and must return a fresh value each time.
-         * @param pAccumulator An associative, non-interfering, stateless function for
+         * @param accumulator An associative, non-interfering, stateless function for
          *   incorporating an additional element into a result
-         * @param pCombiner An associative, non-interfering, stateless
+         * @param combiner An associative, non-interfering, stateless
          *   function for combining two values, which must be compatible with the
          *   accumulator function
          * @return The result of the reduction
          */
-        public <A, R> R collect(final Supplier<R> pSupplier, final BiConsumer<R,
? super O> pAccumulator, final BiConsumer<R, R> pCombiner) {
+        public <A, R> R collect(final Supplier<R> pupplier, final BiConsumer<R,
? super O> accumulator, final BiConsumer<R, R> combiner) {
             makeTerminated();
-            return stream().collect(pSupplier, pAccumulator, pCombiner);
+            return stream().collect(pupplier, accumulator, combiner);
         }
 
         /**
@@ -257,14 +266,14 @@ public class Streams {
          * operations parallelize more gracefully, without needing additional
          * synchronization and with greatly reduced risk of data races.
          *
-         * @param pIdentity the identity value for the accumulating function
-         * @param pAccumulator an associative, non-interfering, stateless
+         * @param identity the identity value for the accumulating function
+         * @param accumulator an associative, non-interfering, stateless
          *                    function for combining two values
          * @return the result of the reduction
          */
-        public O reduce(final O pIdentity, final BinaryOperator<O> pAccumulator) {
+        public O reduce(final O identity, final BinaryOperator<O> accumulator) {
             makeTerminated();
-            return stream().reduce(pIdentity, pAccumulator);
+            return stream().reduce(identity, accumulator);
         }
 
         /**
@@ -274,12 +283,12 @@ public class Streams {
          * <p>This is an intermediate operation.
          *
          * @param <R> The element type of the new stream
-         * @param pMapper A non-interfering, stateless function to apply to each element
+         * @param mapper A non-interfering, stateless function to apply to each element
          * @return the new stream
          */
-        public <R> FailableStream<R> map(final FailableFunction<O, R, ?>
pMapper) {
+        public <R> FailableStream<R> map(final FailableFunction<O, R, ?>
mapper) {
             assertNotTerminated();
-            return new FailableStream<>(stream.map(Functions.asFunction(pMapper)));
+            return new FailableStream<>(stream.map(Functions.asFunction(mapper)));
         }
 
         /**
@@ -304,14 +313,14 @@ public class Streams {
          * stream is empty, the quantification is said to be <em>vacuously
          * satisfied</em> and is always {@code true} (regardless of P(x)).
          *
-         * @param pPredicate A non-interfering, stateless predicate to apply to
+         * @param predicate A non-interfering, stateless predicate to apply to
          * elements of this stream
          * @return {@code true} If either all elements of the stream match the
          * provided predicate or the stream is empty, otherwise {@code false}.
          */
-        public boolean allMatch(final FailablePredicate<O, ?> pPredicate) {
+        public boolean allMatch(final FailablePredicate<O, ?> predicate) {
             assertNotTerminated();
-            return stream().allMatch(Functions.asPredicate(pPredicate));
+            return stream().allMatch(Functions.asPredicate(predicate));
         }
 
         /**
@@ -326,14 +335,14 @@ public class Streams {
          * This method evaluates the <em>existential quantification</em> of the
          * predicate over the elements of the stream (for some x P(x)).
          *
-         * @param pPredicate A non-interfering, stateless predicate to apply to
+         * @param predicate A non-interfering, stateless predicate to apply to
          * elements of this stream
          * @return {@code true} if any elements of the stream match the provided
          * predicate, otherwise {@code false}
          */
-        public boolean anyMatch(final FailablePredicate<O, ?> pPredicate) {
+        public boolean anyMatch(final FailablePredicate<O, ?> predicate) {
             assertNotTerminated();
-            return stream().anyMatch(Functions.asPredicate(pPredicate));
+            return stream().anyMatch(Functions.asPredicate(predicate));
         }
     }
 
@@ -371,12 +380,12 @@ public class Streams {
      *  concise, and readable, and meets the spirit of Lambdas better
      *  than the first version.
      * @param <O> The streams element type.
-     * @param pStream The stream, which is being converted.
+     * @param stream The stream, which is being converted.
      * @return The {@link FailableStream}, which has been created by
      *   converting the stream.
      */
-    public static <O> FailableStream<O> stream(final Stream<O> pStream)
{
-        return new FailableStream<>(pStream);
+    public static <O> FailableStream<O> stream(final Stream<O> stream)
{
+        return new FailableStream<>(stream);
     }
 
     /**
@@ -413,11 +422,11 @@ public class Streams {
      *  concise, and readable, and meets the spirit of Lambdas better
      *  than the first version.
      * @param <O> The streams element type.
-     * @param pStream The stream, which is being converted.
+     * @param stream The stream, which is being converted.
      * @return The {@link FailableStream}, which has been created by
      *   converting the stream.
      */
-    public static <O> FailableStream<O> stream(final Collection<O> pStream)
{
-        return stream(pStream.stream());
+    public static <O> FailableStream<O> stream(final Collection<O> stream)
{
+        return stream(stream.stream());
     }
 }
diff --git a/src/main/java/org/apache/commons/lang3/compare/ComparableUtils.java b/src/main/java/org/apache/commons/lang3/compare/ComparableUtils.java
index 4312af7..c757a52 100644
--- a/src/main/java/org/apache/commons/lang3/compare/ComparableUtils.java
+++ b/src/main/java/org/apache/commons/lang3/compare/ComparableUtils.java
@@ -31,6 +31,8 @@ public class ComparableUtils {
 
     /**
      * Provides access to the available methods
+     *
+     * @param <A> the type of objects that this object may be compared against.
      */
     public static class ComparableCheckBuilder<A extends Comparable<A>> {
 


Mime
View raw message