1/*
2 * Copyright 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.lang.reflect.Modifier;
20import java.util.*;
21
22import org.mockito.asm.ClassVisitor;
23import org.mockito.cglib.core.CollectionUtils;
24import org.mockito.cglib.core.ReflectUtils;
25import org.mockito.cglib.core.RejectModifierPredicate;
26
27/**
28 * @author Chris Nokleberg
29 * @version $Id: MixinEverythingEmitter.java,v 1.3 2004/06/24 21:15:19 herbyderby Exp $
30 */
31class MixinEverythingEmitter extends MixinEmitter {
32
33    public MixinEverythingEmitter(ClassVisitor v, String className, Class[] classes) {
34        super(v, className, classes, null);
35    }
36
37    protected Class[] getInterfaces(Class[] classes) {
38        List list = new ArrayList();
39        for (int i = 0; i < classes.length; i++) {
40            ReflectUtils.addAllInterfaces(classes[i], list);
41        }
42        return (Class[])list.toArray(new Class[list.size()]);
43    }
44
45    protected Method[] getMethods(Class type) {
46        List methods = new ArrayList(Arrays.asList(type.getMethods()));
47        CollectionUtils.filter(methods, new RejectModifierPredicate(Modifier.FINAL | Modifier.STATIC));
48        return (Method[])methods.toArray(new Method[methods.size()]);
49    }
50}
51