001/*
002 * ============================================================================
003 *  Copyright © 2002-2020 by Thomas Thrien.
004 *  All Rights Reserved.
005 * ============================================================================
006 *  Licensed to the public under the agreements of the GNU Lesser General Public
007 *  License, version 3.0 (the "License"). You may obtain a copy of the License at
008 *
009 *       http://www.gnu.org/licenses/lgpl.html
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014 *  License for the specific language governing permissions and limitations
015 *  under the License.
016 */
017
018package org.tquadrat.foundation.xml.builder.spi;
019
020import static org.apiguardian.api.API.Status.MAINTAINED;
021import static org.tquadrat.foundation.lang.Objects.requireNonNullArgument;
022
023import java.util.Optional;
024
025import org.apiguardian.api.API;
026import org.tquadrat.foundation.annotation.ClassVersion;
027import org.tquadrat.foundation.xml.builder.Namespace;
028import org.tquadrat.foundation.xml.builder.XMLElementFactory;
029
030/**
031 *  The default implementation of the interface
032 *  {@link XMLElementFactory}.
033 *
034 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
035 *  @version $Id: XMLElementFactoryBase.java 1030 2022-04-06 13:42:02Z tquadrat $
036 *  @since 0.0.5
037 *
038 *  @UMLGraph.link
039 */
040@SuppressWarnings( "AbstractClassWithoutAbstractMethods" )
041@ClassVersion( sourceVersion = "$Id: XMLElementFactoryBase.java 1030 2022-04-06 13:42:02Z tquadrat $" )
042@API( status = MAINTAINED, since = "0.0.5" )
043public abstract non-sealed class XMLElementFactoryBase implements XMLElementFactory
044{
045        /*-----------*\
046    ====** Constants **========================================================
047        \*-----------*/
048    /**
049     *  An empty array of {@code XMLElementFactoryImpl} objects.
050     */
051    public static final XMLElementFactoryBase[] EMPTY_XMLElementFactoryBase_ARRAY = new XMLElementFactoryBase[0];
052
053        /*------------*\
054    ====** Attributes **=======================================================
055        \*------------*/
056    /**
057     *  The namespace that is used by this element factory.
058     */
059    @SuppressWarnings( "OptionalUsedAsFieldOrParameterType" )
060    private final Optional<Namespace> m_Namespace;
061
062        /*--------------*\
063    ====** Constructors **=====================================================
064        \*--------------*/
065    /**
066     *  Creates a new {@code XMLElementFactoryImpl} instance that does not use
067     *  a namespace.
068     */
069    protected XMLElementFactoryBase() { m_Namespace = Optional.empty(); }
070
071    /**
072     *  Creates a new {@code XMLElementFactoryImpl} instance that uses the
073     *  given namespace.
074     *
075     *  @param  namespace   The namespace that is used by this XML element
076     *      factory.
077     */
078    @SuppressWarnings( "UseOfConcreteClass" )
079    protected XMLElementFactoryBase( final Namespace namespace )
080    {
081        m_Namespace = Optional.of( requireNonNullArgument( namespace, "namespace" ) );
082    }   //  XMLElementFactoryImpl()
083
084        /*---------*\
085    ====** Methods **==========================================================
086        \*---------*/
087    /**
088     *  {@inheritDoc}
089     */
090    @Override
091    public final Optional<Namespace> getNamespace() { return m_Namespace; }
092}
093//  class XMLElementFactoryBase
094
095/*
096 *  End of File
097 */