Esempio n. 1
0
  /**
   * Returns the subsample with the given index. In case the subsample doesn't exist, null is
   * returned.
   *
   * @param subsampleId The subsamples index.
   * @return
   */
  public Subsample getSubsample(Integer subsampleId) {
    if (subsamples == null) {
      return null;
    }

    for (Subsample s : subsamples) {
      if (s.getSubsampleIndex() == subsampleId) {
        return s;
      }
    }

    return null;
  }
Esempio n. 2
0
  /**
   * Adds the given subsample. In case a subsample with the same index already exists, this subample
   * is replaced.
   *
   * @param s
   */
  public void setSubsample(Subsample s) {
    if (subsamples == null) {
      subsamples = new ArrayList<Subsample>(1);
    }

    // check if the subsample already exists
    for (int i = 0; i < subsamples.size(); i++) {
      // if a subsample with the same index already exists, replace it
      if (subsamples.get(i).getSubsampleIndex() == s.getSubsampleIndex()) {
        subsamples.set(i, s);
        return;
      }
    }

    // as the subsample wasn't set, add this one
    subsamples.add(s);
  }