You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/05/22 09:04:47 UTC
[isis] branch master updated: ISIS-1841 Internal API: polishing
_With
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 1bdf869 ISIS-1841 Internal API: polishing _With
1bdf869 is described below
commit 1bdf869f24c6c93db5846489e7936d5e0a909307
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue May 22 11:04:44 2018 +0200
ISIS-1841 Internal API: polishing _With
---
.../main/java/org/apache/isis/commons/internal/base/_With.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/core/commons/src/main/java/org/apache/isis/commons/internal/base/_With.java b/core/commons/src/main/java/org/apache/isis/commons/internal/base/_With.java
index c128a54..2e67d45 100644
--- a/core/commons/src/main/java/org/apache/isis/commons/internal/base/_With.java
+++ b/core/commons/src/main/java/org/apache/isis/commons/internal/base/_With.java
@@ -124,33 +124,36 @@ public final class _With<T> {
// -- MAPPING IDIOMS
/**
+ * Equivalent to {@code Optional.ofNullable(obj).map(mapper).orElse(orElse);}
* @param obj (nullable)
* @param mapper
* @param orElse (nullable)
* @return {@code obj!=null ? mapper.apply(obj) : orElse}
*/
- public static <X, R> R mapIfPresent(@Nullable X obj, Function<X, R> mapper, @Nullable R orElse) {
+ public static <X, R> R mapIfPresentElse(@Nullable X obj, Function<X, R> mapper, @Nullable R orElse) {
return obj!=null ? requires(mapper, "mapper").apply(obj) : orElse;
}
/**
+ * Equivalent to {@code Optional.ofNullable(obj).map(mapper).orElseGet(elseGet);}
* @param obj (nullable)
* @param mapper
* @param elseGet
* @return {@code obj!=null ? mapper.apply(obj) : elseGet.get()}
*/
- public static <X, R> R mapIfPresent(@Nullable X obj, Function<X, R> mapper, Supplier<R> elseGet) {
+ public static <X, R> R mapIfPresentElseGet(@Nullable X obj, Function<X, R> mapper, Supplier<R> elseGet) {
return obj!=null ? requires(mapper, "mapper").apply(obj) : requires(elseGet, "elseGet").get();
}
/**
+ * Equivalent to {@code Optional.ofNullable(obj).map(mapper).orElseThrow(elseThrow);}
* @param obj (nullable)
* @param mapper
* @param elseThrow
* @return {@code obj!=null ? mapper.apply(obj) : throw( elseThrow.get() )}
* @throws E
*/
- public static <X, R, E extends Exception> R applyIfPresentElseThrow(
+ public static <X, R, E extends Exception> R mapIfPresentElseThrow(
@Nullable X obj,
Function<X, R> mapper,
Supplier<E> elseThrow)
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.