Merge pull request #1512 from Degubi/jsonelement_removebooleanwrapper
Remove package private helpers in JsonElement & JsonPrimitive
This commit is contained in:
commit
62f89ac929
@ -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}.
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user