001/*
002 *    GeoAPI - Java interfaces for OGC/ISO standards
003 *    Copyright © 2004-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.citation;
019
020import org.opengis.util.CodeList;
021import org.opengis.annotation.UML;
022import org.opengis.geoapi.internal.Vocabulary;
023
024import static org.opengis.annotation.Obligation.*;
025import static org.opengis.annotation.Specification.*;
026
027
028/**
029 * Class of information to which the referencing entity applies.
030 *
031 * @author  Martin Desruisseaux (IRD)
032 * @author  Rémi Maréchal (Geomatys)
033 * @version 3.1
034 * @since   2.0
035 */
036@Vocabulary(capacity=11)
037@UML(identifier="CI_OnLineFunctionCode", specification=ISO_19115)
038public final class OnLineFunction extends CodeList<OnLineFunction> {
039    /**
040     * Serial number for compatibility with different versions.
041     */
042    private static final long serialVersionUID = 2333803519583053407L;
043
044    /**
045     * Online instructions for transferring data from one storage device or system to another.
046     */
047    @UML(identifier="download", obligation=CONDITIONAL, specification=ISO_19115)
048    public static final OnLineFunction DOWNLOAD = new OnLineFunction("DOWNLOAD");
049
050    /**
051     * Online information about the resource.
052     */
053    @UML(identifier="information", obligation=CONDITIONAL, specification=ISO_19115)
054    public static final OnLineFunction INFORMATION = new OnLineFunction("INFORMATION");
055
056    /**
057     * Online instructions for requesting the resource from the provider.
058     */
059    @UML(identifier="offlineAccess", obligation=CONDITIONAL, specification=ISO_19115)
060    public static final OnLineFunction OFFLINE_ACCESS = new OnLineFunction("OFFLINE_ACCESS");
061
062    /**
063     * Online order process for obtaining the resource.
064     */
065    @UML(identifier="order", obligation=CONDITIONAL, specification=ISO_19115)
066    public static final OnLineFunction ORDER = new OnLineFunction("ORDER");
067
068    /**
069     * Online search interface for seeking out information about the resource.
070     */
071    @UML(identifier="search", obligation=CONDITIONAL, specification=ISO_19115)
072    public static final OnLineFunction SEARCH = new OnLineFunction("SEARCH");
073
074    /**
075     * Complete metadata provided.
076     *
077     * @since 3.1
078     */
079    @UML(identifier="completeMetadata", obligation=CONDITIONAL, specification=ISO_19115)
080    public static final OnLineFunction COMPLETE_METADATA = new OnLineFunction("COMPLETE_METADATA");
081
082    /**
083     * Browse graphic provided.
084     *
085     * @since 3.1
086     */
087    @UML(identifier="browseGraphic", obligation=CONDITIONAL, specification=ISO_19115)
088    public static final OnLineFunction BROWSE_GRAPHIC = new OnLineFunction("BROWSE_GRAPHIC");
089
090    /**
091     * Online resource upload capability provided.
092     *
093     * @since 3.1
094     */
095    @UML(identifier="upload", obligation=CONDITIONAL, specification=ISO_19115)
096    public static final OnLineFunction UPLOAD = new OnLineFunction("UPLOAD");
097
098    /**
099     * Online email service provided.
100     *
101     * @since 3.1
102     */
103    @UML(identifier="emailService", obligation=CONDITIONAL, specification=ISO_19115)
104    public static final OnLineFunction EMAIL_SERVICE = new OnLineFunction("EMAIL_SERVICE");
105
106    /**
107     * Online browsing provided.
108     *
109     * @since 3.1
110     */
111    @UML(identifier="browsing", obligation=CONDITIONAL, specification=ISO_19115)
112    public static final OnLineFunction BROWSING = new OnLineFunction("BROWSING");
113
114    /**
115     * Online file access provided.
116     *
117     * @since 3.1
118     */
119    @UML(identifier="fileAccess", obligation=CONDITIONAL, specification=ISO_19115)
120    public static final OnLineFunction FILE_ACCESS = new OnLineFunction("FILE_ACCESS");
121
122    /**
123     * Constructs an element of the given name.
124     *
125     * @param name  the name of the new element. This name shall not be in use by another element of this type.
126     */
127    private OnLineFunction(final String name) {
128        super(name);
129    }
130
131    /**
132     * Returns the list of {@code OnLineFunction}s.
133     *
134     * @return the list of codes declared in the current JVM.
135     */
136    public static OnLineFunction[] values() {
137        return values(OnLineFunction.class);
138    }
139
140    /**
141     * Returns the list of codes of the same kind as this code list element.
142     * Invoking this method is equivalent to invoking {@link #values()}, except that
143     * this method can be invoked on an instance of the parent {@code CodeList} class.
144     *
145     * @return all code {@linkplain #values() values} for this code list.
146     */
147    @Override
148    public OnLineFunction[] family() {
149        return values();
150    }
151
152    /**
153     * Returns the on line function that matches the given string, or returns a new one if none match it.
154     * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name}
155     * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name.
156     * If no existing instance is found, then a new one is created for the given name.
157     *
158     * @param  code  the name of the code to fetch or to create.
159     * @return a code matching the given name.
160     */
161    public static OnLineFunction valueOf(String code) {
162        return valueOf(OnLineFunction.class, code, OnLineFunction::new).get();
163    }
164}