JAMES-1745 Rename Collectors to ImmutableCollectors
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/bfe79736 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/bfe79736 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/bfe79736 Branch: refs/heads/master Commit: bfe79736e4575428032daedc086c998ebeeaab45 Parents: 4e13597 Author: Antoine Duprat <[email protected]> Authored: Thu Jun 2 10:51:48 2016 +0200 Committer: Antoine Duprat <[email protected]> Committed: Fri Jun 3 13:10:59 2016 +0200 ---------------------------------------------------------------------- .../init/CassandraModuleComposite.java | 8 +- .../cassandra/init/CassandraTypesProvider.java | 4 +- .../cassandra/mail/CassandraMessageMapper.java | 3 +- .../apache/james/util/streams/Collectors.java | 56 --------- .../james/util/streams/ImmutableCollectors.java | 56 +++++++++ .../james/util/streams/CollectorsTest.java | 121 ------------------- .../util/streams/ImmutableCollectorsTest.java | 121 +++++++++++++++++++ .../jmap/methods/GetMessageListMethod.java | 8 +- .../james/jmap/methods/GetMessagesMethod.java | 6 +- .../jmap/methods/JmapResponseWriterImpl.java | 4 +- .../james/jmap/model/GetMailboxesRequest.java | 4 +- .../org/apache/james/jmap/model/Message.java | 7 +- .../james/jmap/model/MessageProperties.java | 8 +- 13 files changed, 204 insertions(+), 202 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraModuleComposite.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraModuleComposite.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraModuleComposite.java index 13184a5..bd1a52e 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraModuleComposite.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraModuleComposite.java @@ -26,7 +26,7 @@ import org.apache.james.backends.cassandra.components.CassandraIndex; import org.apache.james.backends.cassandra.components.CassandraModule; import org.apache.james.backends.cassandra.components.CassandraTable; import org.apache.james.backends.cassandra.components.CassandraType; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import com.google.common.collect.ImmutableList; @@ -39,13 +39,13 @@ public class CassandraModuleComposite implements CassandraModule { public CassandraModuleComposite(CassandraModule... modules) { tables = Arrays.stream(modules) .flatMap(module -> module.moduleTables().stream()) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); index = Arrays.stream(modules) .flatMap(module -> module.moduleIndex().stream()) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); types = Arrays.stream(modules) .flatMap(module -> module.moduleTypes().stream()) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTypesProvider.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTypesProvider.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTypesProvider.java index 10e3873..2618207 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTypesProvider.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/init/CassandraTypesProvider.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import org.apache.james.backends.cassandra.components.CassandraModule; import org.apache.james.backends.cassandra.components.CassandraType; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import com.datastax.driver.core.Session; import com.datastax.driver.core.UserType; @@ -38,7 +38,7 @@ public class CassandraTypesProvider { public CassandraTypesProvider(CassandraModule module, Session session) { userTypes = module.moduleTypes() .stream() - .collect(Collectors.toImmutableMap( + .collect(ImmutableCollectors.toImmutableMap( CassandraType::getName, type -> getSessionType(session, type))); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/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 c2420cd..22fe268 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 @@ -96,6 +96,7 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage; import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty; +import org.apache.james.util.streams.ImmutableCollectors; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; @@ -339,7 +340,7 @@ public class CassandraMessageMapper implements MessageMapper { return row.getList(ATTACHMENTS_IDS, String.class) .stream() .map(AttachmentId::from) - .collect(org.apache.james.util.streams.Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); default: return ImmutableList.of(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/container/util-java8/src/main/java/org/apache/james/util/streams/Collectors.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/streams/Collectors.java b/server/container/util-java8/src/main/java/org/apache/james/util/streams/Collectors.java deleted file mode 100644 index c55cd40..0000000 --- a/server/container/util-java8/src/main/java/org/apache/james/util/streams/Collectors.java +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.util.streams; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collector; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -public class Collectors { - - public static <T> Collector<T, List<T>, ImmutableList<T>> toImmutableList() { - return Collector.of(ArrayList::new, List::add, (left, right) -> { - left.addAll(right); - return left; - }, ImmutableList::copyOf); - } - - public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { - return Collector.of(ImmutableSet::builder, ImmutableSet.Builder::add, (left, right) -> { - left.addAll(right.build()); - return left; - }, ImmutableSet.Builder::build); - } - - public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap( - Function<? super T, ? extends K> keyMapper, - Function<? super T, ? extends V> valueMapper) { - return Collector.of(ImmutableMap::<K,V>builder, - (acc, v) -> acc.put(keyMapper.apply(v), valueMapper.apply(v)), - (map1, map2) -> map1.putAll(map2.build()), - ImmutableMap.Builder::build); - } -} - http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/container/util-java8/src/main/java/org/apache/james/util/streams/ImmutableCollectors.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/streams/ImmutableCollectors.java b/server/container/util-java8/src/main/java/org/apache/james/util/streams/ImmutableCollectors.java new file mode 100644 index 0000000..90d7703 --- /dev/null +++ b/server/container/util-java8/src/main/java/org/apache/james/util/streams/ImmutableCollectors.java @@ -0,0 +1,56 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.util.streams; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collector; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +public class ImmutableCollectors { + + public static <T> Collector<T, List<T>, ImmutableList<T>> toImmutableList() { + return Collector.of(ArrayList::new, List::add, (left, right) -> { + left.addAll(right); + return left; + }, ImmutableList::copyOf); + } + + public static <T> Collector<T, ImmutableSet.Builder<T>, ImmutableSet<T>> toImmutableSet() { + return Collector.of(ImmutableSet::builder, ImmutableSet.Builder::add, (left, right) -> { + left.addAll(right.build()); + return left; + }, ImmutableSet.Builder::build); + } + + public static <T, K, V> Collector<T, ImmutableMap.Builder<K, V>, ImmutableMap<K, V>> toImmutableMap( + Function<? super T, ? extends K> keyMapper, + Function<? super T, ? extends V> valueMapper) { + return Collector.of(ImmutableMap::<K,V>builder, + (acc, v) -> acc.put(keyMapper.apply(v), valueMapper.apply(v)), + (map1, map2) -> map1.putAll(map2.build()), + ImmutableMap.Builder::build); + } +} + http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/container/util-java8/src/test/java/org/apache/james/util/streams/CollectorsTest.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/streams/CollectorsTest.java b/server/container/util-java8/src/test/java/org/apache/james/util/streams/CollectorsTest.java deleted file mode 100644 index 67e6d47..0000000 --- a/server/container/util-java8/src/test/java/org/apache/james/util/streams/CollectorsTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.util.streams; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.data.MapEntry.entry; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import org.junit.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -public class CollectorsTest { - - @Test - public void immutableListCollectorShouldReturnEmptyImmutableListWhenEmptyStream() { - String[] data = {}; - List<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableList()); - assertThat(actual).isInstanceOf(ImmutableList.class); - assertThat(actual).isEmpty(); - } - - @Test - public void immutableListCollectorShouldReturnImmutableListWhenOneElementStream() { - String[] data = {"a"}; - List<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableList()); - assertThat(actual).isInstanceOf(ImmutableList.class); - assertThat(actual).containsExactly("a"); - } - - @Test - public void immutableListCollectorShouldReturnImmutableListWhen3ElementsStream() { - String[] data = {"a", "b", "c"}; - List<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableList()); - assertThat(actual).isInstanceOf(ImmutableList.class); - assertThat(actual).containsExactly("a", "b", "c"); - } - - @Test - public void immutableSetCollectorShouldReturnEmptyImmutableSetWhenEmptyStream() { - String[] data = {}; - Set<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableSet()); - assertThat(actual).isInstanceOf(ImmutableSet.class); - assertThat(actual).isEmpty(); - } - - @Test - public void immutableSetCollectorShouldReturnImmutableSetWhenOneElementStream() { - String[] data = {"a"}; - Set<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableSet()); - assertThat(actual).isInstanceOf(ImmutableSet.class); - assertThat(actual).containsExactly("a"); - } - - @Test - public void immutableSetCollectorShouldReturnImmutableSetWhen3ElementsStream() { - String[] data = {"a", "b", "c"}; - Set<String> actual = Arrays.stream(data) - .collect(Collectors.toImmutableSet()); - assertThat(actual).isInstanceOf(ImmutableSet.class); - assertThat(actual).containsExactly("a", "b", "c"); - } - - - @Test - public void immutableMapCollectorShouldReturnEmptyImmutableMapWhenEmptyStream() { - String[] data = {}; - Map<String, Integer> actual = Arrays.stream(data) - .collect(Collectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); - assertThat(actual).isInstanceOf(ImmutableMap.class); - assertThat(actual).isEmpty(); - } - - @Test - public void immutableMapCollectorShouldReturnAppliedImmutableMapWhenOneElementStream() { - String[] data = {"a"}; - Map<String, Integer> actual = Arrays.stream(data) - .collect(Collectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); - assertThat(actual).isInstanceOf(ImmutableMap.class); - assertThat(actual).containsExactly(entry("A", 1)); - } - - @Test - public void immutableMapCollectorShouldReturnAppliedImmutableMapWhen3ElementsStream() { - String[] data = {"a", "bb", "ccc"}; - Map<String, Integer> actual = Arrays.stream(data) - .collect(Collectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); - assertThat(actual).isInstanceOf(ImmutableMap.class); - assertThat(actual).containsExactly(entry("A", 1), entry("BB", 2), entry("CCC", 3)); - } - -} - http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/container/util-java8/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java ---------------------------------------------------------------------- diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java b/server/container/util-java8/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java new file mode 100644 index 0000000..31410d9 --- /dev/null +++ b/server/container/util-java8/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java @@ -0,0 +1,121 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.util.streams; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.data.MapEntry.entry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableSet; +import org.junit.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +public class ImmutableCollectorsTest { + + @Test + public void immutableListCollectorShouldReturnEmptyImmutableListWhenEmptyStream() { + String[] data = {}; + List<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableList()); + assertThat(actual).isInstanceOf(ImmutableList.class); + assertThat(actual).isEmpty(); + } + + @Test + public void immutableListCollectorShouldReturnImmutableListWhenOneElementStream() { + String[] data = {"a"}; + List<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableList()); + assertThat(actual).isInstanceOf(ImmutableList.class); + assertThat(actual).containsExactly("a"); + } + + @Test + public void immutableListCollectorShouldReturnImmutableListWhen3ElementsStream() { + String[] data = {"a", "b", "c"}; + List<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableList()); + assertThat(actual).isInstanceOf(ImmutableList.class); + assertThat(actual).containsExactly("a", "b", "c"); + } + + @Test + public void immutableSetCollectorShouldReturnEmptyImmutableSetWhenEmptyStream() { + String[] data = {}; + Set<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableSet()); + assertThat(actual).isInstanceOf(ImmutableSet.class); + assertThat(actual).isEmpty(); + } + + @Test + public void immutableSetCollectorShouldReturnImmutableSetWhenOneElementStream() { + String[] data = {"a"}; + Set<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableSet()); + assertThat(actual).isInstanceOf(ImmutableSet.class); + assertThat(actual).containsExactly("a"); + } + + @Test + public void immutableSetCollectorShouldReturnImmutableSetWhen3ElementsStream() { + String[] data = {"a", "b", "c"}; + Set<String> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableSet()); + assertThat(actual).isInstanceOf(ImmutableSet.class); + assertThat(actual).containsExactly("a", "b", "c"); + } + + + @Test + public void immutableMapCollectorShouldReturnEmptyImmutableMapWhenEmptyStream() { + String[] data = {}; + Map<String, Integer> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); + assertThat(actual).isInstanceOf(ImmutableMap.class); + assertThat(actual).isEmpty(); + } + + @Test + public void immutableMapCollectorShouldReturnAppliedImmutableMapWhenOneElementStream() { + String[] data = {"a"}; + Map<String, Integer> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); + assertThat(actual).isInstanceOf(ImmutableMap.class); + assertThat(actual).containsExactly(entry("A", 1)); + } + + @Test + public void immutableMapCollectorShouldReturnAppliedImmutableMapWhen3ElementsStream() { + String[] data = {"a", "bb", "ccc"}; + Map<String, Integer> actual = Arrays.stream(data) + .collect(ImmutableCollectors.toImmutableMap(x -> x.toUpperCase(), x -> x.length())); + assertThat(actual).isInstanceOf(ImmutableMap.class); + assertThat(actual).containsExactly(entry("A", 1), entry("BB", 2), entry("CCC", 3)); + } + +} + http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java index 50b37a2..0248549 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java @@ -50,7 +50,7 @@ import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.MessageMapper.FetchType; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -136,7 +136,7 @@ public class GetMessageListMethod implements Method { return mailboxManager.search(userMailboxesQuery, mailboxSession) .stream() .map(MailboxMetaData::getPath) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); } private Stream<JmapResponse> processGetMessages(GetMessageListRequest messageListRequest, GetMessageListResponse messageListResponse, ClientId clientId, MailboxSession mailboxSession) { @@ -186,7 +186,7 @@ public class GetMessageListMethod implements Method { .stream() .filter(mailbox -> mailboxIdSet.contains(mailbox.getMailboxId().serialize())) .map(mailbox -> new StoreMailboxPath(mailbox)) - .collect(Collectors.toImmutableSet()); + .collect(ImmutableCollectors.toImmutableSet()); } private Optional<MessageManager> getMessageManager(MailboxPath mailboxPath, MailboxSession mailboxSession) { @@ -207,7 +207,7 @@ public class GetMessageListMethod implements Method { return ImmutableList.copyOf(messageManager.get().search(searchQuery, mailboxSession)) .stream() .map(Throwing.function(messageId -> getMessage(mailboxPath, mailboxSession, messageMapper, messageId))) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); } catch (MailboxException e) { LOGGER.warn("Error when searching messages for query :" + searchQuery, e); return ImmutableList.of(); http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java index 2993ff3..3dadb56 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessagesMethod.java @@ -50,7 +50,7 @@ import org.apache.james.mailbox.store.mail.model.Attachment; import org.apache.james.mailbox.store.mail.model.AttachmentId; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxMessage; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import org.javatuples.Pair; import com.fasterxml.jackson.databind.ser.PropertyFilter; @@ -124,7 +124,7 @@ public class GetMessagesMethod implements Method { List<Message> result = getMessagesRequest.getIds().stream() .flatMap(loadMessages) .map(convertToJmapMessage) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); return GetMessagesResponse.builder().messages(result).expectedMessageIds(getMessagesRequest.getIds()).build(); } @@ -235,7 +235,7 @@ public class GetMessagesMethod implements Method { return (attachmentsIds) -> { return attachmentsIds.stream() .map(Throwing.function(id -> attachmentMapper.getAttachment(id))) - .collect(Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); }; } } http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/JmapResponseWriterImpl.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/JmapResponseWriterImpl.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/JmapResponseWriterImpl.java index 0847147..9e06977 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/JmapResponseWriterImpl.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/JmapResponseWriterImpl.java @@ -28,7 +28,7 @@ import javax.inject.Inject; import org.apache.james.jmap.json.ObjectMapperFactory; import org.apache.james.jmap.model.Property; import org.apache.james.jmap.model.ProtocolResponse; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ser.FilterProvider; @@ -82,6 +82,6 @@ public class JmapResponseWriterImpl implements JmapResponseWriter { private Set<String> toFieldNames(Set<? extends Property> properties) { return properties.stream() .map(Property::asFieldName) - .collect(Collectors.toImmutableSet()); + .collect(ImmutableCollectors.toImmutableSet()); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMailboxesRequest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMailboxesRequest.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMailboxesRequest.java index 722d86b..d735d3b 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMailboxesRequest.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMailboxesRequest.java @@ -23,7 +23,7 @@ import java.util.Optional; import org.apache.commons.lang.NotImplementedException; import org.apache.james.jmap.methods.JmapRequest; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; @@ -69,7 +69,7 @@ public class GetMailboxesRequest implements JmapRequest { .map(MailboxProperty::findProperty) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toImmutableSet())); + .collect(ImmutableCollectors.toImmutableSet())); return this; } http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java index 721c0f7..58e62a6 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java @@ -35,6 +35,7 @@ import org.apache.james.jmap.model.message.EMailer; import org.apache.james.jmap.model.message.IndexableMessage; import org.apache.james.mailbox.store.extractor.DefaultTextExtractor; import org.apache.james.mailbox.store.mail.model.MailboxMessage; +import org.apache.james.util.streams.ImmutableCollectors; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -109,7 +110,7 @@ public class Message { private static ImmutableList<Emailer> fromElasticSearchEmailers(Set<EMailer> emailers) { return emailers.stream() .map(Message::fromElasticSearchEmailer) - .collect(org.apache.james.util.streams.Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); } private static Emailer fromElasticSearchEmailer(EMailer emailer) { @@ -140,7 +141,7 @@ public class Message { .asMap() .entrySet() .stream() - .collect(org.apache.james.util.streams.Collectors.toImmutableMap(Map.Entry::getKey, x -> joinOnComma(x.getValue()))); + .collect(ImmutableCollectors.toImmutableMap(Map.Entry::getKey, x -> joinOnComma(x.getValue()))); } private static String getHeaderAsSingleValue(IndexableMessage im, String header) { @@ -183,7 +184,7 @@ public class Message { private static List<Attachment> getAttachments(List<org.apache.james.mailbox.store.mail.model.Attachment> attachments) { return attachments.stream() .map(Message::fromMailboxAttachment) - .collect(org.apache.james.util.streams.Collectors.toImmutableList()); + .collect(ImmutableCollectors.toImmutableList()); } private static Attachment fromMailboxAttachment(org.apache.james.mailbox.store.mail.model.Attachment attachment) { http://git-wip-us.apache.org/repos/asf/james-project/blob/bfe79736/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java index 4f6ba17..f9485ee 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java @@ -25,7 +25,7 @@ import java.util.Optional; import java.util.stream.Stream; import com.google.common.collect.Sets; -import org.apache.james.util.streams.Collectors; +import org.apache.james.util.streams.ImmutableCollectors; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; @@ -49,11 +49,11 @@ public class MessageProperties { } private ImmutableSet<MessageProperty> toMessageProperties(ImmutableSet<String> properties) { - return properties.stream().flatMap(MessageProperty::find).collect(Collectors.toImmutableSet()); + return properties.stream().flatMap(MessageProperty::find).collect(ImmutableCollectors.toImmutableSet()); } private ImmutableSet<HeaderProperty> toHeadersProperties(ImmutableSet<String> properties) { - return properties.stream().flatMap(HeaderProperty::find).collect(Collectors.toImmutableSet()); + return properties.stream().flatMap(HeaderProperty::find).collect(ImmutableCollectors.toImmutableSet()); } public Optional<ImmutableSet<HeaderProperty>> getOptionalHeadersProperties() { @@ -168,7 +168,7 @@ public class MessageProperties { } public static ImmutableSet<MessageProperty> allOutputProperties() { - return Arrays.stream(values()).filter(MessageProperty::outputProperty).collect(Collectors.toImmutableSet()); + return Arrays.stream(values()).filter(MessageProperty::outputProperty).collect(ImmutableCollectors.toImmutableSet()); } private static boolean outputProperty(MessageProperty p) { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
