/* * Copyright 2007, 2008 Duncan McGregor * * This file is part of Rococoa, a library to allow Java to talk to Cocoa. * * Rococoa is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Rococoa is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Rococoa. If not, see <http://www.gnu.org/licenses/>. */ package org.rococoa.cocoa.qtkit; import java.util.Arrays; import java.util.List; import com.sun.jna.Structure; public class QTTimeRange extends Structure implements Structure.ByValue { public QTTime time; public QTTime duration; public QTTimeRange() { } public QTTimeRange(QTTime time, QTTime duration) { this.time = time; this.duration = duration; } @Override protected List getFieldOrder() { return Arrays.asList("time", "duration"); } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((duration == null) ? 0 : duration.hashCode()); result = prime * result + ((time == null) ? 0 : time.hashCode()); return result; } @Override public boolean equals(Object obj) { if(this == obj) { return true; } if(!super.equals(obj)) { return false; } if(getClass() != obj.getClass()) { return false; } final QTTimeRange other = (QTTimeRange) obj; if(duration == null) { if(other.duration != null) { return false; } } else if(!duration.equals(other.duration)) { return false; } if(time == null) { if(other.time != null) { return false; } } else if(!time.equals(other.time)) { return false; } return true; } }