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, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.tool.coprocessor;
019
020import java.util.ArrayList;
021import java.util.List;
022import java.util.Objects;
023import org.apache.yetus.audience.InterfaceAudience;
024
025@InterfaceAudience.Private
026public class CoprocessorMethod {
027  private final String name;
028  private final List<String> parameters;
029
030  public CoprocessorMethod(String name) {
031    this.name = name;
032
033    parameters = new ArrayList<>();
034  }
035
036  public CoprocessorMethod withParameters(String... parameters) {
037    for (String parameter : parameters) {
038      this.parameters.add(parameter);
039    }
040
041    return this;
042  }
043
044  public CoprocessorMethod withParameters(Class<?>... parameters) {
045    for (Class<?> parameter : parameters) {
046      this.parameters.add(parameter.getCanonicalName());
047    }
048
049    return this;
050  }
051
052  @Override
053  public boolean equals(Object obj) {
054    if (obj == this) {
055      return true;
056    } else if (!(obj instanceof CoprocessorMethod)) {
057      return false;
058    }
059
060    CoprocessorMethod other = (CoprocessorMethod) obj;
061
062    return Objects.equals(name, other.name) && Objects.equals(parameters, other.parameters);
063  }
064
065  @Override
066  public int hashCode() {
067    return Objects.hash(name, parameters);
068  }
069}