/* * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008, Open Source Geospatial Foundation (OSGeo) * (C) 2009, Geomatys * * This library 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; * version 2.1 of the License. * * This library 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. */ package org.geotoolkit.temporal.object; import java.util.Objects; import org.opengis.temporal.IndeterminateValue; import org.opengis.temporal.OrdinalEra; import org.opengis.temporal.OrdinalPosition; import org.opengis.temporal.TemporalReferenceSystem; /** * A data type that shall be used for identifying temporal position within an ordinal * temporal reference system. * * @author Mehdi Sidhoum (Geomatys) * @module */ public class DefaultOrdinalPosition extends DefaultTemporalPosition implements OrdinalPosition { /** * This is a reference to the ordinal era in which the instant occurs. */ private OrdinalEra ordinalPosition; public DefaultOrdinalPosition(final TemporalReferenceSystem frame, final IndeterminateValue indeterminatePosition, final OrdinalEra ordinalPosition) { super(frame, indeterminatePosition); this.ordinalPosition = ordinalPosition; } /** * Provides a reference to the ordinal era in which the instant occurs. * * @todo The method name doesn't match the return type. */ @Override public OrdinalEra getOrdinalPosition() { return ordinalPosition; } public void setOrdinalPosition(final OrdinalEra ordinalPosition) { this.ordinalPosition = ordinalPosition; } @Override public boolean equals(final Object object) { if (object == this) { return true; } if (object instanceof DefaultOrdinalPosition && super.equals(object)) { final DefaultOrdinalPosition that = (DefaultOrdinalPosition) object; return Objects.equals(this.ordinalPosition, that.ordinalPosition); } return false; } @Override public int hashCode() { int hash = 5; hash = 37 * hash + (this.ordinalPosition != null ? this.ordinalPosition.hashCode() : 0); return hash; } @Override public String toString() { StringBuilder s = new StringBuilder("OrdinalPosition:").append('\n'); if (ordinalPosition != null) { s.append("ordinalPosition:").append(ordinalPosition).append('\n'); } return s.toString(); } }