From 53e58ad41babd88b249a16e1566e6e8eceb26000 Mon Sep 17 00:00:00 2001
From: Gary Gregory
Date: Fri, 12 Jul 2024 10:13:48 -0400
Subject: [PATCH] Javadoc
Use genaric parameter names that match the JRE
---
.../commons/collections4/Transformer.java | 4 +--
.../comparators/TransformingComparator.java | 4 +--
.../functors/ChainedTransformer.java | 1 +
.../functors/CloneTransformer.java | 1 +
.../functors/ClosureTransformer.java | 1 +
.../functors/ConstantTransformer.java | 12 ++++---
.../functors/ExceptionTransformer.java | 6 ++--
.../functors/FactoryTransformer.java | 12 ++++---
.../collections4/functors/IfTransformer.java | 27 ++++++++--------
.../functors/InstantiateTransformer.java | 1 +
.../functors/InvokerTransformer.java | 8 +++--
.../collections4/functors/MapTransformer.java | 12 ++++---
.../collections4/functors/NOPTransformer.java | 1 +
.../functors/PredicateTransformer.java | 1 +
.../functors/StringValueTransformer.java | 1 +
.../functors/SwitchTransformer.java | 32 ++++++++++---------
.../iterators/TransformIterator.java | 2 ++
17 files changed, 73 insertions(+), 53 deletions(-)
diff --git a/src/main/java/org/apache/commons/collections4/Transformer.java b/src/main/java/org/apache/commons/collections4/Transformer.java
index 52bb97c10..fada2391e 100644
--- a/src/main/java/org/apache/commons/collections4/Transformer.java
+++ b/src/main/java/org/apache/commons/collections4/Transformer.java
@@ -33,8 +33,8 @@ import java.util.function.Function;
* cloning and returning the string value.
*
*
- * @param the input type to the transformer
- * @param the output type from the transformer
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
*
* @since 1.0
* @deprecated Use {@link Function}.
diff --git a/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java b/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java
index 74adfdb7e..b8dbe4f0e 100644
--- a/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java
+++ b/src/main/java/org/apache/commons/collections4/comparators/TransformingComparator.java
@@ -31,8 +31,8 @@ import org.apache.commons.collections4.Transformer;
* This class is Serializable from Commons Collections 4.0.
*
*
- * @param the input type to the transformer
- * @param the output type from the transformer
+ * @param the type of the input to the function
+ * @param the type of the result of the function
*
* @since 2.1
*
diff --git a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java
index 444f5bf91..b66da6a70 100644
--- a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java
@@ -29,6 +29,7 @@ import org.apache.commons.collections4.Transformer;
* is passed to the second transformer and so on.
*
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class ChainedTransformer implements Transformer, Serializable {
diff --git a/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java b/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java
index ca1d3f28d..80eb58673 100644
--- a/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java
@@ -30,6 +30,7 @@ import org.apache.commons.collections4.Transformer;
* for more details.
*
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class CloneTransformer implements Transformer {
diff --git a/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java
index f329e5e87..411ab1fd1 100644
--- a/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java
@@ -26,6 +26,7 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation that calls a Closure using the input object
* and then returns the input.
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class ClosureTransformer implements Transformer, Serializable {
diff --git a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java
index 602ac3830..8db424086 100644
--- a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java
@@ -28,9 +28,11 @@ import org.apache.commons.collections4.Transformer;
* use the prototype factory.
*
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public class ConstantTransformer implements Transformer, Serializable {
+public class ConstantTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = 6374440726369055124L;
@@ -66,7 +68,7 @@ public class ConstantTransformer implements Transformer, Serializabl
}
/** The closures to call in turn */
- private final O iConstant;
+ private final R iConstant;
/**
* Constructor that performs no validation.
@@ -74,7 +76,7 @@ public class ConstantTransformer implements Transformer, Serializabl
*
* @param constantToReturn the constant to return each time
*/
- public ConstantTransformer(final O constantToReturn) {
+ public ConstantTransformer(final R constantToReturn) {
iConstant = constantToReturn;
}
@@ -99,7 +101,7 @@ public class ConstantTransformer implements Transformer, Serializabl
* @return the constant
* @since 3.1
*/
- public O getConstant() {
+ public R getConstant() {
return iConstant;
}
@@ -122,7 +124,7 @@ public class ConstantTransformer implements Transformer, Serializabl
* @return the stored constant
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
return iConstant;
}
}
diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java
index b5978605e..52429a0da 100644
--- a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java
@@ -24,9 +24,11 @@ import org.apache.commons.collections4.Transformer;
/**
* Transformer implementation that always throws an exception.
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public final class ExceptionTransformer implements Transformer, Serializable {
+public final class ExceptionTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = 7179106032121985545L;
@@ -70,7 +72,7 @@ public final class ExceptionTransformer implements Transformer, Seri
* @throws FunctorException always
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
throw new FunctorException("ExceptionTransformer invoked");
}
diff --git a/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java b/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java
index 107bc96e1..203c7e090 100644
--- a/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java
@@ -25,9 +25,11 @@ import org.apache.commons.collections4.Transformer;
/**
* Transformer implementation that calls a Factory and returns the result.
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public class FactoryTransformer implements Transformer, Serializable {
+public class FactoryTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = -6817674502475353160L;
@@ -46,7 +48,7 @@ public class FactoryTransformer implements Transformer, Serializable
}
/** The factory to wrap */
- private final Factory extends O> iFactory;
+ private final Factory extends R> iFactory;
/**
* Constructor that performs no validation.
@@ -54,7 +56,7 @@ public class FactoryTransformer implements Transformer, Serializable
*
* @param factory the factory to call, not null
*/
- public FactoryTransformer(final Factory extends O> factory) {
+ public FactoryTransformer(final Factory extends R> factory) {
iFactory = factory;
}
@@ -64,7 +66,7 @@ public class FactoryTransformer implements Transformer, Serializable
* @return the factory
* @since 3.1
*/
- public Factory extends O> getFactory() {
+ public Factory extends R> getFactory() {
return iFactory;
}
@@ -76,7 +78,7 @@ public class FactoryTransformer implements Transformer, Serializable
* @return the transformed result
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
return iFactory.get();
}
diff --git a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
index 787c43ae4..366753db3 100644
--- a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
@@ -26,12 +26,11 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation that will call one of two closures based on whether a predicate evaluates
* as true or false.
*
- * @param The input type for the transformer
- * @param The output type for the transformer
- *
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 4.1
*/
-public class IfTransformer implements Transformer, Serializable {
+public class IfTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = 8069309411242014252L;
@@ -73,13 +72,13 @@ public class IfTransformer implements Transformer, Serializable {
Objects.requireNonNull(trueTransformer, "trueTransformer"), NOPTransformer.nopTransformer());
}
/** The test */
- private final Predicate super I> iPredicate;
+ private final Predicate super T> iPredicate;
/** The transformer to use if true */
- private final Transformer super I, ? extends O> iTrueTransformer;
+ private final Transformer super T, ? extends R> iTrueTransformer;
/** The transformer to use if false */
- private final Transformer super I, ? extends O> iFalseTransformer;
+ private final Transformer super T, ? extends R> iFalseTransformer;
/**
* Constructor that performs no validation.
@@ -89,9 +88,9 @@ public class IfTransformer implements Transformer, Serializable {
* @param trueTransformer transformer used if true, not null
* @param falseTransformer transformer used if false, not null
*/
- public IfTransformer(final Predicate super I> predicate,
- final Transformer super I, ? extends O> trueTransformer,
- final Transformer super I, ? extends O> falseTransformer) {
+ public IfTransformer(final Predicate super T> predicate,
+ final Transformer super T, ? extends R> trueTransformer,
+ final Transformer super T, ? extends R> falseTransformer) {
iPredicate = predicate;
iTrueTransformer = trueTransformer;
@@ -103,7 +102,7 @@ public class IfTransformer implements Transformer, Serializable {
*
* @return the transformer
*/
- public Transformer super I, ? extends O> getFalseTransformer() {
+ public Transformer super T, ? extends R> getFalseTransformer() {
return iFalseTransformer;
}
@@ -112,7 +111,7 @@ public class IfTransformer implements Transformer, Serializable {
*
* @return the predicate
*/
- public Predicate super I> getPredicate() {
+ public Predicate super T> getPredicate() {
return iPredicate;
}
@@ -121,7 +120,7 @@ public class IfTransformer implements Transformer, Serializable {
*
* @return the transformer
*/
- public Transformer super I, ? extends O> getTrueTransformer() {
+ public Transformer super T, ? extends R> getTrueTransformer() {
return iTrueTransformer;
}
@@ -132,7 +131,7 @@ public class IfTransformer implements Transformer, Serializable {
* @return the transformed result
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
if (iPredicate.test(input)) {
return iTrueTransformer.apply(input);
}
diff --git a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
index a64c24b4e..ed063fedd 100644
--- a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
@@ -31,6 +31,7 @@ import org.apache.commons.collections4.Transformer;
* for more details.
*
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class InstantiateTransformer implements Transformer, T> {
diff --git a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
index 5914bb30a..353c6f844 100644
--- a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
@@ -32,9 +32,11 @@ import org.apache.commons.collections4.Transformer;
* for more details.
*
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public class InvokerTransformer implements Transformer {
+public class InvokerTransformer implements Transformer {
/**
* Gets an instance of this transformer calling a specific method with no arguments.
@@ -118,14 +120,14 @@ public class InvokerTransformer implements Transformer {
*/
@Override
@SuppressWarnings("unchecked")
- public O transform(final Object input) {
+ public R transform(final Object input) {
if (input == null) {
return null;
}
try {
final Class> cls = input.getClass();
final Method method = cls.getMethod(iMethodName, iParamTypes);
- return (O) method.invoke(input, iArgs);
+ return (R) method.invoke(input, iArgs);
} catch (final NoSuchMethodException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
input.getClass() + "' does not exist");
diff --git a/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java b/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java
index d84cdec1a..47e545e2d 100644
--- a/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java
@@ -25,9 +25,11 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation that returns the value held in a specified map
* using the input parameter as a key.
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public final class MapTransformer implements Transformer, Serializable {
+public final class MapTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = 862391807045468939L;
@@ -50,7 +52,7 @@ public final class MapTransformer implements Transformer, Serializab
}
/** The map of data to lookup in */
- private final Map super I, ? extends O> iMap;
+ private final Map super T, ? extends R> iMap;
/**
* Constructor that performs no validation.
@@ -58,7 +60,7 @@ public final class MapTransformer implements Transformer, Serializab
*
* @param map the map to use for lookup, not cloned
*/
- private MapTransformer(final Map super I, ? extends O> map) {
+ private MapTransformer(final Map super T, ? extends R> map) {
iMap = map;
}
@@ -68,7 +70,7 @@ public final class MapTransformer implements Transformer, Serializab
* @return the map
* @since 3.1
*/
- public Map super I, ? extends O> getMap() {
+ public Map super T, ? extends R> getMap() {
return iMap;
}
@@ -79,7 +81,7 @@ public final class MapTransformer implements Transformer, Serializab
* @return the transformed result
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
return iMap.get(input);
}
diff --git a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java
index e025fc553..29ab74522 100644
--- a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java
@@ -23,6 +23,7 @@ import org.apache.commons.collections4.Transformer;
/**
* Transformer implementation that does nothing.
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class NOPTransformer implements Transformer, Serializable {
diff --git a/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java b/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java
index 23319f976..00fa8f0dc 100644
--- a/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java
@@ -25,6 +25,7 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation that calls a Predicate using the input object
* and then returns the result.
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public class PredicateTransformer implements Transformer, Serializable {
diff --git a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java
index e39caa6cf..31c3fa3aa 100644
--- a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java
@@ -24,6 +24,7 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation that returns the result of calling
* {@code String.valueOf} on the input object.
*
+ * @param the type of the input and result to the function.
* @since 3.0
*/
public final class StringValueTransformer implements Transformer, Serializable {
diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
index eb3dbfa95..4262bf0ed 100644
--- a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
@@ -27,9 +27,11 @@ import org.apache.commons.collections4.Transformer;
* Transformer implementation calls the transformer whose predicate returns true,
* like a switch statement.
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 3.0
*/
-public class SwitchTransformer implements Transformer, Serializable {
+public class SwitchTransformer implements Transformer, Serializable {
/** Serial version UID */
private static final long serialVersionUID = -6404460890903469332L;
@@ -108,13 +110,13 @@ public class SwitchTransformer implements Transformer, Serializable
return new SwitchTransformer<>(predicates, transformers, defaultTransformer);
}
/** The tests to consider */
- private final Predicate super I>[] iPredicates;
+ private final Predicate super T>[] iPredicates;
/** The matching transformers to call */
- private final Transformer super I, ? extends O>[] iTransformers;
+ private final Transformer super T, ? extends R>[] iTransformers;
/** The default transformer to call if no tests match */
- private final Transformer super I, ? extends O> iDefault;
+ private final Transformer super T, ? extends R> iDefault;
/**
* Hidden constructor for the use by the static factory methods.
@@ -124,13 +126,13 @@ public class SwitchTransformer implements Transformer, Serializable
* @param transformers matching array of transformers, no nulls
* @param defaultTransformer the transformer to use if no match, null means return null
*/
- private SwitchTransformer(final boolean clone, final Predicate super I>[] predicates,
- final Transformer super I, ? extends O>[] transformers,
- final Transformer super I, ? extends O> defaultTransformer) {
+ private SwitchTransformer(final boolean clone, final Predicate super T>[] predicates,
+ final Transformer super T, ? extends R>[] transformers,
+ final Transformer super T, ? extends R> defaultTransformer) {
iPredicates = clone ? FunctorUtils.copy(predicates) : predicates;
iTransformers = clone ? FunctorUtils.copy(transformers) : transformers;
iDefault = defaultTransformer == null ?
- ConstantTransformer.nullTransformer() : defaultTransformer;
+ ConstantTransformer.nullTransformer() : defaultTransformer;
}
/**
@@ -141,9 +143,9 @@ public class SwitchTransformer implements Transformer, Serializable
* @param transformers matching array of transformers, cloned, no nulls
* @param defaultTransformer the transformer to use if no match, null means return null
*/
- public SwitchTransformer(final Predicate super I>[] predicates,
- final Transformer super I, ? extends O>[] transformers,
- final Transformer super I, ? extends O> defaultTransformer) {
+ public SwitchTransformer(final Predicate super T>[] predicates,
+ final Transformer super T, ? extends R>[] transformers,
+ final Transformer super T, ? extends R> defaultTransformer) {
this(true, predicates, transformers, defaultTransformer);
}
@@ -153,7 +155,7 @@ public class SwitchTransformer implements Transformer, Serializable
* @return the default transformer
* @since 3.1
*/
- public Transformer super I, ? extends O> getDefaultTransformer() {
+ public Transformer super T, ? extends R> getDefaultTransformer() {
return iDefault;
}
@@ -163,7 +165,7 @@ public class SwitchTransformer implements Transformer, Serializable
* @return a copy of the predicates
* @since 3.1
*/
- public Predicate super I>[] getPredicates() {
+ public Predicate super T>[] getPredicates() {
return FunctorUtils.copy(iPredicates);
}
@@ -173,7 +175,7 @@ public class SwitchTransformer implements Transformer, Serializable
* @return a copy of the transformers
* @since 3.1
*/
- public Transformer super I, ? extends O>[] getTransformers() {
+ public Transformer super T, ? extends R>[] getTransformers() {
return FunctorUtils.copy(iTransformers);
}
@@ -185,7 +187,7 @@ public class SwitchTransformer implements Transformer, Serializable
* @return the transformed result
*/
@Override
- public O transform(final I input) {
+ public R transform(final T input) {
for (int i = 0; i < iPredicates.length; i++) {
if (iPredicates[i].test(input)) {
return iTransformers[i].apply(input);
diff --git a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
index 03f1a0209..1b3d774ac 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
@@ -23,6 +23,8 @@ import org.apache.commons.collections4.Transformer;
/**
* Decorates an iterator such that each element returned is transformed.
*
+ * @param the type of the input to the function.
+ * @param the type of the result of the function.
* @since 1.0
*/
public class TransformIterator implements Iterator {