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 * Geometric description of the collection.
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_GeometryTypeCode", specification=ISO_19115_2)
037public final class GeometryType extends CodeList<GeometryType> {
038    /**
039     * Serial number for compatibility with different versions.
040     */
041    private static final long serialVersionUID = -8326145457020825352L;
042
043    /**
044     * Single geographic point of interest.
045     */
046    @UML(identifier="point", obligation=CONDITIONAL, specification=ISO_19115_2)
047    public static final GeometryType POINT = new GeometryType("POINT");
048
049    /**
050     * Extended collection in a single vector.
051     */
052    @UML(identifier="linear", obligation=CONDITIONAL, specification=ISO_19115_2)
053    public static final GeometryType LINEAR = new GeometryType("LINEAR");
054
055    /**
056     * Collection of a geographic area defined by a polygon (coverage).
057     */
058    @UML(identifier="areal", obligation=CONDITIONAL, specification=ISO_19115_2)
059    public static final GeometryType AREAL = new GeometryType("AREAL");
060
061    /**
062     * Series of linear collections grouped by way points.
063     */
064    @UML(identifier="strip", obligation=CONDITIONAL, specification=ISO_19115_2)
065    public static final GeometryType STRIP = new GeometryType("STRIP");
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 GeometryType(final String name) {
073        super(name);
074    }
075
076    /**
077     * Returns the list of {@code GeometryType}s.
078     *
079     * @return the list of codes declared in the current JVM.
080     */
081    public static GeometryType[] values() {
082        return values(GeometryType.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 GeometryType[] family() {
094        return values();
095    }
096
097    /**
098     * Returns the geometry type 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 GeometryType valueOf(String code) {
107        return valueOf(GeometryType.class, code, GeometryType::new).get();
108    }
109}