summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/phonelookup/PhoneLookup.java
diff options
context:
space:
mode:
authorzachh <zachh@google.com>2017-12-22 16:59:32 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-27 13:50:03 -0800
commite1ec439563705d47f699a565c35eff4bc0dcbf61 (patch)
treef77970b4b9e9682355828fc810f5271801775bfe /java/com/android/dialer/phonelookup/PhoneLookup.java
parent0e130eb65c12f52417c731e28330f96b8f71521d (diff)
Parameterized PhoneLookup with submessage type.
This allows indvidual PhoneLookups to define and deal mostly with their own submessage type (with the exception of trivial setter and getter methods for converting from/to PhoneLookupInfo). This also simplifies the FakePhoneLookup and tests which use it a bit, I think. Bug: 34672501 Test: unit PiperOrigin-RevId: 179976215 Change-Id: I2db1fc85771621be2f2afcd6af114d82680e30d0
Diffstat (limited to 'java/com/android/dialer/phonelookup/PhoneLookup.java')
-rw-r--r--java/com/android/dialer/phonelookup/PhoneLookup.java40
1 files changed, 23 insertions, 17 deletions
diff --git a/java/com/android/dialer/phonelookup/PhoneLookup.java b/java/com/android/dialer/phonelookup/PhoneLookup.java
index bb14c1ff6..859085e7b 100644
--- a/java/com/android/dialer/phonelookup/PhoneLookup.java
+++ b/java/com/android/dialer/phonelookup/PhoneLookup.java
@@ -27,19 +27,19 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides operations related to retrieving information about phone numbers.
*
* <p>Some operations defined by this interface are generally targeted towards specific use cases;
- * for example {@link #isDirty(ImmutableSet)}, {@link #getMostRecentPhoneLookupInfo(ImmutableMap)},
- * and {@link #onSuccessfulBulkUpdate()} are generally intended to be used by the call log.
+ * for example {@link #isDirty(ImmutableSet)}, {@link #getMostRecentInfo(ImmutableMap)}, and {@link
+ * #onSuccessfulBulkUpdate()} are generally intended to be used by the call log.
*/
-public interface PhoneLookup {
+public interface PhoneLookup<T> {
/**
- * Returns a future containing a new {@link PhoneLookupInfo} for the provided call.
+ * Returns a future containing a new info for the provided call.
*
* <p>The returned message should contain populated data for the sub-message corresponding to this
- * {@link PhoneLookup}. For example, the CP2 implementation returns a {@link PhoneLookupInfo} with
- * the {@link PhoneLookupInfo.Cp2Info} sub-message populated.
+ * {@link PhoneLookup}. For example, the CP2 implementation returns a {@link
+ * PhoneLookupInfo.Cp2Info} sub-message.
*/
- ListenableFuture<PhoneLookupInfo> lookup(@NonNull Call call);
+ ListenableFuture<T> lookup(@NonNull Call call);
/**
* Returns a future which returns true if the information for any of the provided phone numbers
@@ -56,24 +56,30 @@ public interface PhoneLookup {
* {@code existingInfoMap}.
*
* <p>If there is no longer information associated with a number (for example, a local contact was
- * deleted) the returned map should contain an empty {@link PhoneLookupInfo} for that number.
+ * deleted) the returned map should contain an empty info for that number.
*/
- ListenableFuture<ImmutableMap<DialerPhoneNumber, PhoneLookupInfo>> getMostRecentPhoneLookupInfo(
- ImmutableMap<DialerPhoneNumber, PhoneLookupInfo> existingInfoMap);
+ ListenableFuture<ImmutableMap<DialerPhoneNumber, T>> getMostRecentInfo(
+ ImmutableMap<DialerPhoneNumber, T> existingInfoMap);
/**
- * Populates the sub-message that this {@link PhoneLookup} is responsible for by copying the
- * sub-message value from {@code source} to {@code destination}
+ * Populates the sub-message that this {@link PhoneLookup} is responsible for by copying {@code
+ * subMessage} into the provided {@code phoneLookupInfo} builder.
*/
- void copySubMessage(PhoneLookupInfo.Builder destination, PhoneLookupInfo source);
+ void setSubMessage(PhoneLookupInfo.Builder phoneLookupInfo, T subMessage);
/**
- * Called when the results of the {@link #getMostRecentPhoneLookupInfo(ImmutableMap)} have been
- * applied by the caller.
+ * Gets the sub-message that this {@link PhoneLookup} is responsible for from the provided {@code
+ * phoneLookupInfo}.
+ */
+ T getSubMessage(PhoneLookupInfo phoneLookupInfo);
+
+ /**
+ * Called when the results of the {@link #getMostRecentInfo(ImmutableMap)} have been applied by
+ * the caller.
*
* <p>Typically implementations will use this to store a "last processed" timestamp so that future
- * invocations of {@link #isDirty(ImmutableSet)} and {@link
- * #getMostRecentPhoneLookupInfo(ImmutableMap)} can be efficiently implemented.
+ * invocations of {@link #isDirty(ImmutableSet)} and {@link #getMostRecentInfo(ImmutableMap)} can
+ * be efficiently implemented.
*/
ListenableFuture<Void> onSuccessfulBulkUpdate();
}