private Enum<Enum.EnumKey> convertToOsEnum(JSONObject json, Class<?> enumKeyType) { Enum<Enum.EnumKey> value; String val = Enum.Field.VALUE.toString(); String display = Enum.Field.DISPLAY_VALUE.toString(); if (json.has(val)) { Enum.EnumKey enumKey; try { enumKey = (Enum.EnumKey) enumKeyType.getField(json.optString(val)).get(null); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String displayValue = null; if (json.has(display)) { displayValue = json.optString(display); } value = new EnumImpl<Enum.EnumKey>(enumKey,displayValue); } else { value = new EnumImpl<Enum.EnumKey>(null, json.optString(display)); } return value; }
private Enum<Enum.EnumKey> convertToOsEnum(JSONObject json, Class<?> enumKeyType) { Enum<Enum.EnumKey> value; String val = Enum.Field.VALUE.toString(); String display = Enum.Field.DISPLAY_VALUE.toString(); if (json.has(val)) { Enum.EnumKey enumKey; try { enumKey = (Enum.EnumKey) enumKeyType.getField(json.optString(val)).get(null); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String displayValue = null; if (json.has(display)) { displayValue = json.optString(display); } value = new EnumImpl<Enum.EnumKey>(enumKey,displayValue); } else { value = new EnumImpl<Enum.EnumKey>(null, json.optString(display)); } return value; }
private Enum<Enum.EnumKey> convertToOsEnum(JSONObject json, Class<?> enumKeyType) { Enum<Enum.EnumKey> value; String val = Enum.Field.VALUE.toString(); String display = Enum.Field.DISPLAY_VALUE.toString(); if (json.has(val)) { Enum.EnumKey enumKey; try { enumKey = (Enum.EnumKey) enumKeyType.getField(json.optString(val)).get(null); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String displayValue = null; if (json.has(display)) { displayValue = json.optString(display); } value = new EnumImpl<Enum.EnumKey>(enumKey,displayValue); } else { value = new EnumImpl<Enum.EnumKey>(null, json.optString(display)); } return value; }
private Enum<Enum.EnumKey> convertToOsEnum(JSONObject json, Class<?> enumKeyType) { Enum<Enum.EnumKey> value; String val = Enum.Field.VALUE.toString(); String display = Enum.Field.DISPLAY_VALUE.toString(); if (json.has(val)) { Enum.EnumKey enumKey; try { enumKey = (Enum.EnumKey) enumKeyType.getField(json.optString(val)).get(null); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String displayValue = null; if (json.has(display)) { displayValue = json.optString(display); } value = new EnumImpl<Enum.EnumKey>(enumKey,displayValue); } else { value = new EnumImpl<Enum.EnumKey>(null, json.optString(display)); } return value; }
private Enum<Enum.EnumKey> convertToOsEnum(JSONObject json, Class<?> enumKeyType) { Enum<Enum.EnumKey> value; String val = Enum.Field.VALUE.toString(); String display = Enum.Field.DISPLAY_VALUE.toString(); if (json.has(val)) { Enum.EnumKey enumKey; try { enumKey = (Enum.EnumKey) enumKeyType.getField(json.optString(val)).get(null); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String displayValue = null; if (json.has(display)) { displayValue = json.optString(display); } value = new EnumImpl<Enum.EnumKey>(enumKey,displayValue); } else { value = new EnumImpl<Enum.EnumKey>(null, json.optString(display)); } return value; }