@Test public void testValidRequiredDouble() throws JSONConverterException { JSONObject o = new JSONObject(); o.put("id", 1.3d); Assert.assertEquals(JSONs.requiredDouble(o, "id"), 1.3d); o.put("id", 145); Assert.assertEquals(JSONs.requiredDouble(o, "id"), 145d); }
public static double requiredDouble(JSONObject o, String id) throws JSONConverterException { checkKeys(o, id); Object x = o.get(id); if (!(x instanceof Number)) { throw new JSONConverterException("Number expected at key '" + id + "' but was '" + x.getClass() + "'."); } return ((Number) x).doubleValue(); }
JSONs { public static double requiredDouble(JSONObject o, String id) throws JSONConverterException { checkKeys(o, id); Object x = o.get(id); if (!(x instanceof Number)) { throw new JSONConverterException("Number expected at key '" + id + "' but was '" + x.getClass() + "'."); } return ((Number) x).doubleValue(); } }
JSONs { public static double requiredDouble(JSONObject o, String id) throws JSONConverterException { checkKeys(o, id); Object x = o.get(id); if (!(x instanceof Number)) { throw new JSONConverterException("Number expected at key '" + id + "' but was '" + x.getClass() + "'."); } return ((Number) x).doubleValue(); } private  JSONs(); }
JSONs { public static double requiredDouble(JSONObject o, String id) throws JSONConverterException { checkKeys(o, id); Object x = o.get(id); if (!(x instanceof Number)) { throw new JSONConverterException("Number expected at key '" + id + "' but was '" + x.getClass() + "'."); } return ((Number) x).doubleValue(); } private  JSONs(); static void resetCaches(int size); static int requiredInt(JSONObject o, String id); static int optInt(JSONObject o, String id, int def); static void checkKeys(JSONObject o, String... keys); static String requiredString(JSONObject o, String id); static double requiredDouble(JSONObject o, String id); static boolean requiredBoolean(JSONObject o, String id); static List<VM> vmsFromJSON(Model mo, JSONArray a); static List<Node> nodesFromJSON(Model mo, JSONArray a); static JSONArray vmsToJSON(Collection<VM> s); static JSONArray nodesToJSON(Collection<Node> s); static List<VM> requiredVMs(Model mo, JSONObject o, String id); static List<Node> requiredNodes(Model mo, JSONObject o, String id); static Set<Collection<VM>> requiredVMPart(Model mo, JSONObject o, String id); static Set<Collection<Node>> requiredNodePart(Model mo, JSONObject o, String id); static VM requiredVM(Model mo, JSONObject o, String id); static Node requiredNode(Model mo, JSONObject o, String id); static VM getVM(Model mo, int vmID); static Node getNode(Model mo, int nodeID); static Integer elementToJSON(Element e); }
JSONs { public static double requiredDouble(JSONObject o, String id) throws JSONConverterException { checkKeys(o, id); Object x = o.get(id); if (!(x instanceof Number)) { throw new JSONConverterException("Number expected at key '" + id + "' but was '" + x.getClass() + "'."); } return ((Number) x).doubleValue(); } private  JSONs(); static void resetCaches(int size); static int requiredInt(JSONObject o, String id); static int optInt(JSONObject o, String id, int def); static void checkKeys(JSONObject o, String... keys); static String requiredString(JSONObject o, String id); static double requiredDouble(JSONObject o, String id); static boolean requiredBoolean(JSONObject o, String id); static List<VM> vmsFromJSON(Model mo, JSONArray a); static List<Node> nodesFromJSON(Model mo, JSONArray a); static JSONArray vmsToJSON(Collection<VM> s); static JSONArray nodesToJSON(Collection<Node> s); static List<VM> requiredVMs(Model mo, JSONObject o, String id); static List<Node> requiredNodes(Model mo, JSONObject o, String id); static Set<Collection<VM>> requiredVMPart(Model mo, JSONObject o, String id); static Set<Collection<Node>> requiredNodePart(Model mo, JSONObject o, String id); static VM requiredVM(Model mo, JSONObject o, String id); static Node requiredNode(Model mo, JSONObject o, String id); static VM getVM(Model mo, int vmID); static Node getNode(Model mo, int nodeID); static Integer elementToJSON(Element e);  }