Java Code Examples for org.joda.time.ReadablePeriod#getPeriodType()

The following examples show how to use org.joda.time.ReadablePeriod#getPeriodType() . 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: Time_10_BaseSingleFieldPeriod_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Compares this object with the specified object for equality based on the
 * value of each field. All ReadablePeriod instances are accepted, but only
 * those with a matching <code>PeriodType</code> can return true.
 *
 * @param period  a readable period to check against
 * @return true if all the field values are equal, false if
 *  not or the period is null or of an incorrect type
 */
public boolean equals(Object period) {
    if (this == period) {
        return true;
    }
    if (period instanceof ReadablePeriod == false) {
        return false;
    }
    ReadablePeriod other = (ReadablePeriod) period;
    return (other.getPeriodType() == getPeriodType() && other.getValue(0) == getValue());
}
 
Example 2
Source File: Time_10_BaseSingleFieldPeriod_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Compares this object with the specified object for equality based on the
 * value of each field. All ReadablePeriod instances are accepted, but only
 * those with a matching <code>PeriodType</code> can return true.
 *
 * @param period  a readable period to check against
 * @return true if all the field values are equal, false if
 *  not or the period is null or of an incorrect type
 */
public boolean equals(Object period) {
    if (this == period) {
        return true;
    }
    if (period instanceof ReadablePeriod == false) {
        return false;
    }
    ReadablePeriod other = (ReadablePeriod) period;
    return (other.getPeriodType() == getPeriodType() && other.getValue(0) == getValue());
}
 
Example 3
Source File: BaseSingleFieldPeriod.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 the
 * value of each field. All ReadablePeriod instances are accepted, but only
 * those with a matching <code>PeriodType</code> can return true.
 *
 * @param period  a readable period to check against
 * @return true if all the field values are equal, false if
 *  not or the period is null or of an incorrect type
 */
public boolean equals(Object period) {
    if (this == period) {
        return true;
    }
    if (period instanceof ReadablePeriod == false) {
        return false;
    }
    ReadablePeriod other = (ReadablePeriod) period;
    return (other.getPeriodType() == getPeriodType() && other.getValue(0) == getValue());
}
 
Example 4
Source File: BaseSingleFieldPeriod.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 the
 * value of each field. All ReadablePeriod instances are accepted, but only
 * those with a matching <code>PeriodType</code> can return true.
 *
 * @param period  a readable period to check against
 * @return true if all the field values are equal, false if
 *  not or the period is null or of an incorrect type
 */
public boolean equals(Object period) {
    if (this == period) {
        return true;
    }
    if (period instanceof ReadablePeriod == false) {
        return false;
    }
    ReadablePeriod other = (ReadablePeriod) period;
    return (other.getPeriodType() == getPeriodType() && other.getValue(0) == getValue());
}
 
Example 5
Source File: ReadablePeriodConverter.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Selects a suitable period type for the given object.
 *
 * @param object  the object to examine, must not be null
 * @return the period type from the readable duration
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public PeriodType getPeriodType(Object object) {
    ReadablePeriod period = (ReadablePeriod) object;
    return period.getPeriodType();
}
 
Example 6
Source File: ReadablePeriodConverter.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Selects a suitable period type for the given object.
 *
 * @param object  the object to examine, must not be null
 * @return the period type from the readable duration
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public PeriodType getPeriodType(Object object) {
    ReadablePeriod period = (ReadablePeriod) object;
    return period.getPeriodType();
}