Java Code Examples for org.joda.time.field.FieldUtils#equals()

The following examples show how to use org.joda.time.field.FieldUtils#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractPartial.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compares this ReadablePartial with another returning true if the chronology,
 * field types and values are equal.
 *
 * @param partial  an object to check against
 * @return true if fields and values are equal
 */
public boolean equals(Object partial) {
    if (this == partial) {
        return true;
    }
    if (partial instanceof ReadablePartial == false) {
        return false;
    }
    ReadablePartial other = (ReadablePartial) partial;
    if (size() != other.size()) {
        return false;
    }
    for (int i = 0, isize = size(); i < isize; i++) {
        if (getValue(i) != other.getValue(i) || getFieldType(i) != other.getFieldType(i)) {
            return false;
        }
    }
    return FieldUtils.equals(getChronology(), other.getChronology());
}
 
Example 2
Source File: AbstractPartial.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Compares this ReadablePartial with another returning true if the chronology,
 * field types and values are equal.
 *
 * @param partial  an object to check against
 * @return true if fields and values are equal
 */
public boolean equals(Object partial) {
    if (this == partial) {
        return true;
    }
    if (partial instanceof ReadablePartial == false) {
        return false;
    }
    ReadablePartial other = (ReadablePartial) partial;
    if (size() != other.size()) {
        return false;
    }
    for (int i = 0, isize = size(); i < isize; i++) {
        if (getValue(i) != other.getValue(i) || getFieldType(i) != other.getFieldType(i)) {
            return false;
        }
    }
    return FieldUtils.equals(getChronology(), other.getChronology());
}
 
Example 3
Source File: AbstractInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compares this object with the specified object for equality based
 * on start and end millis plus the chronology.
 * All ReadableInterval instances are accepted.
 * <p>
 * To compare the duration of two time intervals, use {@link #toDuration()}
 * to get the durations and compare those.
 *
 * @param readableInterval  a readable interval to check against
 * @return true if the intervals are equal comparing the start millis,
 *  end millis and chronology
 */
public boolean equals(Object readableInterval) {
    if (this == readableInterval) {
        return true;
    }
    if (readableInterval instanceof ReadableInterval == false) {
        return false;
    }
    ReadableInterval other = (ReadableInterval) readableInterval;
    return 
        getStartMillis() == other.getStartMillis() &&
        getEndMillis() == other.getEndMillis() &&
        FieldUtils.equals(getChronology(), other.getChronology());
}
 
Example 4
Source File: LimitChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A limit chronology is only equal to a limit chronology with the
 * same base chronology and limits.
 * 
 * @param obj  the object to compare to
 * @return true if equal
 * @since 1.4
 */
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj instanceof LimitChronology == false) {
        return false;
    }
    LimitChronology chrono = (LimitChronology) obj;
    return
        getBase().equals(chrono.getBase()) &&
        FieldUtils.equals(getLowerLimit(), chrono.getLowerLimit()) &&
        FieldUtils.equals(getUpperLimit(), chrono.getUpperLimit());
}
 
Example 5
Source File: AbstractInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compares this object with the specified object for equality based
 * on start and end millis plus the chronology.
 * All ReadableInterval instances are accepted.
 * <p>
 * To compare the duration of two time intervals, use {@link #toDuration()}
 * to get the durations and compare those.
 *
 * @param readableInterval  a readable interval to check against
 * @return true if the start and end millis are equal
 */
public boolean equals(Object readableInterval) {
    if (this == readableInterval) {
        return true;
    }
    if (readableInterval instanceof ReadableInterval == false) {
        return false;
    }
    ReadableInterval other = (ReadableInterval) readableInterval;
    return 
        getStartMillis() == other.getStartMillis() &&
        getEndMillis() == other.getEndMillis() &&
        FieldUtils.equals(getChronology(), other.getChronology());
}
 
Example 6
Source File: LimitChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A limit chronology is only equal to a limit chronology with the
 * same base chronology and limits.
 * 
 * @param obj  the object to compare to
 * @return true if equal
 * @since 1.4
 */
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj instanceof LimitChronology == false) {
        return false;
    }
    LimitChronology chrono = (LimitChronology) obj;
    return
        getBase().equals(chrono.getBase()) &&
        FieldUtils.equals(getLowerLimit(), chrono.getLowerLimit()) &&
        FieldUtils.equals(getUpperLimit(), chrono.getUpperLimit());
}
 
Example 7
Source File: AbstractInstant.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Compares this object with the specified object for equality based
 * on the millisecond instant, chronology and time zone.
 * <p>
 * Two objects which represent the same instant in time, but are in
 * different time zones (based on time zone id), will be considered to
 * be different. Only two objects with the same {@link DateTimeZone},
 * {@link Chronology} and instant are equal.
 * <p>
 * See {@link #isEqual(ReadableInstant)} for an equals method that
 * ignores the Chronology and time zone.
 * <p>
 * All ReadableInstant instances are accepted.
 *
 * @param readableInstant  a readable instant to check against
 * @return true if millisecond and chronology are equal, false if
 *  not or the instant is null or of an incorrect type
 */
public boolean equals(Object readableInstant) {
    // must be to fulfil ReadableInstant contract
    if (this == readableInstant) {
        return true;
    }
    if (readableInstant instanceof ReadableInstant == false) {
        return false;
    }
    ReadableInstant otherInstant = (ReadableInstant) readableInstant;
    return
        getMillis() == otherInstant.getMillis() &&
        FieldUtils.equals(getChronology(), otherInstant.getChronology());
}
 
Example 8
Source File: AbstractInstant.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Compares this object with the specified object for equality based
 * on the millisecond instant, chronology and time zone.
 * <p>
 * Two objects which represent the same instant in time, but are in
 * different time zones (based on time zone id), will be considered to
 * be different. Only two objects with the same {@link DateTimeZone},
 * {@link Chronology} and instant are equal.
 * <p>
 * See {@link #isEqual(ReadableInstant)} for an equals method that
 * ignores the Chronology and time zone.
 * <p>
 * All ReadableInstant instances are accepted.
 *
 * @param readableInstant  a readable instant to check against
 * @return true if millisecond and chronology are equal, false if
 *  not or the instant is null or of an incorrect type
 */
public boolean equals(Object readableInstant) {
    // must be to fulfil ReadableInstant contract
    if (this == readableInstant) {
        return true;
    }
    if (readableInstant instanceof ReadableInstant == false) {
        return false;
    }
    ReadableInstant otherInstant = (ReadableInstant) readableInstant;
    return
        getMillis() == otherInstant.getMillis() &&
        FieldUtils.equals(getChronology(), otherInstant.getChronology());
}