package com.onaro.util.jfc.date; import java.util.Date; /** * Custom time-filter provide an absolute start time. */ public class TimeFilterCustom implements TimeFilter { /** * The selected start time. */ private Date startTime; /** * The selected start time. */ private Date endTime; /** * Set the filter's start time. * @param startTime the selected start time * @param endTime the selected end time */ public TimeFilterCustom(Date startTime, Date endTime) { this.startTime = startTime; this.endTime = endTime; } /** * Gets the absolute start time * @return the absolute start time */ public Date getStartTime() { return startTime; } public Date getEndTime() { return endTime; } /** * Test if two filters are equal. Used to prevent unneeded server request if the * filter didn't really changed. * @param o the other filter * @return true if the filters have thesame absolute start time */ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final TimeFilterCustom that = (TimeFilterCustom) o; if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false; if (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null) return false; return true; } public int hashCode() { int result; result = (startTime != null ? startTime.hashCode() : 0); result = 29 * result + (endTime != null ? endTime.hashCode() : 0); return result; } public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("TimeFilterCustom"); //$NON-NLS-1$ sb.append("{endTime=").append(endTime); //$NON-NLS-1$ sb.append(",startTime=").append(startTime); //$NON-NLS-1$ sb.append('}'); return sb.toString(); } }