HandlerFindingStrategy.java revision 1d580d0f6ee4f21eb309ba7b509d2c6d671c4044
1/*
2 * Copyright (C) 2007 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.common.eventbus;
18
19import com.google.common.collect.Multimap;
20
21/**
22 * A method for finding event handler methods in objects, for use by
23 * {@link EventBus}.
24 *
25 * @author Cliff Biffle
26 */
27interface HandlerFindingStrategy {
28
29  /**
30   * Finds all suitable event handler methods in {@code source}, organizes them
31   * by the type of event they handle, and wraps them in {@link EventHandler}s.
32   *
33   * @param source  object whose handlers are desired.
34   * @return EventHandler objects for each handler method, organized by event
35   *         type.
36   *
37   * @throws IllegalArgumentException if {@code source} is not appropriate for
38   *         this strategy (in ways that this interface does not define).
39   */
40  Multimap<Class<?>, EventHandler> findAllHandlers(Object source);
41
42}
43