View Javadoc
1   /*
2    * Copyright (C) 2012-2024 RRiBbit.org
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    * https://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  package org.rribbit.creation;
17  
18  import java.util.Collection;
19  
20  import org.rribbit.Listener;
21  import org.rribbit.ListenerObject;
22  import org.rribbit.creation.notification.ListenerObjectCreationObserver;
23  import org.rribbit.retrieval.ListenerObjectRetriever;
24  
25  /**
26   * A {@link ListenerObjectCreator} creates the {@link ListenerObject}s that will be used by the {@link ListenerObjectRetriever} to search in.
27   * <p />
28   * Implementors are required to keep a list of {@link ListenerObjectCreationObserver}s and notify them whenever a class is scanned and its listeners are created.
29   *
30   * @author G.J. Schouten
31   *
32   */
33  public interface ListenerObjectCreator {
34  
35  	/**
36  	 * Get {@link ListenerObject}s from methods that have registered themselves as a {@link Listener}. Implementations are responsible for keeping a local copy of this {@link Collection}
37  	 * instead of recreating it everytime this method is called.
38  	 *
39  	 * @return a {@link Collection} of {@link ListenerObject} from methods that have registered themselves as a {@link Listener} or an empty {@link Collection} if there are no such methods
40  	 */
41  	Collection<ListenerObject> getListenerObjects();
42  
43  	/**
44  	 * Adds a {@link ListenerObjectCreationObserver} to the list of {@link ListenerObjectCreationObserver}s to be notified when a class is scanned and its listeners created.
45  	 *
46  	 * @param listenerObjectCreationObserver
47  	 */
48  	void registerObserver(ListenerObjectCreationObserver listenerObjectCreationObserver);
49  }