<commit_before>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.j2objc.types;

import org.eclipse.jdt.core.dom.ITypeBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * A binding type for functions.
 *
 * @author <NAME>
 */
public class FunctionBinding {

  private final String name;
  private final ITypeBinding returnType;
  private final ITypeBinding declaringClass;
  private List<ITypeBinding> parameterTypes = new ArrayList<>();
  private boolean isVarargs = false;

  public FunctionBinding(String name, ITypeBinding returnType, ITypeBinding declaringClass) {
    this.name = name;
    this.returnType = returnType;
    this.declaringClass = declaringClass;
  }

  public String getName() {
    return name;
  }

  public ITypeBinding getReturnType() {
    return returnType;
  }

  public ITypeBinding getDeclaringClass() {
    return declaringClass;
  }

  public List<ITypeBinding> getParameterTypes() {
    return parameterTypes;
  }

  public void addParameter(ITypeBinding paramType) {
    parameterTypes.add(paramType);
  }

  public void addParameters(ITypeBinding... paramTypes) {
    for (ITypeBinding paramType : paramTypes) {
      parameterTypes.add(paramType);
    }
  }

  public boolean isVarargs() {
    return isVarargs;
  }

  public void setIsVarargs(boolean value) {
    isVarargs = value;
  }

  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(returnType.getName() + " " + name + "(");
    for (int i = 0; i < parameterTypes.size(); i++) {
      if (i > 0) {
        sb.append(", ");
      }
      sb.append(parameterTypes.get(i).getName());
    }
    sb.append(")");
    return sb.toString();
  }
}<commit_msg>Adds .equals() and .hashCode() to FunctionBinding. 	Change on 2015/10/16 by kstanger <<EMAIL>> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=105625102<commit_after>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.devtools.j2objc.types;

import org.eclipse.jdt.core.dom.ITypeBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * A binding type for functions.
 *
 * @author <NAME>
 */
public class FunctionBinding {

  private final String name;
  private final ITypeBinding returnType;
  private final ITypeBinding declaringClass;
  private List<ITypeBinding> parameterTypes = new ArrayList<>();
  private boolean isVarargs = false;

  public FunctionBinding(String name, ITypeBinding returnType, ITypeBinding declaringClass) {
    this.name = name;
    this.returnType = returnType;
    this.declaringClass = declaringClass;
  }

  public String getName() {
    return name;
  }

  public ITypeBinding getReturnType() {
    return returnType;
  }

  public ITypeBinding getDeclaringClass() {
    return declaringClass;
  }

  public List<ITypeBinding> getParameterTypes() {
    return parameterTypes;
  }

  public void addParameter(ITypeBinding paramType) {
    parameterTypes.add(paramType);
  }

  public void addParameters(ITypeBinding... paramTypes) {
    for (ITypeBinding paramType : paramTypes) {
      parameterTypes.add(paramType);
    }
  }

  public boolean isVarargs() {
    return isVarargs;
  }

  public void setIsVarargs(boolean value) {
    isVarargs = value;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(returnType.getName() + " " + name + "(");
    for (int i = 0; i < parameterTypes.size(); i++) {
      if (i > 0) {
        sb.append(", ");
      }
      sb.append(parameterTypes.get(i).getName());
    }
    sb.append(")");
    return sb.toString();
  }

  @Override
  public boolean equals(Object other) {
    if (!(other instanceof FunctionBinding)) {
      return false;
    }
    // C functions can't be overloaded, so it is sufficient to compare the names.
    return ((FunctionBinding) other).getName().equals(name);
  }

  @Override
  public int hashCode() {
    return name.hashCode();
  }
}
{'fraction_non_alphanumeric': 0.10561122244488978, 'fraction_numerical': 0.006212424849699399, 'mean_word_length': 3.460232350312779, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819328', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1426, 'n_words': 450}