james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/18] james-project git commit: JAMES-2107 Run IntelliJ inspection: "Convert to lambas"
Date Wed, 16 Aug 2017 09:45:36 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index 4edf95b..0b45833 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -50,67 +50,19 @@ public class RecipientRewriteTableProcessor {
     private final DomainList domainList;
     private final MailetContext mailetContext;
 
-    private static final Predicate<RrtExecutionResult> recipientWithError = new Predicate<RrtExecutionResult>() {
-        @Override
-        public boolean apply(RrtExecutionResult mappingData) {
-            return mappingData.isError();
-        }
-    };
-
-    private static final Predicate<RrtExecutionResult> recipientWithoutError = new Predicate<RrtExecutionResult>() {
-        @Override
-        public boolean apply(RrtExecutionResult mappingData) {
-            return !mappingData.isError();
-        }
-    };
-
-    private static final Predicate<Mapping> noneDomain = new Predicate<Mapping>() {
-        @Override
-        public boolean apply(Mapping address) {
-            return !address.hasDomain();
-        }
-    };
-
-    private static final Predicate<Mapping> haveDomain = new Predicate<Mapping>() {
-        @Override
-        public boolean apply(Mapping address) {
-            return address.hasDomain();
-        }
-    };
-
-    private static final Function<RrtExecutionResult, List<MailAddress>> mailAddressesFromMappingData = new Function<RecipientRewriteTableProcessor.RrtExecutionResult, List<MailAddress>>() {
-        @Override
-        public List<MailAddress> apply(RrtExecutionResult mappingData) {
-            return mappingData.getNewRecipients()
-                .or(mappingData.getRecipientWithError()
-                    .or(ImmutableList.<MailAddress>of()));
-        }
-    };
-
-    private static final Function<Optional<MailAddress>, MailAddress> mailAddressFromOptional = new Function<Optional<MailAddress>, MailAddress>() {
-        @Override
-        public MailAddress apply(Optional<MailAddress> mailAddress) {
-            return mailAddress.get();
-        }
-    };
+    private static final Function<RrtExecutionResult, List<MailAddress>> mailAddressesFromMappingData =
+        mappingData -> mappingData.getNewRecipients()
+            .or(mappingData.getRecipientWithError()
+                .or(ImmutableList.of()));
 
-    private static final Predicate<Optional<MailAddress>> mailAddressPresent = new Predicate<Optional<MailAddress>>() {
-        @Override
-        public boolean apply(Optional<MailAddress> mailAddress) {
-            return mailAddress.isPresent();
-        }
-    };
-
-    private static final Function<Mapping, Optional<MailAddress>> mailAddressFromMapping = new Function<Mapping, Optional<MailAddress>>() {
-        @Override
-        public Optional<MailAddress> apply(Mapping addressMapping) {
+    private static final Function<Mapping, Optional<MailAddress>> mailAddressFromMapping =
+        addressMapping -> {
             try {
                 return Optional.of(new MailAddress(addressMapping.asString()));
             } catch (AddressException e) {
                 return Optional.absent();
             }
-        }
-    };
+        };
 
     public RecipientRewriteTableProcessor(RecipientRewriteTable virtualTableStore, DomainList domainList, MailetContext mailetContext) {
         this.virtualTableStore = virtualTableStore;
@@ -121,9 +73,9 @@ public class RecipientRewriteTableProcessor {
     public void processMail(Mail mail) throws MessagingException{
         ImmutableList<RrtExecutionResult> mappingDatas = toMappingDatas(mail);
 
-        ImmutableList<MailAddress> newRecipients = getRecipientsByCondition(mappingDatas, recipientWithoutError);
+        ImmutableList<MailAddress> newRecipients = getRecipientsByCondition(mappingDatas, mappingData -> !mappingData.isError());
 
-        ImmutableList<MailAddress> errorMailAddresses = getRecipientsByCondition(mappingDatas, recipientWithError);
+        ImmutableList<MailAddress> errorMailAddresses = getRecipientsByCondition(mappingDatas, RrtExecutionResult::isError);
 
         if (!errorMailAddresses.isEmpty()) {
             mailetContext.sendMail(mail.getSender(), errorMailAddresses, mail.getMessage(), Mail.ERROR);
@@ -144,14 +96,10 @@ public class RecipientRewriteTableProcessor {
     }
 
     private ImmutableList<RrtExecutionResult> toMappingDatas(final Mail mail) {
-        Function<MailAddress, RrtExecutionResult> convertToMappingData = new Function<MailAddress, RrtExecutionResult>() {
-            @Override
-            public RrtExecutionResult apply(MailAddress recipient) {
-                Preconditions.checkNotNull(recipient);
-
-                return getRrtExecutionResult(mail, recipient);
-            }
+        Function<MailAddress, RrtExecutionResult> convertToMappingData = recipient -> {
+            Preconditions.checkNotNull(recipient);
 
+            return getRrtExecutionResult(mail, recipient);
         };
 
         return FluentIterable.from(mail.getRecipients())
@@ -197,70 +145,43 @@ public class RecipientRewriteTableProcessor {
     private ImmutableList<Mapping> convertToNewMappings(final Mappings mappings,
             ImmutableList<Mapping> addressWithoutDomains) {
         return FluentIterable.from(mappings)
-            .filter(haveDomain)
+            .filter(Mapping::hasDomain)
             .append(addressWithoutDomains)
             .toList();
     }
 
     private ImmutableList<MailAddress> getLocalAddresses(ImmutableList<MailAddress> mailAddresses) {
         return FluentIterable.from(mailAddresses)
-            .filter(isLocalServer())
+            .filter(mailAddress -> mailetContext.isLocalServer(mailAddress.getDomain()))
             .toList();
     }
 
     private ImmutableList<MailAddress> buildMailAddressFromMappingAddress(ImmutableList<Mapping> newMappings) {
         return FluentIterable.from(newMappings)
             .transform(mailAddressFromMapping)
-            .filter(mailAddressPresent)
-            .transform(mailAddressFromOptional)
+            .filter(Optional::isPresent)
+            .transform(Optional::get)
             .toList();
     }
 
     private ImmutableList<Mapping> getAddressWithNoDomain(Mappings mappings, DomainList domainList) throws MessagingException {
         ImmutableList<Mapping> addressWithoutDomains = FluentIterable.from(mappings)
-            .filter(noneDomain)
+            .filter(address -> !address.hasDomain())
             .toList();
         
         if (!addressWithoutDomains.isEmpty()) {
             final String defaultDomain = getDefaultDomain(domainList);
 
             return FluentIterable.from(addressWithoutDomains)
-                .transform(appendDefaultDomain(defaultDomain))
+                .transform(address -> address.appendDomain(defaultDomain))
                 .toList();
         }
         return ImmutableList.of();
     }
 
-    private Function<Mapping, Mapping> appendDefaultDomain(final String defaultDomain) {
-        return new Function<Mapping, Mapping>() {
-            @Override
-            public Mapping apply(Mapping address) {
-                return address.appendDomain(defaultDomain);
-            }
-        };
-    }
-
-    private Predicate<MailAddress> isLocalServer() {
-        return new Predicate<MailAddress>() {
-            @Override
-            public boolean apply(MailAddress mailAddress) {
-                return mailetContext.isLocalServer(mailAddress.getDomain());
-            }
-        };
-    }
-
-    private Predicate<MailAddress> isNotLocalServer() {
-        return new Predicate<MailAddress>() {
-            @Override
-            public boolean apply(MailAddress mailAddress) {
-                return !mailetContext.isLocalServer(mailAddress.getDomain());
-            }
-        };
-    }
-
     private void forwardToRemoteAddress(MailAddress sender, MailAddress recipient, MimeMessage message, ImmutableList<MailAddress> mailAddresses) throws MessagingException {
         ImmutableList<MailAddress> remoteAddress = FluentIterable.from(mailAddresses)
-            .filter(isNotLocalServer())
+            .filter(mailAddress -> !mailetContext.isLocalServer(mailAddress.getDomain()))
             .toList();
 
         if (!remoteAddress.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/DiscardAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/DiscardAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/DiscardAction.java
index 9964780..f22b6ab 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/DiscardAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/DiscardAction.java
@@ -23,9 +23,7 @@ import javax.mail.MessagingException;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.ActionDiscard;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 
 public class DiscardAction extends FileIntoAction implements MailAction {
@@ -39,16 +37,7 @@ public class DiscardAction extends FileIntoAction implements MailAction {
 
     public static void removeRecipient(Mail mail, ActionContext context) {
         mail.setRecipients(FluentIterable.from(mail.getRecipients())
-            .filter(isNot(context.getRecipient()))
+            .filter(mailAddress -> !mailAddress.equals(context.getRecipient()))
             .toList());
     }
-
-    private static Predicate<MailAddress> isNot(final MailAddress recipient) {
-        return new Predicate<MailAddress>() {
-            @Override
-            public boolean apply(MailAddress input) {
-                return !input.equals(recipient);
-            }
-        };
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
index b046341..749504b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
@@ -18,8 +18,20 @@
  ****************************************************************/
 package org.apache.james.transport.mailets.jsieve;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.mail.Header;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.james.mime4j.dom.address.AddressList;
@@ -42,18 +54,7 @@ import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
 import org.joda.time.DateTime;
 
-import javax.mail.Header;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.common.collect.Lists;
 /**
  * <p>
  * Class <code>SieveMailAdapter</code> implements a <code>MailAdapter</code>
@@ -455,11 +456,7 @@ public class SieveMailAdapter implements MailAdapter, EnvelopeAccessors, ActionC
                 .contentTypes(Lists.newArrayList("text/plain"))
                 .includeHeaders(false)
                 .caseInsensitive(false)
-                .searchContents(Lists.transform(phrasesCaseInsensitive, new Function<String, CharSequence>() {
-                    public CharSequence apply(String s) {
-                        return s;
-                    }
-                })).build()
+                .searchContents(Lists.transform(phrasesCaseInsensitive, s -> s)).build()
                 .messageMatches(getMail().getMessage().getInputStream());
         } catch (Exception e) {
             throw new SieveMailException("Error searching in the mail content", e);
@@ -472,11 +469,7 @@ public class SieveMailAdapter implements MailAdapter, EnvelopeAccessors, ActionC
                 .includeHeaders(false)
                 .caseInsensitive(false)
                 .ignoringMime(true)
-                .searchContents(Lists.transform(phrasesCaseInsensitive, new Function<String, CharSequence>() {
-                    public CharSequence apply(String s) {
-                        return s;
-                    }
-                })).build()
+                .searchContents(Lists.transform(phrasesCaseInsensitive, s -> s)).build()
                 .messageMatches(getMail().getMessage().getInputStream());
         } catch (Exception e) {
             throw new SieveMailException("Error searching in the mail content", e);
@@ -489,11 +482,7 @@ public class SieveMailAdapter implements MailAdapter, EnvelopeAccessors, ActionC
                 .contentTypes(contentTypes)
                 .includeHeaders(false)
                 .caseInsensitive(false)
-                .searchContents(Lists.transform(phrasesCaseInsensitive, new Function<String, CharSequence>() {
-                    public CharSequence apply(String s) {
-                        return s;
-                    }
-                })).build()
+                .searchContents(Lists.transform(phrasesCaseInsensitive, s -> s)).build()
                 .messageMatches(getMail().getMessage().getInputStream());
         } catch (Exception e) {
             throw new SieveMailException("Error searching in the mail content", e);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
index 6819364..f83126c 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationAction.java
@@ -31,7 +31,6 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.joda.time.Days;
 
-import com.google.common.base.Function;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -68,11 +67,7 @@ public class VacationAction implements MailAction {
     private boolean isValidForReply(final Mail mail, ActionVacation actionVacation, final ActionContext context) {
         Set<MailAddress> currentMailAddresses = ImmutableSet.copyOf(mail.getRecipients());
         Set<MailAddress> allowedMailAddresses = ImmutableSet.<MailAddress>builder().addAll(
-            Lists.transform(actionVacation.getAddresses(), new Function<String, MailAddress>() {
-                public MailAddress apply(String s) {
-                    return retrieveAddressFromString(s, context);
-                }
-            }))
+            Lists.transform(actionVacation.getAddresses(), s -> retrieveAddressFromString(s, context)))
             .add(context.getRecipient())
             .build();
         return !Sets.intersection(currentMailAddresses, allowedMailAddresses).isEmpty();

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
index 6511924..12cc1f7 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/VacationReply.java
@@ -19,12 +19,8 @@
 
 package org.apache.james.transport.mailets.jsieve;
 
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
+import java.io.IOException;
+import java.util.List;
 
 import javax.activation.DataHandler;
 import javax.mail.MessagingException;
@@ -34,8 +30,13 @@ import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.util.ByteArrayDataSource;
-import java.io.IOException;
-import java.util.List;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
 
 public class VacationReply {
 
@@ -124,11 +125,9 @@ public class VacationReply {
         }
 
         private MailAddress retrieveOriginalSender() throws AddressException {
-            return Optional.fromNullable(from).transform(new Function<String, MailAddress>() {
-                public MailAddress apply(String address) {
-                    return retrieveAddressFromString(address, context);
-                }
-            }).or(context.getRecipient());
+            return Optional.fromNullable(from)
+                .transform(address -> retrieveAddressFromString(address, context))
+                .or(context.getRecipient());
         }
 
         private MailAddress retrieveAddressFromString(String address, ActionContext context) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
index 1f308bb..3390a8d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/AddressesArrayToMailAddressListConverter.java
@@ -28,9 +28,7 @@ import javax.mail.internet.AddressException;
 import org.apache.mailet.MailAddress;
 import org.slf4j.Logger;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 
@@ -40,27 +38,20 @@ public class AddressesArrayToMailAddressListConverter {
         if (addresses == null) {
             return ImmutableList.of();
         }
-        return FluentIterable.from(Arrays.asList(addresses)).transform(new Function<Address, Optional<MailAddress>>() {
-            @Override
-            public Optional<MailAddress> apply(Address input) {
-                try {
-                    return Optional.of(new MailAddress(input.toString()));
-                } catch (AddressException e) {
-                    logger.debug("Can't parse unsent address " + input, e);
-                    return Optional.absent();
-                }
-            }
-        }).filter(new Predicate<Optional<MailAddress>>() {
-            @Override
-            public boolean apply(Optional<MailAddress> input) {
-                return input.isPresent();
-            }
-        }).transform(new Function<Optional<MailAddress>, MailAddress>() {
-            @Override
-            public MailAddress apply(Optional<MailAddress> input) {
-                return input.get();
-            }
-        }).toList();
+        return FluentIterable.from(Arrays.asList(addresses))
+            .transform(address -> toMailAddress(logger, address))
+            .filter(Optional::isPresent)
+            .transform(Optional::get)
+            .toList();
+    }
+
+    private static Optional<MailAddress> toMailAddress(Logger logger, Address address) {
+        try {
+            return Optional.of(new MailAddress(address.toString()));
+        } catch (AddressException e) {
+            logger.debug("Can't parse unsent address " + address, e);
+            return Optional.absent();
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
index 150d089..7bab048 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnable.java
@@ -39,12 +39,7 @@ import com.google.common.base.Supplier;
 
 public class DeliveryRunnable implements Runnable {
 
-    public static final Supplier<Date> CURRENT_DATE_SUPPLIER = new Supplier<Date>() {
-        @Override
-        public Date get() {
-            return new Date();
-        }
-    };
+    public static final Supplier<Date> CURRENT_DATE_SUPPLIER = Date::new;
     public static final AtomicBoolean DEFAULT_NOT_STARTED = new AtomicBoolean(false);
     private static final String OUTGOING_MAILS = "outgoingMails";
     public static final String REMOTE_DELIVERY_TRIAL = "RemoteDeliveryTrial";

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java
index 61a7152..180a0bf 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/EnhancedMessagingException.java
@@ -70,12 +70,7 @@ public class EnhancedMessagingException {
     }
 
     private Function<String, Boolean> startWith5() {
-        return new Function<String, Boolean>() {
-            @Override
-            public Boolean apply(String input) {
-                return input.startsWith("5");
-            }
-        };
+        return message -> message.startsWith("5");
     }
 
     private Optional<Integer> computeReturnCode() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
index 52bd2a6..4e05b1d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/remoteDelivery/InternetAddressConverter.java
@@ -25,7 +25,6 @@ import javax.mail.internet.InternetAddress;
 
 import org.apache.mailet.MailAddress;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.FluentIterable;
 
@@ -33,12 +32,9 @@ public class InternetAddressConverter {
 
     public static InternetAddress[] convert(Collection<MailAddress> recipients) {
         Preconditions.checkNotNull(recipients);
-        return FluentIterable.from(recipients).transform(new Function<MailAddress, InternetAddress>() {
-            @Override
-            public InternetAddress apply(MailAddress input) {
-                return input.toInternetAddress();
-            }
-        }).toArray(InternetAddress.class);
+        return FluentIterable.from(recipients)
+            .transform(MailAddress::toInternetAddress)
+            .toArray(InternetAddress.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
index 89e1d4a..ca80c44 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/MailAddressUtils.java
@@ -26,7 +26,6 @@ import javax.mail.internet.InternetAddress;
 import org.apache.james.transport.mailets.redirect.SpecialAddress;
 import org.apache.mailet.MailAddress;
 
-import com.google.common.base.Function;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 
@@ -56,13 +55,7 @@ public class MailAddressUtils {
 
     private static FluentIterable<InternetAddress> iterableOfInternetAddress(List<MailAddress> mailAddresses) {
         return FluentIterable.from(mailAddresses)
-            .transform(new Function<MailAddress, InternetAddress>() {
-
-                @Override
-                public InternetAddress apply(MailAddress mailAddress) {
-                    return mailAddress.toInternetAddress();
-                }
-            });
+            .transform(MailAddress::toInternetAddress);
     }
 
     public static boolean isUnalteredOrReversePathOrSender(MailAddress mailAddress) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnableTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnableTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnableTest.java
index 09554e1..e056ef1 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnableTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/DeliveryRunnableTest.java
@@ -51,12 +51,7 @@ public class DeliveryRunnableTest {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DeliveryRunnableTest.class);
     public static final Date FIXED_DATE = new Date(1159599194961L);
-    public static final Supplier<Date> FIXED_DATE_SUPPLIER = new Supplier<Date>() {
-        @Override
-        public Date get() {
-            return FIXED_DATE;
-        }
-    };
+    public static final Supplier<Date> FIXED_DATE_SUPPLIER = () -> FIXED_DATE;
 
     @Rule
     public ExpectedException expectedException = ExpectedException.none();

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryRunningTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryRunningTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryRunningTest.java
index 5c6abf7..54b0ee0 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryRunningTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/remoteDelivery/RemoteDeliveryRunningTest.java
@@ -36,8 +36,6 @@ import org.apache.mailet.base.test.FakeMailetConfig;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 public class RemoteDeliveryRunningTest {
 
@@ -59,13 +57,10 @@ public class RemoteDeliveryRunningTest {
 
     @Test
     public void remoteDeliveryShouldStart() throws Exception {
-        when(mailQueue.deQueue()).thenAnswer(new Answer<MailQueue.MailQueueItem>() {
-            @Override
-            public MailQueue.MailQueueItem answer(InvocationOnMock invocation) throws Throwable {
-                countDownLatch.countDown();
-                Thread.sleep(TimeUnit.SECONDS.toMillis(20));
-                return null;
-            }
+        when(mailQueue.deQueue()).thenAnswer(invocation -> {
+            countDownLatch.countDown();
+            Thread.sleep(TimeUnit.SECONDS.toMillis(20));
+            return null;
         });
         remoteDelivery.init(FakeMailetConfig.builder()
             .setProperty(RemoteDeliveryConfiguration.DELIVERY_THREADS, "1")

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index 9f7ab70..d19bb2f 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -69,7 +69,7 @@ public class CassandraStepdefs {
 
     @After
     public void tearDown() {
-        ignoreFailures(() -> mainStepdefs.tearDown(),
+        ignoreFailures(mainStepdefs::tearDown,
                 () -> embeddedElasticSearch.after(),
                 () -> temporaryFolder.delete());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
index 97dbc64..1024bec 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
@@ -159,7 +159,7 @@ public class GetMessagesMethodStepdefs {
 
     private String serialize(Optional<Map<String,String>> headers) {
         return headers
-                .map(map -> map.entrySet())
+                .map(Map::entrySet)
                 .map(entriesToString())
                 .orElse("");
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/JWTAuthenticationStrategy.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JWTAuthenticationStrategy.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JWTAuthenticationStrategy.java
index 9f4f609..2e155df 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JWTAuthenticationStrategy.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JWTAuthenticationStrategy.java
@@ -69,7 +69,7 @@ public class JWTAuthenticationStrategy implements AuthenticationStrategy {
 
         return mailboxSessionStream
                 .findFirst()
-                .orElseThrow(() -> new NoValidAuthHeaderException());
+                .orElseThrow(NoValidAuthHeaderException::new);
     }
 
     private Stream<String> extractTokensFromAuthHeaders(Stream<String> authHeaders) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/QueryParameterAccessTokenAuthenticationStrategy.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/QueryParameterAccessTokenAuthenticationStrategy.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/QueryParameterAccessTokenAuthenticationStrategy.java
index 498ba91..6101834 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/QueryParameterAccessTokenAuthenticationStrategy.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/QueryParameterAccessTokenAuthenticationStrategy.java
@@ -59,7 +59,7 @@ public class QueryParameterAccessTokenAuthenticationStrategy implements Authenti
             .filter(tokenManager::isValid)
             .map(AttachmentAccessToken::getUsername)
             .map(this::createSystemSession)
-            .orElseThrow(() -> new UnauthorizedException());
+            .orElseThrow(UnauthorizedException::new);
     }
 
     private MailboxSession createSystemSession(String username) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
index 2aba067..2ec52b3 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java
@@ -21,6 +21,7 @@ package org.apache.james.jmap.mailet;
 
 import java.time.ZonedDateTime;
 import java.util.concurrent.CompletableFuture;
+import java.util.function.Function;
 
 import javax.inject.Inject;
 import javax.mail.MessagingException;
@@ -40,8 +41,6 @@ import org.apache.mailet.base.GenericMailet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Functions;
-
 public class VacationMailet extends GenericMailet {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(VacationMailet.class);
@@ -88,7 +87,7 @@ public class VacationMailet extends GenericMailet {
                     RecipientId.fromMailAddress(processedMail.getSender())),
                 (vacation, alreadySent) ->
                     sendNotificationIfRequired(recipient, processedMail, processingDate, vacation, alreadySent))
-            .thenCompose(f -> f);
+            .thenCompose(Function.identity());
     }
 
     private CompletableFuture<Void> sendNotificationIfRequired(MailAddress recipient, Mail processedMail, ZonedDateTime processingDate, Vacation vacation, Boolean alreadySent) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
index 5f595c4..b88f282 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
@@ -77,7 +77,7 @@ public class SetMailboxesCreationProcessor implements SetMailboxesProcessor {
         this.metricFactory = metricFactory;
         this.sortingHierarchicalCollections =
             new SortingHierarchicalCollections<>(
-                x -> x.getKey(),
+                Map.Entry::getKey,
                 x -> x.getValue().getParentId());
         this.mailboxFactory = mailboxFactory;
         this.mailboxIdFactory = mailboxIdFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
index 434e19e..34bd029 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
@@ -249,7 +249,7 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
     
     private boolean isAppendToMailboxWithRole(Role role, CreationMessage entry, MailboxSession mailboxSession) throws MailboxException {
         return getMailboxWithRole(mailboxSession, role)
-                .map(box -> entry.isIn(box))
+                .map(entry::isIn)
                 .orElse(false);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
index 53d58d4..c303359 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesUpdateProcessor.java
@@ -132,7 +132,7 @@ public class SetMessagesUpdateProcessor implements SetMessagesProcessor {
         if (serializedMailboxIds.isPresent()) {
             List<MailboxId> mailboxIds = serializedMailboxIds.get()
                 .stream()
-                .map(mailboxId -> mailboxIdFactory.fromString(mailboxId))
+                .map(mailboxIdFactory::fromString)
                 .collect(Guavate.toImmutableList());
 
             messageIdManager.setInMailboxes(messageId, mailboxIds, mailboxSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/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 d3f095b..f53fe5f 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
@@ -71,7 +71,7 @@ public class MessageProperties {
     }
 
     private ImmutableSet<MessageProperty> buildOutputMessageProperties() {
-        return this.messageProperties.orElseGet(() -> MessageProperty.allOutputProperties());
+        return this.messageProperties.orElseGet(MessageProperty::allOutputProperties);
     }
 
     private MessageProperties usingProperties(Sets.SetView<MessageProperty> properties) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
index 7a36140..cc10186 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
@@ -67,6 +67,7 @@ import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.metrics.api.NoopMetricFactory;
+import org.apache.james.util.OptionalConverter;
 import org.apache.james.util.mime.MessageContentExtractor;
 import org.apache.mailet.Mail;
 import org.junit.Before;
@@ -304,9 +305,9 @@ public class SetMessagesCreationProcessorTest {
         @Override
         public Stream<MessageManager> getMailboxByRole(Role aRole, MailboxSession session) {
             if (aRole.equals(Role.OUTBOX)) {
-                return outboxSupplier.get().map(o -> Stream.of(o)).orElse(Stream.empty());
+                return OptionalConverter.toStream(outboxSupplier.get());
             } else if (aRole.equals(Role.DRAFTS)) {
-                return draftsSupplier.get().map(d -> Stream.of(d)).orElse(Stream.empty());
+                return OptionalConverter.toStream(draftsSupplier.get());
             }
             return Stream.empty();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterOperatorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterOperatorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterOperatorTest.java
index f7646bb..4862137 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterOperatorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterOperatorTest.java
@@ -61,7 +61,7 @@ public class FilterOperatorTest {
 
     @Test
     public void andFactoryMethodShouldThrowWhenNoArgument() {
-        assertThatThrownBy(() -> FilterOperator.and()).isInstanceOf(IllegalArgumentException.class);
+        assertThatThrownBy(FilterOperator::and).isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
@@ -74,7 +74,7 @@ public class FilterOperatorTest {
 
     @Test
     public void orFactoryMethodShouldThrowWhenNoArgument() {
-        assertThatThrownBy(() -> FilterOperator.or()).isInstanceOf(IllegalArgumentException.class);
+        assertThatThrownBy(FilterOperator::or).isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
@@ -87,7 +87,7 @@ public class FilterOperatorTest {
 
     @Test
     public void notFactoryMethodShouldThrowWhenNoArgument() {
-        assertThatThrownBy(() -> FilterOperator.not()).isInstanceOf(IllegalArgumentException.class);
+        assertThatThrownBy(FilterOperator::not).isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
index aa95a73..d6edfbd 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
@@ -28,7 +28,6 @@ import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueue.MailQueueException;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
-import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;
@@ -43,13 +42,7 @@ public class MailSpoolTest {
     public void setup() {
         myQueue = new MyQueue();
 
-        mailSpool = new MailSpool(new MailQueueFactory() {
-
-            @Override
-            public MailQueue getQueue(String name) {
-                return myQueue;
-            }
-        });
+        mailSpool = new MailSpool(name -> myQueue);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
index feb4b66..a48dc79 100644
--- a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
+++ b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
@@ -62,6 +62,6 @@ public class PublicKeyProviderTest {
 
         PublicKeyProvider sut = new PublicKeyProvider(configWithPEMKey, new PublicKeyReader());
 
-        assertThatThrownBy(() -> sut.get()).isExactlyInstanceOf(MissingOrInvalidKeyException.class);
+        assertThatThrownBy(sut::get).isExactlyInstanceOf(MissingOrInvalidKeyException.class);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
index 46501c9..a91e1ab 100644
--- a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
+++ b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
@@ -50,7 +50,6 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
@@ -728,23 +727,20 @@ public class POP3ServerTest {
         MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
         MessageParser messageParser = new MessageParser();
-        mailboxManager = new StoreMailboxManager(factory, new Authenticator() {
-    
-            @Override
-            public boolean isAuthentic(String userid, CharSequence passwd) {
-                try {
-                    return usersRepository.test(userid, passwd.toString());
-                } catch (UsersRepositoryException e) {
-                    e.printStackTrace();
-                    return false;
-                }
-            }
-        }, new Authorizator() {
-            @Override
-            public AuthorizationState canLoginAsOtherUser(String userId, String otherUserId) {
-                return AuthorizationState.NOT_ADMIN;
+        mailboxManager = new StoreMailboxManager(factory, (userid, passwd) -> {
+            try {
+                return usersRepository.test(userid, passwd.toString());
+            } catch (UsersRepositoryException e) {
+                e.printStackTrace();
+                return false;
             }
-        }, aclResolver, groupMembershipResolver, messageParser, new DefaultMessageId.Factory(), MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX, MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE);
+        }, (userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
+            aclResolver,
+            groupMembershipResolver,
+            messageParser,
+            new DefaultMessageId.Factory(),
+            MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
+            MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE);
         mailboxManager.init();
 
         protocolHandlerChain.put("mailboxmanager", MailboxManager.class, mailboxManager);

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
index 4ff7d13..3551fbb 100644
--- a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
+++ b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
@@ -27,6 +27,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+
 import javax.mail.MessagingException;
 
 import org.apache.commons.io.IOUtils;
@@ -108,16 +109,12 @@ public class MockMailQueue implements MailQueue {
             throw new MailQueueException("Mock");
         }
 
-        scheduler.schedule(new Runnable() {
-
-            @Override
-            public void run() {
-                try {
-                    queue.put(MockMailQueue.this.cloneMail(mail));
-                } catch (InterruptedException e) {
-                    log.error("", e);
-                    throw new RuntimeException("Mock", e);
-                }
+        scheduler.schedule(() -> {
+            try {
+                queue.put(MockMailQueue.this.cloneMail(mail));
+            } catch (InterruptedException e) {
+                log.error("", e);
+                throw new RuntimeException("Mock", e);
             }
         }, delay, unit);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java b/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
index 50886ca..f5fd47c 100644
--- a/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
+++ b/server/queue/queue-file/src/main/java/org/apache/james/queue/file/FileMailQueue.java
@@ -22,7 +22,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -91,12 +90,7 @@ public class FileMailQueue implements ManageableMailQueue {
             File qDir = new File(queueDir, Integer.toString(i));
             FileUtils.forceMkdir(qDir);
 
-            String[] files = qDir.list(new FilenameFilter() {
-                @Override
-                public boolean accept(File dir, String name) {
-                    return name.endsWith(OBJECT_EXTENSION);
-                }
-            });
+            String[] files = qDir.list((dir, name) -> name.endsWith(OBJECT_EXTENSION));
 
             for (String name : files) {
 
@@ -129,16 +123,12 @@ public class FileMailQueue implements ManageableMailQueue {
 
                         // Schedule a task which will put the mail in the queue
                         // for processing after a given delay
-                        scheduler.schedule(new Runnable() {
-
-                            @Override
-                            public void run() {
-                                try {
-                                    inmemoryQueue.put(key);
-                                } catch (InterruptedException e) {
-                                    Thread.currentThread().interrupt();
-                                    throw new RuntimeException("Unable to init", e);
-                                }
+                        scheduler.schedule(() -> {
+                            try {
+                                inmemoryQueue.put(key);
+                            } catch (InterruptedException e) {
+                                Thread.currentThread().interrupt();
+                                throw new RuntimeException("Unable to init", e);
                             }
                         }, next - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
                     }
@@ -192,17 +182,13 @@ public class FileMailQueue implements ManageableMailQueue {
 
             if (delay > 0) {
                 // The message should get delayed so schedule it for later
-                scheduler.schedule(new Runnable() {
-
-                    @Override
-                    public void run() {
-                        try {
-                            inmemoryQueue.put(key);
+                scheduler.schedule(() -> {
+                    try {
+                        inmemoryQueue.put(key);
 
-                        } catch (InterruptedException e) {
-                            Thread.currentThread().interrupt();
-                            throw new RuntimeException("Unable to init", e);
-                        }
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                        throw new RuntimeException("Unable to init", e);
                     }
                 }, delay, unit);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/855a3c87/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
index 1e8b0c5..2682014 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/AbstractJMSMailQueueTest.java
@@ -167,19 +167,15 @@ public abstract class AbstractJMSMailQueueTest {
 
         assertEquals(1, queue.getSize());
 
-        Thread flushThread = new Thread(new Runnable() {
-
-            @Override
-            public void run() {
-                try {
-                    // wait for 2 seconds then flush the queue
-                    TimeUnit.MILLISECONDS.sleep(4000);
-                    assertEquals(1, queue.flush());
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-
+        Thread flushThread = new Thread(() -> {
+            try {
+                // wait for 2 seconds then flush the queue
+                TimeUnit.MILLISECONDS.sleep(4000);
+                assertEquals(1, queue.flush());
+            } catch (Exception e) {
+                throw new RuntimeException(e);
             }
+
         });
         flushThread.start();
 


---------------------------------------------------------------------
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