예제 #1
0
  /**
   * Returns true if all the parameters have the same names and values. One use will be to determine
   * if two DisctetizedFunctions are the same, i.e. set up with the same independent parameters.
   */
  public boolean equalsParameterList(ParameterList list) {

    // Not same size, can't be equal
    if (this.size() != list.size()) return false;

    // Check each individual Parameter
    ListIterator<ParameterAPI<?>> it = this.getParametersIterator();
    while (it.hasNext()) {

      // This list's parameter
      ParameterAPI<?> param1 = it.next();

      // List may not contain parameter with this list's parameter name
      if (!list.containsParameter(param1.getName())) return false;

      // Found two parameters with same name, check equals, actually
      // redundent,
      // because that is what equals does
      ParameterAPI<?> param2 = list.getParameter(param1.getName());
      if (!param1.equals(param2)) return false;

      // Now try compare to to see if value the same, can fail if two
      // values
      // are different, or if the value object types are different
      try {
        if (param1.compareTo(param2) != 0) return false;
      } catch (ClassCastException ee) {
        return false;
      }
    }

    // Passed all tests - return true
    return true;
  }