MCPcopy Index your code
hub / github.com/VolmitSoftware/Adapt / getEnum

Method getEnum

src/main/java/com/volmit/adapt/util/JSONArray.java:237–246  ·  view source on GitHub ↗

Get the enum value associated with an index. @param clazz The type of enum to retrieve. @param index The index must be between 0 and length() - 1. @return The enum value at the index location @throws JSONException if the key is not found or if the value cannot be converted to

(Class<E> clazz, int index)

Source from the content-addressed store, hash-verified

235 * to an enum.
236 */
237 public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
238 E val = optEnum(clazz, index);
239 if (val == null) {
240 // JSONException should really take a throwable argument.
241 // If it did, I would re-implement this with the Enum.valueOf
242 // method and place any thrown exception in the JSONException
243 throw new JSONException("JSONObject[" + JSONObject.quote(Integer.toString(index)) + "] is not an enum of type " + JSONObject.quote(clazz.getSimpleName()) + ".");
244 }
245 return val;
246 }
247
248 /**
249 * Get the BigDecimal value associated with an index.

Callers

nothing calls this directly

Calls 3

optEnumMethod · 0.95
quoteMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected