Skip to content

Commit cffbfda

Browse files
committed
JavaDocs overhaul
1 parent 0bac067 commit cffbfda

File tree

9 files changed

+228
-193
lines changed

9 files changed

+228
-193
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Note: Detailed information about performing a release can be found in the SCM se
193193

194194
### Branching Model
195195

196-
We following a simple git workflow/branching model:
196+
We follow a simple git workflow/branching model:
197197

198198
```
199199
master

vavr/src/main/java/io/vavr/CheckedConsumer.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,50 @@
2424
import static io.vavr.CheckedConsumerModule.sneakyThrow;
2525

2626
/**
27-
* A consumer that may throw, equivalent to {@linkplain java.util.function.Consumer}.
27+
* A {@linkplain java.util.function.Consumer} that is allowed to throw checked exceptions.
2828
*
29-
* @param <T> the value type supplied to this consumer.
29+
* @param <T> the type of the input to the consumer
3030
*/
3131
@FunctionalInterface
3232
public interface CheckedConsumer<T> {
3333

3434
/**
35-
* Creates a {@code CheckedConsumer}.
35+
* Creates a {@code CheckedConsumer} from the given method reference or lambda.
3636
*
37+
* <p>Example usage:</p>
3738
* <pre>{@code
3839
* final CheckedConsumer<Value> checkedConsumer = CheckedConsumer.of(Value::stdout);
3940
* final Consumer<Value> consumer = checkedConsumer.unchecked();
4041
*
41-
* // prints "Hi" on the console
42+
* // prints "Hi" to the console
4243
* consumer.accept(CharSeq.of("Hi!"));
4344
*
44-
* // throws
45+
* // may throw an exception
4546
* consumer.accept(null);
4647
* }</pre>
4748
*
48-
* @param methodReference (typically) a method reference, e.g. {@code Type::method}
49-
* @param <T> type of values that are accepted by the consumer
50-
* @return a new {@code CheckedConsumer}
49+
* @param methodReference typically a method reference, e.g. {@code Type::method}
50+
* @param <T> the type of values accepted by the consumer
51+
* @return a new {@code CheckedConsumer} wrapping the given method reference
5152
* @see CheckedFunction1#of(CheckedFunction1)
5253
*/
5354
static <T> CheckedConsumer<T> of(CheckedConsumer<T> methodReference) {
5455
return methodReference;
5556
}
5657

5758
/**
58-
* Performs side-effects.
59+
* Performs an action on the given value, potentially causing side-effects.
5960
*
60-
* @param t a value of type {@code T}
61-
* @throws Throwable if an error occurs
61+
* @param t the input value of type {@code T}
62+
* @throws Throwable if an error occurs during execution
6263
*/
6364
void accept(T t) throws Throwable;
6465

6566
/**
66-
* Returns a chained {@code CheckedConsumer} that first executes {@code this.accept(t)}
67-
* and then {@code after.accept(t)}, for a given {@code t} of type {@code T}.
67+
* Returns a composed {@code CheckedConsumer} that performs, in sequence,
68+
* {@code this.accept(t)} followed by {@code after.accept(t)} for the same input {@code t}.
6869
*
69-
* @param after the action that will be executed after this action
70+
* @param after the action to execute after this action
7071
* @return a new {@code CheckedConsumer} that chains {@code this} and {@code after}
7172
* @throws NullPointerException if {@code after} is null
7273
*/
@@ -76,9 +77,10 @@ default CheckedConsumer<T> andThen(CheckedConsumer<? super T> after) {
7677
}
7778

7879
/**
79-
* Returns an unchecked {@link Consumer} that will <em>sneaky throw</em> if an exceptions occurs when accepting a value.
80+
* Returns an unchecked {@link Consumer} that <em>sneakily throws</em> any exception
81+
* encountered while accepting a value.
8082
*
81-
* @return a new {@link Consumer} that throws a {@code Throwable}.
83+
* @return a {@link Consumer} that may throw any {@link Throwable} without declaring it
8284
*/
8385
default Consumer<T> unchecked() {
8486
return t -> {

vavr/src/main/java/io/vavr/CheckedPredicate.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,31 @@
2323
import static io.vavr.CheckedPredicateModule.sneakyThrow;
2424

2525
/**
26-
* A {@linkplain java.util.function.Predicate} which may throw.
26+
* A {@linkplain java.util.function.Predicate} that is allowed to throw checked exceptions.
2727
*
2828
* @param <T> the type of the input to the predicate
2929
*/
3030
@FunctionalInterface
3131
public interface CheckedPredicate<T> {
3232

3333
/**
34-
* Creates a {@code CheckedPredicate}.
34+
* Creates a {@code CheckedPredicate} from the given method reference or lambda.
3535
*
36+
* <p>Example usage:</p>
3637
* <pre>{@code
3738
* final CheckedPredicate<Boolean> checkedPredicate = CheckedPredicate.of(Boolean::booleanValue);
3839
* final Predicate<Boolean> predicate = checkedPredicate.unchecked();
3940
*
40-
* // = true
41+
* // returns true
4142
* predicate.test(Boolean.TRUE);
4243
*
43-
* // throws
44+
* // may throw an exception
4445
* predicate.test(null);
4546
* }</pre>
4647
*
47-
* @param methodReference (typically) a method reference, e.g. {@code Type::method}
48-
* @param <T> type of values that are tested by the predicate
49-
* @return a new {@code CheckedPredicate}
48+
* @param methodReference typically a method reference, e.g. {@code Type::method}
49+
* @param <T> the type of values tested by the predicate
50+
* @return a new {@code CheckedPredicate} wrapping the given method reference
5051
* @see CheckedFunction1#of(CheckedFunction1)
5152
*/
5253
static <T> CheckedPredicate<T> of(CheckedPredicate<T> methodReference) {
@@ -57,24 +58,25 @@ static <T> CheckedPredicate<T> of(CheckedPredicate<T> methodReference) {
5758
* Evaluates this predicate on the given argument.
5859
*
5960
* @param t the input argument
60-
* @return {@code true} if the input argument matches the predicate, otherwise {@code false}
61-
* @throws Throwable if an error occurs
61+
* @return {@code true} if the argument satisfies the predicate, {@code false} otherwise
62+
* @throws Throwable if an error occurs during evaluation
6263
*/
6364
boolean test(T t) throws Throwable;
6465

6566
/**
66-
* Negates this predicate.
67+
* Returns a predicate that represents the logical negation of this predicate.
6768
*
68-
* @return A new CheckedPredicate.
69+
* @return a new {@code CheckedPredicate} representing the negated condition
6970
*/
7071
default CheckedPredicate<T> negate() {
7172
return t -> !test(t);
7273
}
7374

7475
/**
75-
* Returns an unchecked {@link Predicate} that will <em>sneaky throw</em> if an exceptions occurs when testing a value.
76+
* Returns an unchecked {@link Predicate} that <em>sneakily throws</em> any exception
77+
* encountered when testing a value.
7678
*
77-
* @return a new {@link Predicate} that throws a {@code Throwable}.
79+
* @return a {@link Predicate} that may throw any {@link Throwable} without declaring it
7880
*/
7981
default Predicate<T> unchecked() {
8082
return t -> {

vavr/src/main/java/io/vavr/CheckedRunnable.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,48 @@
2121
import static io.vavr.CheckedRunnableModule.sneakyThrow;
2222

2323
/**
24-
* A {@linkplain Runnable} which may throw.
24+
* A {@linkplain Runnable} that is allowed to throw checked exceptions.
2525
*/
2626
@FunctionalInterface
2727
public interface CheckedRunnable {
2828

2929
/**
30-
* Creates a {@code CheckedRunnable}.
30+
* Creates a {@code CheckedRunnable} from the given method reference or lambda.
3131
*
32+
* <p>Example usage:</p>
3233
* <pre>{@code
3334
* // class Evil { static void sideEffect() { ... } }
3435
* final CheckedRunnable checkedRunnable = CheckedRunnable.of(Evil::sideEffect);
3536
* final Runnable runnable = checkedRunnable.unchecked();
3637
*
37-
* // may or may not perform a side-effect while not throwing
38+
* // may or may not perform the side-effect without throwing checked exceptions
3839
* runnable.run();
3940
*
40-
* // may or may not perform a side-effect while throwing
41+
* // may or may not perform the side-effect while potentially throwing
4142
* runnable.run();
4243
* }</pre>
4344
*
44-
* @param methodReference (typically) a method reference, e.g. {@code Type::method}
45-
* @return a new {@code CheckedRunnable}
45+
* @param methodReference typically a method reference, e.g. {@code Type::method}
46+
* @return a new {@code CheckedRunnable} wrapping the given method reference
4647
* @see CheckedFunction1#of(CheckedFunction1)
4748
*/
4849
static CheckedRunnable of(CheckedRunnable methodReference) {
4950
return methodReference;
5051
}
5152

5253
/**
53-
* Performs side-effects.
54+
* Executes the action, potentially performing side-effects.
5455
*
55-
* @throws Throwable if an error occurs
56+
* @throws Throwable if an error occurs during execution
5657
*/
58+
5759
void run() throws Throwable;
5860

5961
/**
60-
* Returns an unchecked {@link Runnable} that will <em>sneaky throw</em> if an exceptions occurs when running the unit of work.
62+
* Returns an unchecked {@link Runnable} that <em>sneakily throws</em> any exception
63+
* encountered during execution of this unit of work.
6164
*
62-
* @return a new {@link Runnable} that throws a {@code Throwable}.
65+
* @return a {@link Runnable} that may throw any {@link Throwable} without declaring it
6366
*/
6467
default Runnable unchecked() {
6568
return () -> {

0 commit comments

Comments
 (0)