james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [24/29] james-project git commit: JAMES-2169 Rename confusing optional method
Date Wed, 04 Oct 2017 09:28:47 GMT
JAMES-2169 Rename confusing optional method


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0f698595
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0f698595
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0f698595

Branch: refs/heads/master
Commit: 0f69859558a31a944cbfef96908bae408ea80b0f
Parents: b5c3096
Author: benwa <btellier@linagora.com>
Authored: Tue Oct 3 10:08:10 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Oct 4 16:24:38 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/cassandra/mail/CassandraBlobsDAO.java      | 2 +-
 .../james/mailbox/cassandra/mail/CassandraMailboxMapper.java | 2 +-
 .../james/mailbox/cassandra/mail/CassandraMessageMapper.java | 2 +-
 .../src/main/java/org/apache/james/util/OptionalUtils.java   | 2 +-
 .../test/java/org/apache/james/util/OptionalUtilsTest.java   | 8 ++++----
 .../java/org/apache/james/jmap/model/mailbox/Rights.java     | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
index b96e5c4..7cd3718 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraBlobsDAO.java
@@ -168,7 +168,7 @@ public class CassandraBlobsDAO {
 
     private byte[] concatenateDataParts(Stream<BlobPart> blobParts) {
         ImmutableList<byte[]> parts = blobParts
-            .map(blobPart -> OptionalUtils.peekOnEmpty(
+            .map(blobPart -> OptionalUtils.executeIfEmpty(
                 blobPart.row,
                 () -> LOGGER.warn("Missing blob part for blobId {} and position {}", blobPart.blobId,
blobPart.position)))
             .flatMap(OptionalUtils::toStream)

http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index d9d5c10..f1e37b5 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -141,7 +141,7 @@ public class CassandraMailboxMapper implements MailboxMapper {
 
     private CompletableFuture<Optional<SimpleMailbox>> retrieveMailbox(CassandraMailboxPathDAO.CassandraIdAndPath
idAndPath) {
         return retrieveMailbox(idAndPath.getCassandraId())
-            .thenApply(optional -> OptionalUtils.peekOnEmpty(optional,
+            .thenApply(optional -> OptionalUtils.executeIfEmpty(optional,
                 () -> LOGGER.warn("Could not retrieve mailbox {} with path {} in mailbox
table.", idAndPath.getCassandraId(), idAndPath.getMailboxPath())));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index cf38640..697b523 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -226,7 +226,7 @@ public class CassandraMessageMapper implements MessageMapper {
 
     private CompletableFuture<Optional<ComposedMessageIdWithMetaData>> retrieveComposedId(CassandraId
mailboxId, MessageUid uid) {
         return messageIdDAO.retrieve(mailboxId, uid)
-            .thenApply(optional -> OptionalUtils.peekOnEmpty(optional,
+            .thenApply(optional -> OptionalUtils.executeIfEmpty(optional,
                 () -> LOGGER.warn("Could not retrieve message {} {}", mailboxId, uid)));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/server/container/util-java8/src/main/java/org/apache/james/util/OptionalUtils.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/OptionalUtils.java
b/server/container/util-java8/src/main/java/org/apache/james/util/OptionalUtils.java
index 66628ba..000feb8 100644
--- a/server/container/util-java8/src/main/java/org/apache/james/util/OptionalUtils.java
+++ b/server/container/util-java8/src/main/java/org/apache/james/util/OptionalUtils.java
@@ -28,7 +28,7 @@ public class OptionalUtils {
         void perform();
     }
 
-    public static <T> Optional<T> peekOnEmpty(Optional<T> optional, Operation
operation) {
+    public static <T> Optional<T> executeIfEmpty(Optional<T> optional,
Operation operation) {
         if (!optional.isPresent()) {
             operation.perform();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/server/container/util-java8/src/test/java/org/apache/james/util/OptionalUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/OptionalUtilsTest.java
b/server/container/util-java8/src/test/java/org/apache/james/util/OptionalUtilsTest.java
index a270469..80a8684 100644
--- a/server/container/util-java8/src/test/java/org/apache/james/util/OptionalUtilsTest.java
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/OptionalUtilsTest.java
@@ -36,7 +36,7 @@ public class OptionalUtilsTest {
 
     @Test
     public void ifEmptyShouldPreserveValueOfEmptyOptionals() {
-        Optional<Object> expected = OptionalUtils.peekOnEmpty(Optional.empty(), ()
-> { });
+        Optional<Object> expected = OptionalUtils.executeIfEmpty(Optional.empty(),
() -> { });
 
         assertThat(expected).isEmpty();
     }
@@ -44,7 +44,7 @@ public class OptionalUtilsTest {
     @Test
     public void ifEmptyShouldPreserveValueOfPresentOptionals() {
         String value = "value";
-        Optional<String> expected = OptionalUtils.peekOnEmpty(Optional.of(value), ()
-> { });
+        Optional<String> expected = OptionalUtils.executeIfEmpty(Optional.of(value),
() -> { });
 
         assertThat(expected).contains(value);
     }
@@ -53,7 +53,7 @@ public class OptionalUtilsTest {
     public void ifEmptyShouldPerformOperationIfEmpty() {
         AtomicInteger operationCounter = new AtomicInteger(0);
 
-        OptionalUtils.peekOnEmpty(Optional.empty(), operationCounter::incrementAndGet);
+        OptionalUtils.executeIfEmpty(Optional.empty(), operationCounter::incrementAndGet);
 
         assertThat(operationCounter.get()).isEqualTo(1);
     }
@@ -62,7 +62,7 @@ public class OptionalUtilsTest {
     public void ifEmptyShouldNotPerformOperationIfPresent() {
         AtomicInteger operationCounter = new AtomicInteger(0);
 
-        OptionalUtils.peekOnEmpty(Optional.of("value"), operationCounter::incrementAndGet);
+        OptionalUtils.executeIfEmpty(Optional.of("value"), operationCounter::incrementAndGet);
 
         assertThat(operationCounter.get()).isEqualTo(0);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0f698595/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java
index 99c0e79..38ce0b3 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java
@@ -71,7 +71,7 @@ public class Rights {
         }
 
         public static Optional<Right> forRight(MailboxACL.Right right) {
-            return OptionalUtils.peekOnEmpty(
+            return OptionalUtils.executeIfEmpty(
                 Arrays.stream(values())
                     .filter(jmapRight -> jmapRight.right == right)
                     .findAny(),


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message