1 package org.apidesign.apifest08.currency;
7 public final class DateRange
9 private final Date from;
10 private final Date till;
12 DateRange(final Date f,
15 if(f == null && t != null)
17 throw new IllegalArgumentException("f was null but t was not");
20 if(f != null && t == null)
22 throw new IllegalArgumentException("f was null but t was not");
39 public boolean isInRange(final Date date)
43 if(date.equals(from) || date.equals(till))
47 else if(date.after(from) && date.before(till))
60 public boolean equals(Object obj) {
64 if (getClass() != obj.getClass()) {
67 final DateRange other = (DateRange) obj;
68 if (this.from != other.from && (this.from == null || !this.from.equals(other.from))) {
71 if (this.till != other.till && (this.till == null || !this.till.equals(other.till))) {
78 public int hashCode() {
80 hash = 89 * hash + (this.from != null ? this.from.hashCode() : 0);
81 hash = 89 * hash + (this.till != null ? this.till.hashCode() : 0);
86 public String toString()
88 return (from + " until " + till);