001/*
002 *    GeoAPI - Java interfaces for OGC/ISO standards
003 *    Copyright © 2004-2023 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.util;
019
020import java.util.List;
021import java.util.Collections;
022import org.opengis.annotation.UML;
023
024import static org.opengis.annotation.Obligation.*;
025import static org.opengis.annotation.Specification.*;
026
027
028/**
029 * Identifier within a {@linkplain NameSpace name space} for a local object.
030 * Local names are names which are directly accessible to and maintained by a {@link NameSpace}.
031 * Names are local to one and only one name space.
032 * The name space within which they are local is indicated by the {@linkplain #scope() scope}.
033 *
034 * @author  Martin Desruisseaux (IRD)
035 * @author  Bryce Nordgren (USDA)
036 * @version 3.0
037 * @since   2.0
038 *
039 * @see NameFactory#createLocalName(NameSpace, CharSequence)
040 */
041@UML(identifier="LocalName", specification=ISO_19103)
042public interface LocalName extends GenericName {
043    /**
044     * Returns the number of levels specified by this name, which is always 1 for a local name.
045     *
046     * @return always 1 for a local name.
047     */
048    @Override
049    @UML(identifier="depth", obligation=MANDATORY, specification=ISO_19103)
050    default int depth() {
051        return 1;
052    }
053
054    /**
055     * Returns the sequence of local names. Since this object is itself a locale name,
056     * this method always returns a {@linkplain Collections#singletonList(Object) singleton list}
057     * containing only {@code this}.
058     *
059     * @return a singleton containing only {@code this}.
060     */
061    @Override
062    @UML(identifier="parsedName", obligation=MANDATORY, specification=ISO_19103)
063    default List<? extends LocalName> getParsedNames() {
064        return Collections.singletonList(this);
065    }
066
067    /**
068     * Returns {@code this} since this object is already a local name.
069     */
070    @Override
071    default LocalName head() {
072        return this;
073    }
074
075    /**
076     * Returns {@code this} since this object is already a local name.
077     */
078    @Override
079    default LocalName tip() {
080        return this;
081    }
082
083    /**
084     * Returns a locale-independent string representation of this local name.
085     *
086     * @return the local-independent string representation of this name.
087     */
088    @Override
089    @UML(identifier="aName", obligation=MANDATORY, specification=ISO_19103)
090    String toString();
091}