001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2006-2024 Open Geospatial Consortium, Inc. 004 * http://www.geoapi.org 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.opengis.temporal; 019 020import org.opengis.util.CodeList; 021import org.opengis.annotation.UML; 022import org.opengis.geoapi.internal.Vocabulary; 023 024import static org.opengis.annotation.Specification.ISO_19108; 025import static org.opengis.annotation.Obligation.CONDITIONAL; 026 027 028/** 029 * Indications that a temporal position is not precisely known. 030 * 031 * @author ISO 19108 (for abstract model and documentation) 032 * @author Stephane Fellah (Image Matters) 033 * @author Alexander Petkov 034 * @author Martin Desruisseaux (IRD, Geomatys) 035 * @since 3.1 036 * @version 3.1 037 */ 038@Vocabulary(capacity=4) 039@UML(identifier="TM_IndeterminateValue", specification=ISO_19108) 040public final class IndeterminateValue extends CodeList<IndeterminateValue> { 041 /** 042 * Serial number for compatibility with different versions. 043 */ 044 private static final long serialVersionUID = 1399031922917754577L; 045 046 /** 047 * Indicates that no specific value for temporal position is provided. 048 */ 049 @UML(identifier="unknown", obligation=CONDITIONAL, specification=ISO_19108) 050 public static final IndeterminateValue UNKNOWN = new IndeterminateValue("UNKNOWN"); 051 052 /** 053 * Indicates that the specified value shall be replaced with the 054 * current temporal position whenever the value is accessed. 055 */ 056 @UML(identifier="now", obligation=CONDITIONAL, specification=ISO_19108) 057 public static final IndeterminateValue NOW = new IndeterminateValue("NOW"); 058 059 /** 060 * Indicate that the actual temporal position is unknown, but it is known to be before the specified value. 061 */ 062 @UML(identifier="before", obligation=CONDITIONAL, specification=ISO_19108) 063 public static final IndeterminateValue BEFORE = new IndeterminateValue("BEFORE"); 064 065 /** 066 * Indicates that the actual temporal position is unknown, but it is known to be after the specified value. 067 */ 068 @UML(identifier="after", obligation=CONDITIONAL, specification=ISO_19108) 069 public static final IndeterminateValue AFTER = new IndeterminateValue("AFTER"); 070 071 /** 072 * Constructs an element of the given name. 073 * 074 * @param name the name of the new element. This name shall not be in use by another element of this type. 075 */ 076 private IndeterminateValue(final String name) { 077 super(name); 078 } 079 080 /** 081 * Returns the list of {@code IndeterminateValue}s. 082 * 083 * @return the list of codes declared in the current JVM. 084 */ 085 public static IndeterminateValue[] values() { 086 return values(IndeterminateValue.class); 087 } 088 089 /** 090 * Returns the list of codes of the same kind as this code list element. 091 * Invoking this method is equivalent to invoking {@link #values()}, except that 092 * this method can be invoked on an instance of the parent {@code CodeList} class. 093 * 094 * @return all code {@linkplain #values() values} for this code list. 095 */ 096 @Override 097 public IndeterminateValue[] family() { 098 return values(); 099 } 100 101 /** 102 * Returns the indeterminate value that matches the given string, or returns a new one if none match it. 103 * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name} 104 * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name. 105 * If no existing instance is found, then a new one is created for the given name. 106 * 107 * @param code the name of the code to fetch or to create. 108 * @return a code matching the given name. 109 */ 110 public static IndeterminateValue valueOf(String code) { 111 return valueOf(IndeterminateValue.class, code, IndeterminateValue::new).get(); 112 } 113}