Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
Use genaric parameter names that match the JRE
  • Loading branch information
garydgregory committed Jul 12, 2024
1 parent 7e96acb commit 53e58ad
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* cloning and returning the string value.
* </p>
*
* @param <T> the input type to the transformer
* @param <R> the output type from the transformer
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
*
* @since 1.0
* @deprecated Use {@link Function}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* This class is Serializable from Commons Collections 4.0.
* </p>
*
* @param <I> the input type to the transformer
* @param <O> the output type from the transformer
* @param <I> the type of the input to the function
* @param <O> the type of the result of the function
*
* @since 2.1
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* is passed to the second transformer and so on.
* </p>
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* for more details.
* </p>
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class CloneTransformer<T> implements Transformer<T, T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Transformer implementation that calls a Closure using the input object
* and then returns the input.
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class ClosureTransformer<T> implements Transformer<T, T>, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
* use the prototype factory.
* </p>
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 3.0
*/
public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializable {
public class ConstantTransformer<T, R> implements Transformer<T, R>, Serializable {

/** Serial version UID */
private static final long serialVersionUID = 6374440726369055124L;
Expand Down Expand Up @@ -66,15 +68,15 @@ public static <I, O> Transformer<I, O> nullTransformer() {
}

/** The closures to call in turn */
private final O iConstant;
private final R iConstant;

/**
* Constructor that performs no validation.
* Use {@code constantTransformer} if you want that.
*
* @param constantToReturn the constant to return each time
*/
public ConstantTransformer(final O constantToReturn) {
public ConstantTransformer(final R constantToReturn) {
iConstant = constantToReturn;
}

Expand All @@ -99,7 +101,7 @@ public boolean equals(final Object obj) {
* @return the constant
* @since 3.1
*/
public O getConstant() {
public R getConstant() {
return iConstant;
}

Expand All @@ -122,7 +124,7 @@ public int hashCode() {
* @return the stored constant
*/
@Override
public O transform(final I input) {
public R transform(final T input) {
return iConstant;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
/**
* Transformer implementation that always throws an exception.
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 3.0
*/
public final class ExceptionTransformer<I, O> implements Transformer<I, O>, Serializable {
public final class ExceptionTransformer<T, R> implements Transformer<T, R>, Serializable {

/** Serial version UID */
private static final long serialVersionUID = 7179106032121985545L;
Expand Down Expand Up @@ -70,7 +72,7 @@ private Object readResolve() {
* @throws FunctorException always
*/
@Override
public O transform(final I input) {
public R transform(final T input) {
throw new FunctorException("ExceptionTransformer invoked");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
/**
* Transformer implementation that calls a Factory and returns the result.
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 3.0
*/
public class FactoryTransformer<I, O> implements Transformer<I, O>, Serializable {
public class FactoryTransformer<T, R> implements Transformer<T, R>, Serializable {

/** Serial version UID */
private static final long serialVersionUID = -6817674502475353160L;
Expand All @@ -46,15 +48,15 @@ public static <I, O> Transformer<I, O> factoryTransformer(final Factory<? extend
}

/** The factory to wrap */
private final Factory<? extends O> iFactory;
private final Factory<? extends R> iFactory;

/**
* Constructor that performs no validation.
* Use {@code factoryTransformer} if you want that.
*
* @param factory the factory to call, not null
*/
public FactoryTransformer(final Factory<? extends O> factory) {
public FactoryTransformer(final Factory<? extends R> factory) {
iFactory = factory;
}

Expand All @@ -64,7 +66,7 @@ public FactoryTransformer(final Factory<? extends O> factory) {
* @return the factory
* @since 3.1
*/
public Factory<? extends O> getFactory() {
public Factory<? extends R> getFactory() {
return iFactory;
}

Expand All @@ -76,7 +78,7 @@ public Factory<? extends O> getFactory() {
* @return the transformed result
*/
@Override
public O transform(final I input) {
public R transform(final T input) {
return iFactory.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
* Transformer implementation that will call one of two closures based on whether a predicate evaluates
* as true or false.
*
* @param <I> The input type for the transformer
* @param <O> The output type for the transformer
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 4.1
*/
public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
public class IfTransformer<T, R> implements Transformer<T, R>, Serializable {

/** Serial version UID */
private static final long serialVersionUID = 8069309411242014252L;
Expand Down Expand Up @@ -73,13 +72,13 @@ public static <T> Transformer<T, T> ifTransformer(
Objects.requireNonNull(trueTransformer, "trueTransformer"), NOPTransformer.<T>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.
Expand All @@ -89,9 +88,9 @@ public static <T> Transformer<T, T> ifTransformer(
* @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;
Expand All @@ -103,7 +102,7 @@ public IfTransformer(final Predicate<? super I> predicate,
*
* @return the transformer
*/
public Transformer<? super I, ? extends O> getFalseTransformer() {
public Transformer<? super T, ? extends R> getFalseTransformer() {
return iFalseTransformer;
}

Expand All @@ -112,7 +111,7 @@ public IfTransformer(final Predicate<? super I> predicate,
*
* @return the predicate
*/
public Predicate<? super I> getPredicate() {
public Predicate<? super T> getPredicate() {
return iPredicate;
}

Expand All @@ -121,7 +120,7 @@ public Predicate<? super I> getPredicate() {
*
* @return the transformer
*/
public Transformer<? super I, ? extends O> getTrueTransformer() {
public Transformer<? super T, ? extends R> getTrueTransformer() {
return iTrueTransformer;
}

Expand All @@ -132,7 +131,7 @@ public Predicate<? super I> getPredicate() {
* @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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* for more details.
* </p>
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class InstantiateTransformer<T> implements Transformer<Class<? extends T>, T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
* for more details.
* </p>
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 3.0
*/
public class InvokerTransformer<I, O> implements Transformer<I, O> {
public class InvokerTransformer<T, R> implements Transformer<T, R> {

/**
* Gets an instance of this transformer calling a specific method with no arguments.
Expand Down Expand Up @@ -118,14 +120,14 @@ public InvokerTransformer(final String methodName, final Class<?>[] paramTypes,
*/
@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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
* Transformer implementation that returns the value held in a specified map
* using the input parameter as a key.
*
* @param <T> the type of the input to the function.
* @param <R> the type of the result of the function.
* @since 3.0
*/
public final class MapTransformer<I, O> implements Transformer<I, O>, Serializable {
public final class MapTransformer<T, R> implements Transformer<T, R>, Serializable {

/** Serial version UID */
private static final long serialVersionUID = 862391807045468939L;
Expand All @@ -50,15 +52,15 @@ public static <I, O> Transformer<I, O> mapTransformer(final Map<? super I, ? ext
}

/** 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.
* Use {@code mapTransformer} if you want that.
*
* @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;
}

Expand All @@ -68,7 +70,7 @@ private MapTransformer(final Map<? super I, ? extends O> map) {
* @return the map
* @since 3.1
*/
public Map<? super I, ? extends O> getMap() {
public Map<? super T, ? extends R> getMap() {
return iMap;
}

Expand All @@ -79,7 +81,7 @@ private MapTransformer(final Map<? super I, ? extends O> map) {
* @return the transformed result
*/
@Override
public O transform(final I input) {
public R transform(final T input) {
return iMap.get(input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/**
* Transformer implementation that does nothing.
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class NOPTransformer<T> implements Transformer<T, T>, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Transformer implementation that calls a Predicate using the input object
* and then returns the result.
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public class PredicateTransformer<T> implements Transformer<T, Boolean>, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Transformer implementation that returns the result of calling
* {@code String.valueOf} on the input object.
*
* @param <T> the type of the input and result to the function.
* @since 3.0
*/
public final class StringValueTransformer<T> implements Transformer<T, String>, Serializable {
Expand Down
Loading

0 comments on commit 53e58ad

Please sign in to comment.