1/*
2 * Copyright 2003,2004 The Apache Software Foundation
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 */
16package org.mockito.cglib.proxy;
17
18import java.lang.reflect.Method;
19import java.util.List;
20
21/**
22 * Map methods of subclasses generated by {@link Enhancer} to a particular
23 * callback. The type of the callbacks chosen for each method affects
24 * the bytecode generated for that method in the subclass, and cannot
25 * change for the life of the class.
26 */
27public interface CallbackFilter {
28    /**
29     * Map a method to a callback.
30     *
31     * @param method the intercepted method
32     * @param allMethods all the methods found on the instance. Don't mess with the contents of this list!!!
33     * @return the index into the array of callbacks (as specified by {@link Enhancer#setCallbacks}) to use for the method,
34     */
35    int accept(Method method, List<Method> allMethods);
36
37    /**
38     * The <code>CallbackFilter</code> in use affects which cached class
39     * the <code>Enhancer</code> will use, so this is a reminder that
40     * you should correctly implement <code>equals</code> and
41     * <code>hashCode</code> for custom <code>CallbackFilter</code>
42     * implementations in order to improve performance.
43    */
44    boolean equals(Object o);
45}
46