示例#1
0
 @Override
 public boolean equals(Object o) {
   if (!(o instanceof Stream)) return false;
   Stream other = (Stream) o;
   if (!getLocation().equals(other.getLocation())) return false;
   if (!streamBase.equals(other.streamBase)) return false;
   if (!getResourceClass().equals(other.getResourceClass())) return false;
   if (instanceParam != other.instanceParam) return false;
   return true;
 }
示例#2
0
  @Override
  public int compareTo(Stream other) {
    int cmp;

    // The main idea in comparing streams is that
    // if they can't be differentiated by location
    // and base/stream class, then we should try
    // instanceParam. This allows streams passed in
    // different parameters to be distinguished.

    cmp = getLocation().compareTo(other.getLocation());
    if (cmp != 0) return cmp;
    cmp = streamBase.compareTo(other.streamBase);
    if (cmp != 0) return cmp;
    cmp = getResourceClass().compareTo(other.getResourceClass());
    if (cmp != 0) return cmp;
    cmp = instanceParam - other.instanceParam;
    if (cmp != 0) return cmp;

    return 0;
  }