package uk.org.mikea.whitby;

import java.util.Comparator;
import java.util.List;

import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.joda.time.LocalTime;

public interface Event {
	public boolean tbc();
	public LocalTime startTime();
	public LocalTime endTime();
	public String displayTime();
	public String location();
	public List<Team> teams();
	public void writeDetail(XWPFParagraph paragraph, Team team);
	
	public static class EventComparator implements Comparator<Event> {
		@Override
		public int compare(Event o1, Event o2) {
			if (o1.tbc() && o2.tbc()) {
				return 0;
			} else if (o1.tbc() && !o2.tbc()) {
				return 1;
			} else if (!o1.tbc() && o2.tbc()) {
				return -1;
			}
			int startComparison = o1.startTime().compareTo(o2.startTime());
			if (startComparison == 0) {
				if ((o1.endTime() != null) && (o2.endTime() != null)) {
					return o1.endTime().compareTo(o2.endTime());
				} else if (o1.endTime() != null) {
					return -1;
				}
				return 1;
			}
			return startComparison;
		}
	}
}
