001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.mobility.e2e.classdata;
043:
044: import java.util.Collections;
045: import java.util.List;
046:
047: /**
048: *
049: * @author Michal Skvor
050: */
051: public class MethodData {
052:
053: private final String name, parentClassName;
054: private final ClassData returnType;
055: private final List<MethodParameter> parameters;
056:
057: private int requestID;
058:
059: public MethodData(String parentClassName, String name,
060: ClassData returnType, List<MethodParameter> parameters) {
061: this .name = name;
062: this .parentClassName = parentClassName;
063: this .returnType = returnType;
064: this .parameters = parameters;
065: }
066:
067: public String getName() {
068: return name;
069: }
070:
071: public String getParentClassName() {
072: return parentClassName;
073: }
074:
075: public ClassData getReturnType() {
076: return returnType;
077: }
078:
079: public List<MethodParameter> getParameters() {
080: return Collections.unmodifiableList(parameters);
081: }
082:
083: public void setRequestID(int requestID) {
084: this .requestID = requestID;
085: }
086:
087: public int getRequestID() {
088: return requestID;
089: }
090:
091: @Override
092: public boolean equals(Object o) {
093: if (!(o instanceof MethodData))
094: return false;
095: MethodData md = (MethodData) o;
096: if (!md.getParentClassName().equals(parentClassName))
097: return false;
098: if (!md.getName().equals(name))
099: return false;
100: if (!md.getReturnType().equals(returnType))
101: return false;
102: if (md.getParameters().size() != parameters.size())
103: return false;
104: for (int i = 0; i < parameters.size(); i++) {
105: if (!md.getParameters().get(i).equals(parameters.get(i)))
106: return false;
107: }
108: return true;
109: }
110:
111: @Override
112: public int hashCode() {
113: return parentClassName.hashCode() + name.hashCode()
114: + returnType.hashCode() + parameters.hashCode();
115: }
116: }
|