API Change: Implemented various getAs methods to return null.

This commit is contained in:
Inderjeet Singh 2011-05-25 07:08:21 +00:00
parent 5e2bc1b8f0
commit 540d36e4bd

View File

@ -17,6 +17,8 @@
package com.google.gson;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* A class representing a Json {@code null} value.
@ -35,13 +37,49 @@ public final class JsonNull extends JsonElement {
/**
* Creates a new JsonNull object.
* Deprecated. Use {@link #INSTANCE} instead
* Deprecated since Gson version 1.8. Use {@link #INSTANCE} instead
*/
@Deprecated
public JsonNull() {
// Do nothing
}
/**
* Returns null
* @since 1.8
*/
@Override
public Number getAsNumber() {
return null;
}
/**
* Returns null
* @Since 1.8
*/
@Override
public String getAsString() {
return null;
}
/**
* Returns null
* @Since 1.8
*/
@Override
public BigDecimal getAsBigDecimal() {
return null;
}
/**
* Returns null
* @Since 1.8
*/
@Override
public BigInteger getAsBigInteger() {
return null;
}
@Override
protected void toString(Appendable sb, Escaper escaper) throws IOException {
sb.append("null");