001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *        http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 */
019
020package org.apache.isis.core.metamodel.specloader.traverser;
021
022import java.lang.reflect.Method;
023import java.lang.reflect.Type;
024
025/**
026 * Helper that finds all parameter types (including generic types) for the
027 * provided {@link Method}.
028 * 
029 * <p>
030 * For example,
031 * 
032 * <pre>
033 * public class CustomerRepository {
034 *     public void filterCustomers(List&lt;Customer&gt; customerList) { ... }
035 * }
036 * </pre>
037 * <p>
038 * will find both <tt>List</tt> and <tt>Customer</tt>.
039 */
040public class TypeExtractorMethodParameters extends TypeExtractorAbstract {
041
042    private final Class<?>[] parameterTypes;
043
044    public TypeExtractorMethodParameters(final Method method) {
045        super(method);
046
047        parameterTypes = getMethod().getParameterTypes();
048        for (final Class<?> parameterType : parameterTypes) {
049            add(parameterType);
050        }
051
052        final Type[] genericTypes = getMethod().getGenericParameterTypes();
053        addParameterizedTypes(genericTypes);
054    }
055
056    public Class<?>[] getParameterTypes() {
057        return parameterTypes;
058    }
059
060}