001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2009-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.metadata.acquisition; 019 020import org.opengis.annotation.UML; 021import org.opengis.util.CodeList; 022import org.opengis.geoapi.internal.Vocabulary; 023 024import static org.opengis.annotation.Obligation.*; 025import static org.opengis.annotation.Specification.*; 026 027 028/** 029 * Designation of criterion for defining the context of the scanning process event. 030 * 031 * @author Cédric Briançon (Geomatys) 032 * @version 3.1 033 * @since 2.3 034 */ 035@Vocabulary(capacity=3) 036@UML(identifier="MI_ContextCode", specification=ISO_19115_2) 037public final class Context extends CodeList<Context> { 038 /** 039 * Serial number for compatibility with different versions. 040 */ 041 private static final long serialVersionUID = 1723020399396010030L; 042 043 /** 044 * Event related to a specific collection. 045 */ 046 @UML(identifier="acquisition", obligation=CONDITIONAL, specification=ISO_19115_2) 047 public static final Context ACQUISITION = new Context("ACQUISITION"); 048 049 /** 050 * Event related to a sequence of collections. 051 */ 052 @UML(identifier="pass", obligation=CONDITIONAL, specification=ISO_19115_2) 053 public static final Context PASS = new Context("PASS"); 054 055 /** 056 * Event related to a navigational manoeuvre. 057 */ 058 @UML(identifier="wayPoint", obligation=CONDITIONAL, specification=ISO_19115_2) 059 public static final Context WAY_POINT = new Context("WAY_POINT"); 060 061 /** 062 * Constructs an element of the given name. 063 * 064 * @param name the name of the new element. This name shall not be in use by another element of this type. 065 */ 066 private Context(final String name) { 067 super(name); 068 } 069 070 /** 071 * Returns the list of {@code Context}s. 072 * 073 * @return the list of codes declared in the current JVM. 074 */ 075 public static Context[] values() { 076 return values(Context.class); 077 } 078 079 /** 080 * Returns the list of codes of the same kind as this code list element. 081 * Invoking this method is equivalent to invoking {@link #values()}, except that 082 * this method can be invoked on an instance of the parent {@code CodeList} class. 083 * 084 * @return all code {@linkplain #values() values} for this code list. 085 */ 086 @Override 087 public Context[] family() { 088 return values(); 089 } 090 091 /** 092 * Returns the context that matches the given string, or returns a new one if none match it. 093 * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name} 094 * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name. 095 * If no existing instance is found, then a new one is created for the given name. 096 * 097 * @param code the name of the code to fetch or to create. 098 * @return a code matching the given name. 099 */ 100 public static Context valueOf(String code) { 101 return valueOf(Context.class, code, Context::new).get(); 102 } 103}