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.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 * Code indicating whether the data contained in a packet is real, simulated or synthesized.
030 * Real data originates from live-fly or other non-simulated operational sources.
031 * Simulated data originates from target simulator sources.
032 * Synthesized data is a mix of real and simulated data.
033 *
034 * @author  Cédric Briançon (Geomatys)
035 * @version 3.1
036 * @since   2.3
037 */
038@Vocabulary(capacity=3)
039@UML(identifier="MI_OperationTypeCode", specification=ISO_19115_2)
040public final class OperationType extends CodeList<OperationType> {
041    /**
042     * Serial number for compatibility with different versions.
043     */
044    private static final long serialVersionUID = -4952647967684867284L;
045
046    /**
047     * Originates from live-fly or other non-simulated operational source.
048     */
049    @UML(identifier="real", obligation=CONDITIONAL, specification=ISO_19115_2)
050    public static final OperationType REAL = new OperationType("REAL");
051
052    /**
053     * Originates from target simulator sources.
054     */
055    @UML(identifier="simulated", obligation=CONDITIONAL, specification=ISO_19115_2)
056    public static final OperationType SIMULATED = new OperationType("SIMULATED");
057
058    /**
059     * Mix of real and simulated data.
060     */
061    @UML(identifier="synthesized", obligation=CONDITIONAL, specification=ISO_19115_2)
062    public static final OperationType SYNTHESIZED = new OperationType("SYNTHESIZED");
063
064    /**
065     * Constructs an element of the given name.
066     *
067     * @param name  the name of the new element. This name shall not be in use by another element of this type.
068     */
069    private OperationType(final String name) {
070        super(name);
071    }
072
073    /**
074     * Returns the list of {@code OperationType}s.
075     *
076     * @return the list of codes declared in the current JVM.
077     */
078    public static OperationType[] values() {
079        return values(OperationType.class);
080    }
081
082    /**
083     * Returns the list of codes of the same kind as this code list element.
084     * Invoking this method is equivalent to invoking {@link #values()}, except that
085     * this method can be invoked on an instance of the parent {@code CodeList} class.
086     *
087     * @return all code {@linkplain #values() values} for this code list.
088     */
089    @Override
090    public OperationType[] family() {
091        return values();
092    }
093
094    /**
095     * Returns the operation type that matches the given string, or returns a new one if none match it.
096     * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name}
097     * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name.
098     * If no existing instance is found, then a new one is created for the given name.
099     *
100     * @param  code  the name of the code to fetch or to create.
101     * @return a code matching the given name.
102     */
103    public static OperationType valueOf(String code) {
104        return valueOf(OperationType.class, code, OperationType::new).get();
105    }
106}