Пример #1
0
  /**
   * Adds all parameters of the parameterlist to this one, if the named parameter is not already in
   * the list. If a named parameter exists already a Parameter Exception is thrown.
   */
  public void addParameterList(ParameterList list2) throws ParameterException {

    ListIterator<ParameterAPI<?>> it = list2.getParametersIterator();
    while (it.hasNext()) {
      ParameterAPI<?> param = (ParameterAPI<?>) it.next();
      if (!this.containsParameter(param)) {
        this.addParameter(param);
      }
    }
  }
Пример #2
0
  /**
   * compares 2 ParameterList to see if they are equal. It compares them by checking each parameter
   * with the passed argument obj is present in the parameterList, it is compared with. It also
   * checks if both the parameterLists have same parameters and have the same values.
   *
   * @param obj instance of ParameterList
   * @return int 0 if both object are same else return -1
   */
  public int compareTo(Object obj) {

    int result = 0;

    if (!(obj instanceof ParameterList)) {
      throw new ClassCastException(C + "Object not a ParameterList, unable to compare");
    }

    ParameterList paramList = (ParameterList) obj;

    ListIterator<ParameterAPI<?>> it = paramList.getParametersIterator();

    if (size() != paramList.size()) return -1;

    while (it.hasNext()) {
      ParameterAPI param1 = (ParameterAPI) it.next();
      ParameterAPI param2 = (ParameterAPI) getParameter(param1.getName());
      result = param2.compareTo(param1);
      if (result != 0) break;
    }

    return result;
  }