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.distribution;
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 * Method used to write to the medium.
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=7)
037@UML(identifier="MD_MediumFormatCode", specification=ISO_19115)
038public final class MediumFormat extends CodeList<MediumFormat> {
039    /**
040     * Serial number for compatibility with different versions.
041     */
042    private static final long serialVersionUID = 413822250362716958L;
043
044    /**
045     * CoPy In / Out (UNIX file format and command).
046     */
047    @UML(identifier="cpio", obligation=CONDITIONAL, specification=ISO_19115)
048    public static final MediumFormat CPIO = new MediumFormat("CPIO");
049
050    /**
051     * Tap ARchive.
052     */
053    @UML(identifier="tar", obligation=CONDITIONAL, specification=ISO_19115)
054    public static final MediumFormat TAR = new MediumFormat("TAR");
055
056    /**
057     * High Sierra file system.
058     */
059    @UML(identifier="highSierra", obligation=CONDITIONAL, specification=ISO_19115)
060    public static final MediumFormat HIGH_SIERRA = new MediumFormat("HIGH_SIERRA");
061
062    /**
063     * Information processing - volume and file structure of CD-ROM.
064     */
065    @UML(identifier="iso9660", obligation=CONDITIONAL, specification=ISO_19115)
066    public static final MediumFormat ISO_9660 = new MediumFormat("ISO_9660");
067
068    /**
069     * Rock Ridge interchange protocol (UNIX).
070     */
071    @UML(identifier="iso9660RockRidge", obligation=CONDITIONAL, specification=ISO_19115)
072    public static final MediumFormat ISO_9660_ROCK_RIDGE = new MediumFormat("ISO_9660_ROCK_RIDGE");
073
074    /**
075     * Hierarchical File System (Macintosh).
076     */
077    @UML(identifier="iso9660AppleHFS", obligation=CONDITIONAL, specification=ISO_19115)
078    public static final MediumFormat ISO_9660_APPLE_HFS = new MediumFormat("ISO_9660_APPLE_HFS");
079
080    /**
081     * Universal Disk Format.
082     *
083     * @since 3.1
084     */
085    @UML(identifier="udf", obligation=CONDITIONAL, specification=ISO_19115)
086    public static final MediumFormat UDF = new MediumFormat("UDF");
087
088    /**
089     * Constructs an element of the given name.
090     *
091     * @param name  the name of the new element. This name shall not be in use by another element of this type.
092     */
093    private MediumFormat(final String name) {
094        super(name);
095    }
096
097    /**
098     * Returns the list of {@code MediumFormat}s.
099     *
100     * @return the list of codes declared in the current JVM.
101     */
102    public static MediumFormat[] values() {
103        return values(MediumFormat.class);
104    }
105
106    /**
107     * Returns the list of codes of the same kind as this code list element.
108     * Invoking this method is equivalent to invoking {@link #values()}, except that
109     * this method can be invoked on an instance of the parent {@code CodeList} class.
110     *
111     * @return all code {@linkplain #values() values} for this code list.
112     */
113    @Override
114    public MediumFormat[] family() {
115        return values();
116    }
117
118    /**
119     * Returns the medium format that matches the given string, or returns a new one if none match it.
120     * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name}
121     * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name.
122     * If no existing instance is found, then a new one is created for the given name.
123     *
124     * @param  code  the name of the code to fetch or to create.
125     * @return a code matching the given name.
126     */
127    public static MediumFormat valueOf(String code) {
128        return valueOf(MediumFormat.class, code, MediumFormat::new).get();
129    }
130}