From 4c7d959c3e944963436705340eccf4b82cde7e47 Mon Sep 17 00:00:00 2001 From: zachh Date: Fri, 10 Nov 2017 16:29:49 -0800 Subject: Use lambdas in CompositePhoneLookup. They should work now that we target guava 20 instead of 18 in AOSP. Test: tap PiperOrigin-RevId: 175354039 Change-Id: Id7844c3a1c8e29e5ecb13fa36a92dd80be0cfc7c --- .../composite/CompositePhoneLookup.java | 49 +++++++++------------- 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java index f85b357e7..59a845774 100644 --- a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java +++ b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java @@ -23,7 +23,6 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerFutures; import com.android.dialer.phonelookup.PhoneLookup; import com.android.dialer.phonelookup.PhoneLookupInfo; -import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -60,15 +59,12 @@ public final class CompositePhoneLookup implements PhoneLookup { } return Futures.transform( Futures.allAsList(futures), - new Function, PhoneLookupInfo>() { - @Override - public PhoneLookupInfo apply(List infos) { - PhoneLookupInfo.Builder mergedInfo = PhoneLookupInfo.newBuilder(); - for (PhoneLookupInfo info : infos) { - mergedInfo.mergeFrom(info); - } - return mergedInfo.build(); + infos -> { + PhoneLookupInfo.Builder mergedInfo = PhoneLookupInfo.newBuilder(); + for (PhoneLookupInfo info : infos) { + mergedInfo.mergeFrom(info); } + return mergedInfo.build(); }, MoreExecutors.directExecutor()); } @@ -102,30 +98,23 @@ public final class CompositePhoneLookup implements PhoneLookup { } return Futures.transform( Futures.allAsList(futures), - new Function< - List>, - ImmutableMap>() { - @Override - public ImmutableMap apply( - List> allMaps) { - ImmutableMap.Builder combinedMap = - ImmutableMap.builder(); - for (DialerPhoneNumber dialerPhoneNumber : existingInfoMap.keySet()) { - PhoneLookupInfo.Builder combinedInfo = PhoneLookupInfo.newBuilder(); - for (ImmutableMap map : allMaps) { - PhoneLookupInfo subInfo = map.get(dialerPhoneNumber); - if (subInfo == null) { - throw new IllegalStateException( - "A sublookup didn't return an info for number: " - + LogUtil.sanitizePhoneNumber( - dialerPhoneNumber.getRawInput().getNumber())); - } - combinedInfo.mergeFrom(subInfo); + (allMaps) -> { + ImmutableMap.Builder combinedMap = + ImmutableMap.builder(); + for (DialerPhoneNumber dialerPhoneNumber : existingInfoMap.keySet()) { + PhoneLookupInfo.Builder combinedInfo = PhoneLookupInfo.newBuilder(); + for (ImmutableMap map : allMaps) { + PhoneLookupInfo subInfo = map.get(dialerPhoneNumber); + if (subInfo == null) { + throw new IllegalStateException( + "A sublookup didn't return an info for number: " + + LogUtil.sanitizePhoneNumber(dialerPhoneNumber.getRawInput().getNumber())); } - combinedMap.put(dialerPhoneNumber, combinedInfo.build()); + combinedInfo.mergeFrom(subInfo); } - return combinedMap.build(); + combinedMap.put(dialerPhoneNumber, combinedInfo.build()); } + return combinedMap.build(); }, MoreExecutors.directExecutor()); } -- cgit v1.2.3