2008-09-01 05:13:32 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Google Inc.
|
|
|
|
*
|
|
|
|
* 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.google.gson;
|
|
|
|
|
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* A class representing a JSON {@code null} value.
|
2008-09-01 05:13:32 +02:00
|
|
|
*
|
|
|
|
* @author Inderjeet Singh
|
|
|
|
* @author Joel Leitch
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
public final class JsonNull extends JsonElement {
|
2011-05-25 09:01:36 +02:00
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* Singleton for {@code JsonNull}.
|
2011-06-03 21:02:28 +02:00
|
|
|
*
|
2011-05-25 09:01:36 +02:00
|
|
|
* @since 1.8
|
|
|
|
*/
|
|
|
|
public static final JsonNull INSTANCE = new JsonNull();
|
2008-09-01 05:13:32 +02:00
|
|
|
|
2008-12-01 00:01:14 +01:00
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* Creates a new {@code JsonNull} object.
|
2022-08-04 19:32:30 +02:00
|
|
|
*
|
2022-09-09 16:32:55 +02:00
|
|
|
* @deprecated Deprecated since Gson version 1.8, use {@link #INSTANCE} instead.
|
2008-12-01 00:01:14 +01:00
|
|
|
*/
|
2011-05-25 09:01:36 +02:00
|
|
|
@Deprecated
|
2008-12-01 00:01:14 +01:00
|
|
|
public JsonNull() {
|
|
|
|
// Do nothing
|
|
|
|
}
|
2011-05-25 09:08:21 +02:00
|
|
|
|
2017-05-31 19:33:37 +02:00
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* Returns the same instance since it is an immutable value.
|
|
|
|
*
|
2017-05-31 19:33:37 +02:00
|
|
|
* @since 2.8.2
|
|
|
|
*/
|
2012-09-03 10:34:37 +02:00
|
|
|
@Override
|
2017-05-31 19:33:37 +02:00
|
|
|
public JsonNull deepCopy() {
|
2012-08-21 03:19:43 +02:00
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
2008-11-14 23:33:39 +01:00
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* All instances of {@code JsonNull} have the same hash code since they are indistinguishable.
|
2008-11-14 23:33:39 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return JsonNull.class.hashCode();
|
|
|
|
}
|
2011-06-03 21:02:28 +02:00
|
|
|
|
2008-11-14 23:33:39 +01:00
|
|
|
/**
|
2022-09-09 16:32:55 +02:00
|
|
|
* All instances of {@code JsonNull} are considered equal.
|
2008-11-14 23:33:39 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
2022-12-06 19:43:08 +01:00
|
|
|
return other instanceof JsonNull;
|
2008-12-01 00:01:14 +01:00
|
|
|
}
|
2008-09-01 05:13:32 +02:00
|
|
|
}
|