@@ -229,55 +229,56 @@ public static boolean anyNotNull(final Object... values) {
229
229
230
230
/**
231
231
* <p>
232
- * Invokes the given {@code consumer's} {@link Consumer#accept(Object)} with the first {@code non-null} value from
233
- * {@code objects}. If all the values are null, the consumer is not invoked.
232
+ * Calls the given {@code consumer's} {@link Consumer#accept(Object)} method with the first {@code non-null} value
233
+ * from {@code objects}. If all the values are null, the consumer is not invoked. This is equivalent to the call
234
+ * {@code ObjectUtils.acceptIfNonNull(ObjectUtils.firstNonNull(objects), consumer)}
234
235
* </p>
235
236
*
236
237
* <p>
237
238
* The caller is responsible for thread-safety and exception handling of consumer.
238
239
* </p>
239
240
*
240
241
* <pre>
241
- * ObjectUtils.applyFirstNonNull (bean::setValue, null) - setValue not invoked
242
- * ObjectUtils.applyFirstNonNull (bean::setValue, null, "abc", "def") - setValue invoked with "abc"
243
- * ObjectUtils.applyFirstNonNull (v -> bean.setValue(v), "abc") - setValue invoked with "abc"
242
+ * ObjectUtils.acceptFirstNonNull (bean::setValue, null) - setValue not invoked
243
+ * ObjectUtils.acceptFirstNonNull (bean::setValue, null, "abc", "def") - setValue invoked with "abc"
244
+ * ObjectUtils.acceptFirstNonNull (v -> bean.setValue(v), "abc") - setValue invoked with "abc"
244
245
* </pre>
245
246
*
246
247
* @param <T> the type of the object
247
248
* @param objects the values to test, may be {@code null} or empty
248
249
* @param consumer the consumer operation to invoke with the first non-null {@code objects}.
249
250
* @see #firstNonNull(Object...)
250
- * @see #applyIfNonNull(Consumer, Object )
251
+ * @see #acceptIfNonNull(Object, Consumer )
251
252
* @since 3.12
252
253
*/
253
254
@ SafeVarargs
254
- public static <T > void applyFirstNonNull (final Consumer <T > consumer , final T ... objects ) {
255
- applyIfNonNull ( consumer , firstNonNull (objects ));
255
+ public static <T > void acceptFirstNonNull (final Consumer <T > consumer , final T ... objects ) {
256
+ acceptIfNonNull ( firstNonNull (objects ), consumer );
256
257
}
257
258
258
259
/**
259
260
* <p>
260
- * Invokes the given {@code consumer's} {@link Consumer#accept(Object)} with the {@code object} if it is
261
- * {@code non-null}, otherwise the consumer is not invoked .
261
+ * Calls the given {@code consumer's} {@link Consumer#accept(Object)} method with the {@code object} if it is
262
+ * {@code non-null}.
262
263
* </p>
263
264
*
264
265
* <p>
265
266
* The caller is responsible for thread-safety and exception handling of consumer.
266
267
* </p>
267
268
*
268
269
* <pre>
269
- * ObjectUtils.applyIfNonNull( bean::setValue, null ) - setValue not invoked
270
- * ObjectUtils.applyIfNonNull( bean::setValue, "abc" ) - setValue invoked with "abc"
271
- * ObjectUtils.applyIfNonNull( v -> bean.setValue(v), "abc" ) - setValue invoked with "abc"
270
+ * ObjectUtils.acceptIfNonNull(null, bean::setValue) - setValue not invoked
271
+ * ObjectUtils.acceptIfNonNull("abc", bean::setValue) - setValue invoked with "abc"
272
+ * ObjectUtils.acceptIfNonNull("abc", v -> bean.setValue(v)) - setValue invoked with "abc"
272
273
* </pre>
273
274
*
274
275
* @param <T> the type of the object
275
276
* @param object the {@code Object} to test, may be {@code null}
276
277
* @param consumer the consumer operation to invoke with {@code object} if it is {@code non-null}
277
- * @see #applyFirstNonNull (Consumer, Object...)
278
+ * @see #acceptFirstNonNull (Consumer, Object...)
278
279
* @since 3.12
279
280
*/
280
- public static <T > void applyIfNonNull (final Consumer < T > consumer , final T object ) {
281
+ public static <T > void acceptIfNonNull (final T object , final Consumer < T > consumer ) {
281
282
if (object != null ) {
282
283
consumer .accept (object );
283
284
}
0 commit comments