1 /* 2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.scenario.effect.compiler.model; 27 28 import java.util.Collections; 29 import java.util.List; 30 31 /** 32 */ 33 public class Function { 34 35 private final String name; 36 private final Type returnType; 37 private final List<Param> params; 38 39 Function(String name, Type returnType, List<Param> params) { 40 this.name = name; 41 this.returnType = returnType; 42 if (params != null) { 43 this.params = params; 44 } else { 45 this.params = Collections.emptyList(); 46 } 47 } 48 49 public String getName() { 50 return name; 51 } 52 53 public Type getReturnType() { 54 return returnType; 55 } 56 57 public List<Param> getParams() { 58 return params; 59 } 60 61 @Override 62 public boolean equals(Object obj) { 63 if (obj == null) { 64 return false; 65 } 66 if (getClass() != obj.getClass()) { 67 return false; 68 } 69 final Function other = (Function) obj; 70 if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) { 71 return false; 72 } 73 if (this.returnType != other.returnType) { 74 return false; 75 } 76 if (this.params != other.params && (this.params == null || !this.params.equals(other.params))) { 77 return false; 78 } 79 return true; 80 } 81 82 @Override 83 public int hashCode() { 84 int hash = 7; 85 hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); 86 hash = 71 * hash + (this.returnType != null ? this.returnType.hashCode() : 0); 87 hash = 71 * hash + (this.params != null ? this.params.hashCode() : 0); 88 return hash; 89 } 90 }