
package de.ivu.elect.presentation.system;

import java.io.Serializable;
import java.util.Arrays;

/**
 *  on 30.06.2015.
 */
public class FinderKey implements Serializable {

  private static final long serialVersionUID = 1L;

  private final String finderName;

  private final Object[] parameter;

  public FinderKey(String finderName, Object... parameter) {
    this.finderName = finderName;
    this.parameter = parameter;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    FinderKey finderKey = (FinderKey) o;

    if (finderName != null ? !finderName.equals(finderKey.finderName) : finderKey.finderName != null) {
      return false;
    }
    // Probably incorrect - comparing Object[] arrays with Arrays.equals
    return Arrays.equals(parameter, finderKey.parameter);

  }

  @Override
  public int hashCode() {
    int result = finderName != null ? finderName.hashCode() : 0;
    result = 31 * result + (parameter != null ? Arrays.hashCode(parameter) : 0);
    return result;
  }
}
