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 * Mechanism of activation. 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_TriggerCode", specification=ISO_19115_2) 037public final class Trigger extends CodeList<Trigger> { 038 /** 039 * Serial number for compatibility with different versions. 040 */ 041 private static final long serialVersionUID = 649620597963351153L; 042 043 /** 044 * Event due to external stimuli. 045 */ 046 @UML(identifier="automatic", obligation=CONDITIONAL, specification=ISO_19115_2) 047 public static final Trigger AUTOMATIC = new Trigger("AUTOMATIC"); 048 049 /** 050 * Event manually instigated. 051 */ 052 @UML(identifier="manual", obligation=CONDITIONAL, specification=ISO_19115_2) 053 public static final Trigger MANUAL = new Trigger("MANUAL"); 054 055 /** 056 * Event instigated by planned internal stimuli. 057 */ 058 @UML(identifier="preProgrammed", obligation=CONDITIONAL, specification=ISO_19115_2) 059 public static final Trigger PRE_PROGRAMMED = new Trigger("PRE_PROGRAMMED"); 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 Trigger(final String name) { 067 super(name); 068 } 069 070 /** 071 * Returns the list of {@code Trigger}s. 072 * 073 * @return the list of codes declared in the current JVM. 074 */ 075 public static Trigger[] values() { 076 return values(Trigger.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 Trigger[] family() { 088 return values(); 089 } 090 091 /** 092 * Returns the trigger 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 Trigger valueOf(String code) { 101 return valueOf(Trigger.class, code, Trigger::new).get(); 102 } 103}