dev.mccue.json.JsonNull Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json Show documentation
Show all versions of json Show documentation
A Java JSON Library intended to be easy to learn and simple to teach.
The newest version!
package dev.mccue.json;
import dev.mccue.json.internal.ValueCandidate;
import dev.mccue.json.serialization.JsonSerializationProxy;
import dev.mccue.json.stream.JsonGenerator;
import java.io.Serial;
/**
* Represents null in the json data model.
*
* @author Ethan McCue
*/
@ValueCandidate
public final class JsonNull implements Json {
@Serial
private static final long serialVersionUID = 1L;
private static final JsonNull INSTANCE = new JsonNull();
private JsonNull() {}
/**
* Returns an instance of {@link JsonNull}. Guaranteed to be comparable with ==,
* but not to be safe for identity sensitive operations.
*
* @return An instance of {@link JsonNull}
*/
public static JsonNull instance() {
return INSTANCE;
}
@Override
public java.lang.String toString() {
return "null";
}
@Serial
private Object writeReplace() {
return new JsonSerializationProxy(Json.writeString(this));
}
@Serial
private Object readResolve() {
throw new IllegalStateException();
}
@Override
public void write(JsonGenerator generator) {
generator.writeNull();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy