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 * Temporal relation 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_SequenceCode", specification=ISO_19115_2)
037public final class Sequence extends CodeList<Sequence> {
038    /**
039     * Serial number for compatibility with different versions.
040     */
041    private static final long serialVersionUID = -3995216796996596661L;
042
043    /**
044     * Beginning of a collection.
045     */
046    @UML(identifier="start", obligation=CONDITIONAL, specification=ISO_19115_2)
047    public static final Sequence START = new Sequence("START");
048
049    /**
050     * End of a collection.
051     */
052    @UML(identifier="end", obligation=CONDITIONAL, specification=ISO_19115_2)
053    public static final Sequence END = new Sequence("END");
054
055    /**
056     * Collection without a significant duration
057     */
058    @UML(identifier="instantaneous", obligation=CONDITIONAL, specification=ISO_19115_2)
059    public static final Sequence INSTANTANEOUS = new Sequence("INSTANTANEOUS");
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 Sequence(final String name) {
067        super(name);
068    }
069
070    /**
071     * Returns the list of {@code Sequence}s.
072     *
073     * @return the list of codes declared in the current JVM.
074     */
075    public static Sequence[] values() {
076        return values(Sequence.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 Sequence[] family() {
088        return values();
089    }
090
091    /**
092     * Returns the sequence 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 Sequence valueOf(String code) {
101        return valueOf(Sequence.class, code, Sequence::new).get();
102    }
103}