]>
Commit | Line | Data |
---|---|---|
070d3ab2 MG |
1 | /* |
2 | * Copyright (C) 2008 Google Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package com.google.gson; | |
18 | ||
19 | /** | |
20 | * A class representing a Json {@code null} value. | |
21 | * | |
22 | * @author Inderjeet Singh | |
23 | * @author Joel Leitch | |
24 | * @since 1.2 | |
25 | */ | |
26 | public final class JsonNull extends JsonElement { | |
27 | /** | |
28 | * singleton for JsonNull | |
29 | * | |
30 | * @since 1.8 | |
31 | */ | |
32 | public static final JsonNull INSTANCE = new JsonNull(); | |
33 | ||
34 | /** | |
35 | * Creates a new JsonNull object. | |
36 | * Deprecated since Gson version 1.8. Use {@link #INSTANCE} instead | |
37 | */ | |
38 | @Deprecated | |
39 | public JsonNull() { | |
40 | // Do nothing | |
41 | } | |
42 | ||
43 | @Override | |
44 | JsonNull deepCopy() { | |
45 | return INSTANCE; | |
46 | } | |
47 | ||
48 | /** | |
49 | * All instances of JsonNull have the same hash code since they are indistinguishable | |
50 | */ | |
51 | @Override | |
52 | public int hashCode() { | |
53 | return JsonNull.class.hashCode(); | |
54 | } | |
55 | ||
56 | /** | |
57 | * All instances of JsonNull are the same | |
58 | */ | |
59 | @Override | |
60 | public boolean equals(Object other) { | |
61 | return this == other || other instanceof JsonNull; | |
62 | } | |
63 | } |