Skip to content

Commit 0d9d491

Browse files
committed
javadoc improvements
1 parent 02f8c32 commit 0d9d491

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

core/src/main/java/org/everit/json/schema/loader/internal/TypeBasedMultiplexer.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
* Example usage: <code>
3737
* Object additProps = schemaJson.get("additionalProperties");
3838
* typeMultiplexer(additionalProps)
39-
* .ifIs(JSONArray.class).then(arr -> {...if additProps is a JSONArray then process it... })
40-
* .ifObject().then(obj -> {...if additProps is a JSONArray then process it... })
39+
* .ifIs(JSONArray.class).then(arr -&gt; {...if additProps is a JSONArray then process it... })
40+
* .ifObject().then(obj -&gt; {...if additProps is a JSONArray then process it... })
4141
* .requireAny(); // throw a SchemaException if additProps is neither a JSONArray nor a JSONObject
4242
* </code>
4343
*
@@ -91,10 +91,18 @@ public TypeBasedMultiplexer then(final Consumer<JSONObject> consumer) {
9191
*
9292
* @param <E>
9393
* the type of the input to the operation.
94-
* @return the parent multiplexer instance
9594
*/
9695
@FunctionalInterface
9796
public interface OnTypeConsumer<E> {
97+
98+
/**
99+
* Sets the callback (consumer) to be called if the type of {@code obj} is the previously set
100+
* {@code predicateClass}.
101+
*
102+
* @param consumer
103+
* the callback to be called if the type of {@code obj} is the previously set class.
104+
* @return the parent multiplexer instance
105+
*/
98106
TypeBasedMultiplexer then(Consumer<E> consumer);
99107
}
100108

@@ -132,14 +140,25 @@ public TypeBasedMultiplexer then(final Consumer<E> consumer) {
132140
private final Collection<ResolutionScopeChangeListener> scopeChangeListeners = new ArrayList<>(1);
133141

134142
/**
135-
* Constructor with {@code null} {@code keyOfObj}.
143+
* Constructor with {@code null} {@code keyOfObj} and {@code null} {@code id}.
144+
*
145+
* @param obj
146+
* the object which' class is matched against the classes defined by {@link #ifIs(Class)}
147+
* (or {@link #ifObject()}) calls.
136148
*/
137149
public TypeBasedMultiplexer(final Object obj) {
138150
this(null, obj);
139151
}
140152

141153
/**
142154
* Contstructor with {@code null id}.
155+
*
156+
* @param keyOfObj
157+
* is an optional (nullable) string used by {@link #requireAny()} to construct the
158+
* message of the {@link SchemaException} if no appropriate consumer action is found.
159+
* @param obj
160+
* the object which' class is matched against the classes defined by {@link #ifIs(Class)}
161+
* (or {@link #ifObject()}) calls.
143162
*/
144163
public TypeBasedMultiplexer(final String keyOfObj, final Object obj) {
145164
this(keyOfObj, obj, null);
@@ -172,6 +191,14 @@ public void addResolutionScopeChangeListener(
172191
* Creates a setter which will be invoked by {@link #orElse(Consumer)} or {@link #requireAny()} if
173192
* {@code obj} is an instance of {@code predicateClass}.
174193
*
194+
* @param predicateClass
195+
* the predicate class (the callback set by a subsequent
196+
* {@link OnTypeConsumer#then(Consumer)} will be executed if {@code obj} is an instance
197+
* of {@code predicateClass}).
198+
* @param <E>
199+
* the type represented by {@code predicateClass}.
200+
* @return an {@code OnTypeConsumer} implementation to be used to set the action performed if
201+
* {@code obj} is an instance of {@code predicateClass}.
175202
* @throws IllegalArgumentException
176203
* if {@code predicateClass} is {@link JSONObject}. Use {@link #ifObject()} for matching
177204
* {@code obj}'s class against {@link JSONObject}.
@@ -194,6 +221,9 @@ public <E> OnTypeConsumer<E> ifIs(final Class<E> predicateClass) {
194221
* append this id value to {@link org.everit.json.schema.loader.SchemaLoader#id} for the duration
195222
* of the action execution, then it will restore the original id.
196223
* </p>
224+
*
225+
* @return an {@code OnTypeConsumer} implementation to be used to set the action performed if
226+
* {@code obj} is a JSONObject instance.
197227
*/
198228
public OnTypeConsumer<JSONObject> ifObject() {
199229
return new IdModifyingTypeConsumerImpl(JSONObject.class);
@@ -203,6 +233,9 @@ public OnTypeConsumer<JSONObject> ifObject() {
203233
* Checks if the {@code obj} is an instance of any previously set classes (by {@link #ifIs(Class)}
204234
* or {@link #ifObject()}), performs the mapped action of found or invokes {@code orElseConsumer}
205235
* with the {@code obj}.
236+
*
237+
* @param orElseConsumer
238+
* the callback to be called if no types matched.
206239
*/
207240
public void orElse(final Consumer<Object> orElseConsumer) {
208241
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)