Example usage for org.jfree.data.time Quarter getYearValue

List of usage examples for org.jfree.data.time Quarter getYearValue

Introduction

In this page you can find the example usage for org.jfree.data.time Quarter getYearValue.

Prototype

public int getYearValue() 

Source Link

Document

Returns the year.

Usage

From source file:org.jfree.data.time.Quarter.java

/**
 * Returns an integer indicating the order of this Quarter object relative
 * to the specified object:/*from ww  w  .ja v a  2s .  c  o  m*/
 *
 * negative == before, zero == same, positive == after.
 *
 * @param o1  the object to compare
 *
 * @return negative == before, zero == same, positive == after.
 */
@Override
public int compareTo(TimePeriod o1) {

    int result;

    // CASE 1 : Comparing to another Quarter object
    // --------------------------------------------
    if (o1 instanceof Quarter) {
        Quarter q = (Quarter) o1;
        result = this.year - q.getYearValue();
        if (result == 0) {
            result = this.quarter - q.getQuarter();
        }
    }

    // CASE 2 : Comparing to another TimePeriod object
    // -----------------------------------------------
    else {
        // more difficult case - evaluate later...
        result = 0;
    }

    return result;

}

From source file:org.jfree.data.time.Quarter.java

/**
 * Tests the equality of this Quarter object to an arbitrary object.
 * Returns <code>true</code> if the target is a Quarter instance
 * representing the same quarter as this object.  In all other cases,
 * returns <code>false</code>.
 *
 * @param obj  the object (<code>null</code> permitted).
 *
 * @return <code>true</code> if quarter and year of this and the object are
 *         the same./*from w  w w  . j  a v  a 2 s  .  co m*/
 */
@Override
public boolean equals(Object obj) {
    if (obj instanceof Quarter) {
        Quarter target = (Quarter) obj;
        return (this.quarter == target.getQuarter() && (this.year == target.getYearValue()));
    }
    return false;
}