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 * Ordered list of priorities.
030 *
031 * @author  Cédric Briançon (Geomatys)
032 * @version 3.1
033 * @since   2.3
034 */
035@Vocabulary(capacity=4)
036@UML(identifier="MI_PriorityCode", specification=ISO_19115_2)
037public final class Priority extends CodeList<Priority> {
038    /**
039     * Serial number for compatibility with different versions.
040     */
041    private static final long serialVersionUID = -3504801926504645861L;
042
043    /**
044     * Decisive importance.
045     */
046    @UML(identifier="critical", obligation=CONDITIONAL, specification=ISO_19115_2)
047    public static final Priority CRITICAL = new Priority("CRITICAL");
048
049    /**
050     * Requires resources to be made available.
051     */
052    @UML(identifier="highImportance", obligation=CONDITIONAL, specification=ISO_19115_2)
053    public static final Priority HIGH_IMPORTANCE = new Priority("HIGH_IMPORTANCE");
054
055    /**
056     * Normal operation priority.
057     */
058    @UML(identifier="mediumImportance", obligation=CONDITIONAL, specification=ISO_19115_2)
059    public static final Priority MEDIUM_IMPORTANCE = new Priority("MEDIUM_IMPORTANCE");
060
061    /**
062     * To be completed when resources are available
063     */
064    @UML(identifier="lowImportance", obligation=CONDITIONAL, specification=ISO_19115_2)
065    public static final Priority LOW_IMPORTANCE = new Priority("LOW_IMPORTANCE");
066
067    /**
068     * Constructs an element of the given name.
069     *
070     * @param name  the name of the new element. This name shall not be in use by another element of this type.
071     */
072    private Priority(final String name) {
073        super(name);
074    }
075
076    /**
077     * Returns the list of {@code Priority}s.
078     *
079     * @return the list of codes declared in the current JVM.
080     */
081    public static Priority[] values() {
082        return values(Priority.class);
083    }
084
085    /**
086     * Returns the list of codes of the same kind as this code list element.
087     * Invoking this method is equivalent to invoking {@link #values()}, except that
088     * this method can be invoked on an instance of the parent {@code CodeList} class.
089     *
090     * @return all code {@linkplain #values() values} for this code list.
091     */
092    @Override
093    public Priority[] family() {
094        return values();
095    }
096
097    /**
098     * Returns the priority that matches the given string, or returns a new one if none match it.
099     * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name}
100     * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name.
101     * If no existing instance is found, then a new one is created for the given name.
102     *
103     * @param  code  the name of the code to fetch or to create.
104     * @return a code matching the given name.
105     */
106    public static Priority valueOf(String code) {
107        return valueOf(Priority.class, code, Priority::new).get();
108    }
109}