com.helger.json.IJsonValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ph-json Show documentation
Show all versions of ph-json Show documentation
JSON reader and writer libary
/*
* Copyright (C) 2014-2024 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.json;
import java.io.IOException;
import java.io.Writer;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.helger.commons.traits.IGetterDirectTrait;
import com.helger.json.valueserializer.IJsonValueSerializer;
/**
* Base interface for a single JSON value
*
* @author Philip Helger
*/
public interface IJsonValue extends IJson, IGetterDirectTrait
{
/**
* @return The contained native object value. May be null
.
*/
@Nullable
Object getValue ();
/**
* @return true
if the value is of type {@link Boolean}.
*/
boolean isBooleanValue ();
/**
* @return true
if the value is of type {@link BigInteger},
* {@link Integer} or {@link Long}.
*/
boolean isIntValue ();
/**
* @return true
if the value is of type {@link BigDecimal} or
* {@link Double}.
*/
boolean isDecimalValue ();
/**
* @return true
if the value is of type {@link String}.
*/
boolean isStringValue ();
/**
* @return The serializer to be used. Never null
.
*/
@Nonnull
IJsonValueSerializer getValueSerializer ();
/**
* Append this value in JSON notation to the passed {@link Writer}. This is a
* shortcut for
* getValueSerializer ().appendAsJsonString (getValue (), aWriter);
*
* @param aWriter
* The destination. May not be null
.
* @throws IOException
* in case of a write error
*/
void appendAsJsonString (@Nonnull Writer aWriter) throws IOException;
@Nonnull
IJsonValue getClone ();
}