001package votorola.a.diff.harvest; 002 003import java.util.Date; 004 005import votorola.g.lang.ThreadSafe; 006import votorola.g.lang.Warning; 007 008/** 009 * Final class to represent points in the archive. This is not necessary generic 010 * enough, so it is not a stable API yet and only used by 011 * {@linkplain PipermailHarvester}. 012 * 013 */ 014@Warning("non-API") 015@ThreadSafe 016final public class Marker implements Comparable<Marker> { 017 018 private final String path; 019 private final Date date; 020 021 /** 022 * Use factories. 023 */ 024 private Marker(final String path, final Date date) { 025 this.path = path; 026 this.date = date; 027 } 028 029 /** 030 * Construct a new marker. 031 * 032 * @param path 033 * @param date 034 */ 035 @Warning("non-API") 036 public static Marker create(final String path, final Date date) { 037 return new Marker(path, date); 038 } 039 040 /** 041 * 042 */ 043 @Warning("non-API") 044 public static Marker dummy() { 045 return dummy; 046 } 047 048 private static Marker dummy = new Marker("", new Date(0)); 049 050 public String path() { 051 return path; 052 } 053 054 public Date date() { 055 return date; 056 } 057 058 /** 059 * If both date and marker are equal, this returns true. 060 * 061 * @return equality 062 */ 063 @Override 064 public boolean equals(final Object o) { 065 if (this == o) { 066 return true; 067 } 068 return (o instanceof Marker) && ((Marker) o).path.equals(path) 069 && ((Marker) o).date.equals(date); 070 } 071 072 /** 073 * Obey equals contract. 074 */ 075 @Override 076 public int hashCode() { 077 return path.hashCode() * 37 + date.hashCode(); 078 } 079 080 /** 081 * Compare through date. 082 */ 083 public int compareTo(Marker m) { 084 return m.date.compareTo(date); 085 } 086}