Merge pull request #1512 from Degubi/jsonelement_removebooleanwrapper

Remove package private helpers in JsonElement & JsonPrimitive
This commit is contained in:
Jake Wharton 2019-04-14 17:58:42 -04:00 committed by GitHub
commit 62f89ac929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 28 deletions

View File

@ -153,19 +153,6 @@ public abstract class JsonElement {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
/**
* convenience method to get this element as a {@link Boolean} value.
*
* @return get this element as a {@link Boolean} value.
* @throws ClassCastException if the element is of not a {@link JsonPrimitive} and is not a valid
* boolean value.
* @throws IllegalStateException if the element is of the type {@link JsonArray} but contains
* more than a single element.
*/
Boolean getAsBooleanWrapper() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
/**
* convenience method to get this element as a {@link Number}.
*

View File

@ -91,16 +91,6 @@ public final class JsonPrimitive extends JsonElement {
return value instanceof Boolean;
}
/**
* convenience method to get this element as a {@link Boolean}.
*
* @return get this element as a {@link Boolean}.
*/
@Override
Boolean getAsBooleanWrapper() {
return (Boolean) value;
}
/**
* convenience method to get this element as a boolean value.
*
@ -109,11 +99,10 @@ public final class JsonPrimitive extends JsonElement {
@Override
public boolean getAsBoolean() {
if (isBoolean()) {
return getAsBooleanWrapper().booleanValue();
} else {
// Check to see if the value as a String is "true" in any case.
return Boolean.parseBoolean(getAsString());
return ((Boolean) value).booleanValue();
}
// Check to see if the value as a String is "true" in any case.
return Boolean.parseBoolean(getAsString());
}
/**
@ -155,7 +144,7 @@ public final class JsonPrimitive extends JsonElement {
if (isNumber()) {
return getAsNumber().toString();
} else if (isBoolean()) {
return getAsBooleanWrapper().toString();
return ((Boolean) value).toString();
} else {
return (String) value;
}