public boolean equals()

in src/com/amazon/ion/Timestamp.java [2750:2795]


    public boolean equals(Timestamp t)
    {
        if (this == t) return true;
        if (t == null) return false;

        // FRACTION precision is equivalent to SECOND precision.
        Precision thisPrecision = this._precision.includes(Precision.SECOND) ? Precision.SECOND : this._precision;
        Precision thatPrecision = t._precision.includes(Precision.SECOND) ? Precision.SECOND : t._precision;

        // if the precisions are not the same the values are not
        // precision doesn't matter WRT equality
        if (thisPrecision != thatPrecision) return false;

        // if the local offset are not the same the values are not
        if (this._offset == null) {
            if (t._offset != null)  return false;
        }
        else {
            if (t._offset == null) return false;
        }

        // so now we check the actual time value
        if (this._year   != t._year)    return false;
        if (this._month  != t._month)   return false;
        if (this._day    != t._day)     return false;
        if (this._hour   != t._hour)    return false;
        if (this._minute != t._minute)  return false;
        if (this._second != t._second)  return false;

        // and if we have a local offset, check the value here
        if (this._offset != null) {
            if (this._offset.intValue() != t._offset.intValue()) return false;
        }

        // we only look at the fraction if we know that it's actually there
        if ((this._fraction != null && t._fraction == null)
                || (this._fraction == null && t._fraction != null)) {
            // one of the fractions are null
            return false;
        }
        if (this._fraction == null && t._fraction == null) {
            // both are null
            return true;
        }
        return this._fraction.equals(t._fraction);
    }