.class Lcom/google/common/eventbus/AnnotatedSubscriberFinder; .super Ljava/lang/Object; .source "AnnotatedSubscriberFinder.java" # interfaces .implements Lcom/google/common/eventbus/SubscriberFindingStrategy; # annotations .annotation system Ldalvik/annotation/MemberClasses; value = { Lcom/google/common/eventbus/AnnotatedSubscriberFinder$MethodIdentifier; } .end annotation # static fields .field private static final subscriberMethodsCache:Lcom/google/common/cache/LoadingCache; .annotation system Ldalvik/annotation/Signature; value = { "Lcom/google/common/cache/LoadingCache", "<", "Ljava/lang/Class", "<*>;", "Lcom/google/common/collect/ImmutableList", "<", "Ljava/lang/reflect/Method;", ">;>;" } .end annotation .end field # direct methods .method static constructor ()V .locals 2 .prologue .line 53 invoke-static {}, Lcom/google/common/cache/CacheBuilder;->newBuilder()Lcom/google/common/cache/CacheBuilder; move-result-object v0 invoke-virtual {v0}, Lcom/google/common/cache/CacheBuilder;->weakKeys()Lcom/google/common/cache/CacheBuilder; move-result-object v0 new-instance v1, Lcom/google/common/eventbus/AnnotatedSubscriberFinder$1; invoke-direct {v1}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder$1;->()V invoke-virtual {v0, v1}, Lcom/google/common/cache/CacheBuilder;->build(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache; move-result-object v0 sput-object v0, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->subscriberMethodsCache:Lcom/google/common/cache/LoadingCache; return-void .end method .method constructor ()V .locals 0 .prologue .line 46 invoke-direct {p0}, Ljava/lang/Object;->()V .line 89 return-void .end method .method static synthetic access$000(Ljava/lang/Class;)Lcom/google/common/collect/ImmutableList; .locals 1 .prologue .line 46 invoke-static {p0}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->getAnnotatedMethodsInternal(Ljava/lang/Class;)Lcom/google/common/collect/ImmutableList; move-result-object v0 return-object v0 .end method .method private static getAnnotatedMethods(Ljava/lang/Class;)Lcom/google/common/collect/ImmutableList; .locals 1 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/lang/Class", "<*>;)", "Lcom/google/common/collect/ImmutableList", "<", "Ljava/lang/reflect/Method;", ">;" } .end annotation .prologue .line 83 :try_start_0 sget-object v0, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->subscriberMethodsCache:Lcom/google/common/cache/LoadingCache; invoke-interface {v0, p0}, Lcom/google/common/cache/LoadingCache;->getUnchecked(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Lcom/google/common/collect/ImmutableList; :try_end_0 .catch Lcom/google/common/util/concurrent/UncheckedExecutionException; {:try_start_0 .. :try_end_0} :catch_0 return-object v0 .line 84 :catch_0 move-exception v0 .line 85 invoke-virtual {v0}, Lcom/google/common/util/concurrent/UncheckedExecutionException;->getCause()Ljava/lang/Throwable; move-result-object v0 invoke-static {v0}, Lcom/google/common/base/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException; move-result-object v0 throw v0 .end method .method private static getAnnotatedMethodsInternal(Ljava/lang/Class;)Lcom/google/common/collect/ImmutableList; .locals 9 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/lang/Class", "<*>;)", "Lcom/google/common/collect/ImmutableList", "<", "Ljava/lang/reflect/Method;", ">;" } .end annotation .prologue .line 114 invoke-static {p0}, Lcom/google/common/reflect/TypeToken;->of(Ljava/lang/Class;)Lcom/google/common/reflect/TypeToken; move-result-object v0 invoke-virtual {v0}, Lcom/google/common/reflect/TypeToken;->getTypes()Lcom/google/common/reflect/TypeToken$TypeSet; move-result-object v0 invoke-virtual {v0}, Lcom/google/common/reflect/TypeToken$TypeSet;->rawTypes()Ljava/util/Set; move-result-object v0 .line 115 invoke-static {}, Lcom/google/common/collect/Maps;->newHashMap()Ljava/util/HashMap; move-result-object v1 .line 116 invoke-interface {v0}, Ljava/util/Set;->iterator()Ljava/util/Iterator; move-result-object v2 :cond_0 invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z move-result v0 if-eqz v0, :cond_3 invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/lang/Class; .line 117 invoke-virtual {v0}, Ljava/lang/Class;->getMethods()[Ljava/lang/reflect/Method; move-result-object v3 array-length v4, v3 const/4 v0, 0x0 :goto_0 if-ge v0, v4, :cond_0 aget-object v5, v3, v0 .line 118 const-class v6, Lcom/google/common/eventbus/Subscribe; invoke-virtual {v5, v6}, Ljava/lang/reflect/Method;->isAnnotationPresent(Ljava/lang/Class;)Z move-result v6 if-eqz v6, :cond_2 .line 119 invoke-virtual {v5}, Ljava/lang/reflect/Method;->getParameterTypes()[Ljava/lang/Class; move-result-object v6 .line 120 array-length v7, v6 const/4 v8, 0x1 if-eq v7, v8, :cond_1 .line 121 new-instance v0, Ljava/lang/IllegalArgumentException; new-instance v1, Ljava/lang/StringBuilder; invoke-direct {v1}, Ljava/lang/StringBuilder;->()V const-string v2, "Method " invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v1 invoke-virtual {v1, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; move-result-object v1 const-string v2, " has @Subscribe annotation, but requires " invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v1 array-length v2, v6 invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder; move-result-object v1 const-string v2, " arguments. Event subscriber methods must require a single argument." invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v1 invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v1 invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;->(Ljava/lang/String;)V throw v0 .line 126 :cond_1 new-instance v6, Lcom/google/common/eventbus/AnnotatedSubscriberFinder$MethodIdentifier; invoke-direct {v6, v5}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder$MethodIdentifier;->(Ljava/lang/reflect/Method;)V .line 127 invoke-interface {v1, v6}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z move-result v7 if-nez v7, :cond_2 .line 128 invoke-interface {v1, v6, v5}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; .line 117 :cond_2 add-int/lit8 v0, v0, 0x1 goto :goto_0 .line 133 :cond_3 invoke-interface {v1}, Ljava/util/Map;->values()Ljava/util/Collection; move-result-object v0 invoke-static {v0}, Lcom/google/common/collect/ImmutableList;->copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList; move-result-object v0 return-object v0 .end method .method private static makeSubscriber(Ljava/lang/Object;Ljava/lang/reflect/Method;)Lcom/google/common/eventbus/EventSubscriber; .locals 1 .prologue .line 149 invoke-static {p1}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->methodIsDeclaredThreadSafe(Ljava/lang/reflect/Method;)Z move-result v0 if-eqz v0, :cond_0 .line 150 new-instance v0, Lcom/google/common/eventbus/EventSubscriber; invoke-direct {v0, p0, p1}, Lcom/google/common/eventbus/EventSubscriber;->(Ljava/lang/Object;Ljava/lang/reflect/Method;)V .line 154 :goto_0 return-object v0 .line 152 :cond_0 new-instance v0, Lcom/google/common/eventbus/SynchronizedEventSubscriber; invoke-direct {v0, p0, p1}, Lcom/google/common/eventbus/SynchronizedEventSubscriber;->(Ljava/lang/Object;Ljava/lang/reflect/Method;)V goto :goto_0 .end method .method private static methodIsDeclaredThreadSafe(Ljava/lang/reflect/Method;)Z .locals 1 .prologue .line 166 const-class v0, Lcom/google/common/eventbus/AllowConcurrentEvents; invoke-virtual {p0, v0}, Ljava/lang/reflect/Method;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation; move-result-object v0 if-eqz v0, :cond_0 const/4 v0, 0x1 :goto_0 return v0 :cond_0 const/4 v0, 0x0 goto :goto_0 .end method # virtual methods .method public findAllSubscribers(Ljava/lang/Object;)Lcom/google/common/collect/Multimap; .locals 5 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/lang/Object;", ")", "Lcom/google/common/collect/Multimap", "<", "Ljava/lang/Class", "<*>;", "Lcom/google/common/eventbus/EventSubscriber;", ">;" } .end annotation .prologue .line 70 invoke-static {}, Lcom/google/common/collect/HashMultimap;->create()Lcom/google/common/collect/HashMultimap; move-result-object v1 .line 71 invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class; move-result-object v0 .line 72 invoke-static {v0}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->getAnnotatedMethods(Ljava/lang/Class;)Lcom/google/common/collect/ImmutableList; move-result-object v0 invoke-virtual {v0}, Lcom/google/common/collect/ImmutableList;->iterator()Ljava/util/Iterator; move-result-object v2 :goto_0 invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z move-result v0 if-eqz v0, :cond_0 invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/lang/reflect/Method; .line 73 invoke-virtual {v0}, Ljava/lang/reflect/Method;->getParameterTypes()[Ljava/lang/Class; move-result-object v3 .line 74 const/4 v4, 0x0 aget-object v3, v3, v4 .line 75 invoke-static {p1, v0}, Lcom/google/common/eventbus/AnnotatedSubscriberFinder;->makeSubscriber(Ljava/lang/Object;Ljava/lang/reflect/Method;)Lcom/google/common/eventbus/EventSubscriber; move-result-object v0 .line 76 invoke-interface {v1, v3, v0}, Lcom/google/common/collect/Multimap;->put(Ljava/lang/Object;Ljava/lang/Object;)Z goto :goto_0 .line 78 :cond_0 return-object v1 .end method