1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

enum support

This commit is contained in:
stleary 2015-07-22 20:16:02 -05:00
parent ca3001629a
commit 9785b4ff0b
2 changed files with 8 additions and 8 deletions

View file

@ -254,7 +254,7 @@ public class JSONArray implements Iterable<Object> {
* The type of enum to retrieve. * The type of enum to retrieve.
* @param index * @param index
* The index must be between 0 and length() - 1. * The index must be between 0 and length() - 1.
* @return The enum value. * @return The enum value at the index location
* @throws JSONException * @throws JSONException
* if the key is not found or if the value cannot be converted * if the key is not found or if the value cannot be converted
* to an enum. * to an enum.
@ -563,7 +563,7 @@ public class JSONArray implements Iterable<Object> {
* The type of enum to retrieve. * The type of enum to retrieve.
* @param index * @param index
* The index must be between 0 and length() - 1. * The index must be between 0 and length() - 1.
* @return The enum value or null if not found * @return The enum value at the index location or null if not found
*/ */
public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) { public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) {
return this.optEnum(clazz, index, null); return this.optEnum(clazz, index, null);
@ -578,8 +578,8 @@ public class JSONArray implements Iterable<Object> {
* The index must be between 0 and length() - 1. * The index must be between 0 and length() - 1.
* @param defaultValue * @param defaultValue
* The default in case the value is not found * The default in case the value is not found
* @return The enum value or defaultValue if the value is not found or * @return The enum value at the index location or defaultValue if
* cannot be assigned to clazz * the value is not found or cannot be assigned to clazz
*/ */
public <E extends Enum<E>> E optEnum(Class<E> clazz, int index, E defaultValue) { public <E extends Enum<E>> E optEnum(Class<E> clazz, int index, E defaultValue) {
try { try {

View file

@ -486,7 +486,7 @@ public class JSONObject {
* The type of enum to retrieve. * The type of enum to retrieve.
* @param key * @param key
* A key string. * A key string.
* @return The enum value. * @return The enum value associated with the key
* @throws JSONException * @throws JSONException
* if the key is not found or if the value cannot be converted * if the key is not found or if the value cannot be converted
* to an enum. * to an enum.
@ -876,7 +876,7 @@ public class JSONObject {
* The type of enum to retrieve. * The type of enum to retrieve.
* @param key * @param key
* A key string. * A key string.
* @return The enum value or null if not found * @return The enum value associated with the key or null if not found
*/ */
public <E extends Enum<E>> E optEnum(Class<E> clazz, String key) { public <E extends Enum<E>> E optEnum(Class<E> clazz, String key) {
return this.optEnum(clazz, key, null); return this.optEnum(clazz, key, null);
@ -891,8 +891,8 @@ public class JSONObject {
* A key string. * A key string.
* @param defaultValue * @param defaultValue
* The default in case the value is not found * The default in case the value is not found
* @return The enum value or defaultValue if the value is not found or * @return The enum value associated with the key or defaultValue
* cannot be assigned to clazz * if the value is not found or cannot be assigned to clazz
*/ */
public <E extends Enum<E>> E optEnum(Class<E> clazz, String key, E defaultValue) { public <E extends Enum<E>> E optEnum(Class<E> clazz, String key, E defaultValue) {
try { try {