📄 appointmentstartcomparator.java
字号:
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by the |
| Free Software Foundation. A copy of the license has been included with |
| these distribution in the COPYING file, if not go to www.fsf.org |
| |
| As a special exception, you are granted the permissions to link this |
| program with every library, which license fulfills the Open Source |
| Definition as published by the Open Source Initiative (OSI). |
*--------------------------------------------------------------------------*/
package org.rapla.entities.domain;
import java.util.*;
public class AppointmentStartComparator implements Comparator {
public int compare(Object o1,Object o2) {
if (o1 instanceof Date)
return compare((Date) o1, o2);
if (o2 instanceof Date)
return -1 * compare((Date) o2, o1 );
if ( o1.equals(o2)) return 0;
Appointment a1 = (Appointment) o1;
Appointment a2 = (Appointment) o2;
if (a1.getStart().before(a2.getStart()))
return -1;
if (a1.getStart().after(a2.getStart()))
return 1;
return (o1.hashCode() < o2.hashCode()) ? -1 : 1;
}
public int compare(Date d1,Object o2) {
if (o2 instanceof Date)
return d1.compareTo((Date) o2);
Appointment a2 = (Appointment) o2;
if (d1.before(a2.getStart())) {
//System.out.println(a2 + ">" + d1);
return -1;
}
if (d1.after(a2.getStart())) {
// System.out.println(a2 + "<" + d1);
return 1;
}
// If appointment.getStart().equals(date)
// set the appointment before the date
return 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -