001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    package org.apache.geronimo.gbean;
019    
020    import java.io.Serializable;
021    import java.util.ArrayList;
022    import java.util.Arrays;
023    import java.util.Collections;
024    import java.util.List;
025    
026    /**
027     * Describes an operation on a GBean.
028     *
029     * @version $Rev: 558235 $ $Date: 2007-07-20 23:47:45 -0400 (Fri, 20 Jul 2007) $
030     */
031    public class GOperationInfo implements Serializable {
032        private static final long serialVersionUID = -5593225815559931812L;
033        /**
034         * The name of this method.
035         */
036        private final String name;
037        
038        /**
039         * The return type of this method.
040         */
041        private final String returnType;
042        
043        /**
044         * Parameters of this method.
045         */
046        private final List parameters;
047    
048        /**
049         * Target method name.
050         */
051        private final String methodName;
052    
053        public GOperationInfo(String name, String type) {
054            this(name, name, Collections.EMPTY_LIST, type);
055        }
056    
057        public GOperationInfo(String name, Class[] paramTypes, String returnType) {
058            this.name = this.methodName = name;
059            this.returnType = returnType;
060            String[] args = new String[paramTypes.length];
061            for (int i = 0; i < args.length; i++) {
062                args[i] = paramTypes[i].getName();
063            }
064            this.parameters = Collections.unmodifiableList(Arrays.asList(args));
065        }
066    
067        public GOperationInfo(String name, String[] paramTypes, String returnType) {
068            this(name, name, Arrays.asList(paramTypes), returnType);
069        }
070        
071        public GOperationInfo(String name, List parameters, String returnType) {
072            this(name, name, parameters, returnType);
073        }
074        
075        public GOperationInfo(String name, String methodName, List parameters, String returnType) {
076            this.name = name;
077            this.returnType = returnType;
078            this.methodName = methodName;
079            this.parameters = Collections.unmodifiableList(new ArrayList(parameters));
080        }
081    
082        public String getName() {
083            return name;
084        }
085        
086        public String getReturnType() {
087            return returnType;
088        }
089    
090        public String getMethodName() {
091            return methodName;
092        }
093    
094        public List getParameterList() {
095            return parameters;
096        }
097    
098        public String toString() {
099            return "[GOperationInfo: name=" + name + " parameters=" + parameters + " returnType =" + returnType + "]";
100        }
101    }