001/*
002 * ============================================================================
003 *  Copyright © 2002-2026 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.jsonbuilder;
019
020import static org.apiguardian.api.API.Status.STABLE;
021
022import java.util.Formatter;
023
024import org.apiguardian.api.API;
025import org.tquadrat.foundation.annotation.ClassVersion;
026
027/**
028 *  <p>{@summary The representation of the JSON literals.} These are</p>
029 *  <ul>
030 *      <li>{@link #NULL NULL}</li>
031 *      <li>{@link #TRUE TRUE}</li>
032 *      <li>{@link #FALSE FALSE}</li>
033 *  </ul>
034 *
035 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
036 *  @version $Id: JSONLiteral.java 1258 2026-06-04 18:33:06Z tquadrat $
037 *  @since 0.1.0
038 *
039 *  @UMLGraph.link
040 */
041@ClassVersion( sourceVersion = "$Id: JSONLiteral.java 1258 2026-06-04 18:33:06Z tquadrat $" )
042@API( status = STABLE, since = "0.1.0" )
043public enum JSONLiteral implements JSONValue
044{
045        /*------------------*\
046    ====** Enum Definitions **=================================================
047        \*------------------*/
048    /**
049     *  Represents the JSON literal {@null}.
050     */
051    NULL( "null" )
052    {
053        /**
054         *  {@inheritDoc}
055         */
056        @Override
057        public final boolean isNull() { return true; }
058    },
059
060    /**
061     *  Represents the JSON literal {@true}.
062     */
063    TRUE( "true" )
064    {
065        /**
066         *  {@inheritDoc}
067         */
068        @Override
069        public final boolean isTrue() { return true; }
070    },
071
072    /**
073     *  Represents the JSON literal {@false}.
074     */
075    FALSE( "false" )
076    {
077        /**
078         *  {@inheritDoc}
079         */
080        @Override
081        public final boolean isFalse() { return true; }
082    };
083
084        /*------------*\
085    ====** Attributes **=======================================================
086        \*------------*/
087    /**
088     *  The value for the literal.
089     */
090    private final String m_Value;
091
092        /*--------------*\
093    ====** Constructors **=====================================================
094        \*--------------*/
095    /**
096     *  Creates a new instance of {@code JSONLiteral}.
097     *
098     *  @param  value   The value.
099     */
100    private JSONLiteral( final String value )
101    {
102        m_Value = value;
103    }   //  JSONLiteral()
104
105        /*---------*\
106    ====** Methods **==========================================================
107        \*---------*/
108    /**
109     * {@inheritDoc}
110     */
111    @Override
112    public final void formatTo( final Formatter formatter, final int flags, final int width, final int precision )
113    {
114        formatter.format( m_Value );
115    }   //  formatTo()
116
117    /**
118     * {@inheritDoc}
119     */
120    @Override
121    public final boolean isBoolean() { return isFalse() || isTrue(); }
122
123    /**
124     * {@inheritDoc}
125     */
126    @Override
127    public final String toString() { return m_Value; }
128}
129//  enum JSONLiteral
130
131/*
132 *  End of File
133 */