Skip to content

Commit 4b9356e

Browse files
committed
Added javadoc to publisher interfaces
1 parent 77fd0dd commit 4b9356e

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

src/main/java/org/dataloader/BatchPublisher.java

+17-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,30 @@
77
/**
88
* A function that is invoked for batch loading a stream of data values indicated by the provided list of keys.
99
* <p>
10-
* The function will call the provided {@link Subscriber} to process the values it has retrieved to allow
10+
* The function <b>must</b> call the provided {@link Subscriber} to process the values it has retrieved to allow
1111
* the future returned by {@link DataLoader#load(Object)} to complete as soon as the individual value is available
1212
* (rather than when all values have been retrieved).
1313
* <p>
14-
* <b>NOTE:</b> It is <b>required </b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as
15-
* the provided keys.
14+
* <b>NOTE:</b> It is <b>required</b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as
15+
* the provided keys and that you provide a value for every key provided.
1616
*
1717
* @param <K> type parameter indicating the type of keys to use for data load requests.
1818
* @param <V> type parameter indicating the type of values returned
19+
* @see BatchLoader for the non-reactive version
1920
*/
2021
public interface BatchPublisher<K, V> {
22+
/**
23+
* Called to batch the provided keys into a stream of values. You <b>must</b> provide
24+
* the same number of values as there as keys, and they <b>must</b> be in the order of the keys.
25+
* <p>
26+
* The idiomatic approach would be to create a reactive {@link org.reactivestreams.Publisher} that provides
27+
* the values given the keys and then subscribe to it with the provided {@link Subscriber}.
28+
* <p>
29+
* <b>NOTE:</b> It is <b>required</b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as
30+
* the provided keys and that you provide a value for every key provided.
31+
*
32+
* @param keys the collection of keys to load
33+
* @param subscriber as values arrive you must call the subscriber for each value
34+
*/
2135
void load(List<K> keys, Subscriber<V> subscriber);
2236
}

src/main/java/org/dataloader/BatchPublisherWithContext.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,30 @@
55
import java.util.List;
66

77
/**
8-
* An {@link BatchPublisher} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
8+
* This form of {@link BatchPublisher} is given a {@link org.dataloader.BatchLoaderEnvironment} object
9+
* that encapsulates the calling context. A typical use case is passing in security credentials or database details
10+
* for example.
11+
* <p>
12+
* See {@link BatchPublisher} for more details on the design invariants that you must implement in order to
13+
* use this interface.
914
*/
1015
public interface BatchPublisherWithContext<K, V> {
16+
/**
17+
* Called to batch the provided keys into a stream of values. You <b>must</b> provide
18+
* the same number of values as there as keys, and they <b>must</b> be in the order of the keys.
19+
* <p>
20+
* The idiomatic approach would be to create a reactive {@link org.reactivestreams.Publisher} that provides
21+
* the values given the keys and then subscribe to it with the provided {@link Subscriber}.
22+
* <p>
23+
* <b>NOTE:</b> It is <b>required</b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as
24+
* the provided keys and that you provide a value for every key provided.
25+
* <p>
26+
* This is given an environment object to that maybe be useful during the call. A typical use case
27+
* is passing in security credentials or database details for example.
28+
*
29+
* @param keys the collection of keys to load
30+
* @param subscriber as values arrive you must call the subscriber for each value
31+
* @param environment an environment object that can help with the call
32+
*/
1133
void load(List<K> keys, Subscriber<V> subscriber, BatchLoaderEnvironment environment);
1234
}

src/main/java/org/dataloader/MappedBatchPublisher.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@
88
/**
99
* A function that is invoked for batch loading a stream of data values indicated by the provided list of keys.
1010
* <p>
11-
* The function will call the provided {@link Subscriber} to process the key/value pairs it has retrieved to allow
11+
* The function <b>must</b> call the provided {@link Subscriber} to process the key/value pairs it has retrieved to allow
1212
* the future returned by {@link DataLoader#load(Object)} to complete as soon as the individual value is available
1313
* (rather than when all values have been retrieved).
1414
*
1515
* @param <K> type parameter indicating the type of keys to use for data load requests.
1616
* @param <V> type parameter indicating the type of values returned
17+
* @see MappedBatchLoader for the non-reactive version
1718
*/
1819
public interface MappedBatchPublisher<K, V> {
20+
/**
21+
* Called to batch the provided keys into a stream of map entries of keys and values.
22+
* <p>
23+
* The idiomatic approach would be to create a reactive {@link org.reactivestreams.Publisher} that provides
24+
* the values given the keys and then subscribe to it with the provided {@link Subscriber}.
25+
*
26+
* @param keys the collection of keys to load
27+
* @param subscriber as values arrive you must call the subscriber for each value
28+
*/
1929
void load(List<K> keys, Subscriber<Map.Entry<K, V>> subscriber);
2030
}

src/main/java/org/dataloader/MappedBatchPublisherWithContext.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,27 @@
66
import java.util.Map;
77

88
/**
9-
* A {@link MappedBatchPublisher} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
9+
* This form of {@link MappedBatchPublisher} is given a {@link org.dataloader.BatchLoaderEnvironment} object
10+
* that encapsulates the calling context. A typical use case is passing in security credentials or database details
11+
* for example.
12+
* <p>
13+
* See {@link MappedBatchPublisher} for more details on the design invariants that you must implement in order to
14+
* use this interface.
1015
*/
1116
public interface MappedBatchPublisherWithContext<K, V> {
17+
18+
/**
19+
* Called to batch the provided keys into a stream of map entries of keys and values.
20+
* <p>
21+
* The idiomatic approach would be to create a reactive {@link org.reactivestreams.Publisher} that provides
22+
* the values given the keys and then subscribe to it with the provided {@link Subscriber}.
23+
* <p>
24+
* This is given an environment object to that maybe be useful during the call. A typical use case
25+
* is passing in security credentials or database details for example.
26+
*
27+
* @param keys the collection of keys to load
28+
* @param subscriber as values arrive you must call the subscriber for each value
29+
* @param environment an environment object that can help with the call
30+
*/
1231
void load(List<K> keys, Subscriber<Map.Entry<K, V>> subscriber, BatchLoaderEnvironment environment);
1332
}

0 commit comments

Comments
 (0)