コード例 #1
0
 @Override
 public boolean equals(Object object) {
   if (object == this) {
     return true;
   }
   if (!(object instanceof NativeBreakIterator)) {
     return false;
   }
   // TODO: is this sufficient? shouldn't we be checking the underlying rules?
   NativeBreakIterator rhs = (NativeBreakIterator) object;
   return type == rhs.type && charIter.equals(rhs.charIter);
 }
コード例 #2
0
  /**
   * Returns true if both BreakIterators are of the same class, have the same rules, and iterate
   * over the same text.
   */
  @Override
  public boolean equals(Object that) {
    try {
      if (that == null) {
        return false;
      }

      RuleBasedBreakIterator other = (RuleBasedBreakIterator) that;
      if (checksum != other.checksum) {
        return false;
      }
      if (text == null) {
        return other.text == null;
      } else {
        return text.equals(other.text);
      }
    } catch (ClassCastException e) {
      return false;
    }
  }