choices.forEach(json -> max.set(Math.max(max.get(), ((JSONObject) json).getDouble(c)))); return a.put(new JSONObject().put(aggregator_as, max.get())); choices.forEach(json -> min.set(Math.min(min.get(), ((JSONObject) json).getDouble(c)))); return a.put(new JSONObject().put(aggregator_as, min.get())); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get())); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get() / choices.length())); if (aggregator.startsWith("PERCENT(") && aggregator.endsWith(")")) { final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(8, aggregator.length() - 1); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); choices.forEach(json -> a.put(new JSONObject() .put(aggregator_as, 100.0d * ((JSONObject) json).getDouble(c) / sum.get()) .put(column_as, ((JSONObject) json).get(column_final))));
public String toString() { StringBuffer sb = new StringBuffer(); this.array.forEach(entry -> sb.append(entry.toString()).append("\n")); return sb.toString(); }
/** * To be able to apply (re-)actions to this thought, the actions on the information can be retrieved. * @return the (re-)actions which are applicable to this thought. */ public List<SusiAction> getActions() { List<SusiAction> actions = new ArrayList<>(); getActionsJSON().forEach(action -> actions.add(new SusiAction((JSONObject) action))); return actions; }
public List<Action> getActions() { List<Action> actions = new ArrayList<>(); getActionsJSON().forEach(action -> actions.add(new Action((JSONObject) action))); return actions; }
@SuppressWarnings("unchecked") public List<Peer> getMCPServiceList() { Set<String> failstubs = new HashSet<>(); JSONArray ja = null; loop: for (Set<String> a: new Set[]{mcpActiveAddresses, mcpPassiveAddresses}) { for (String hostprotocolstub: a) { try { ServiceResponse response = APIServer.getAPI(ServicesService.NAME).serviceImpl(hostprotocolstub, new JSONObject()); ja = response.getArray(); break loop; } catch (IOException e) { failstubs.add(hostprotocolstub); } } } removeMCP(failstubs); List<Peer> list = new ArrayList<>(); if (ja == null) return list; ja.forEach(j -> list.add(new Peer((JSONObject) j))); return list; }
/** * We add all of updates from longpoll server * to queue * * @param elements Array of updates */ void putAll(JSONArray elements) { elements.forEach(item -> updates.add((JSONArray) item)); }
public List<JSONObject> getRequestNodes() { List<JSONObject> obj = new ArrayList<>(); this.requests.getJSONArray("nodes").forEach(element -> obj.add((JSONObject) element)); return obj; }
public List<JSONObject> getResponseNodes(){ List<JSONObject> obj = new ArrayList<>(); this.responses.getJSONArray("nodes").forEach(element -> obj.add((JSONObject) element)); return obj; }
public List<JSONArray> getRequestEdges() { List<JSONArray> obj = new ArrayList<>(); this.requests.getJSONArray("edges").forEach(element -> obj.add((JSONArray) element)); return obj; }
public List<JSONArray> getResponseEdges(){ List<JSONArray> obj = new ArrayList<>(); this.responses.getJSONArray("edges").forEach(element -> obj.add((JSONArray) element)); return obj; }
/** The threshold list of the blunder winrate */ public Optional<List<Double>> blunderWinrateThresholds() { String key = "blunder-winrate-thresholds"; Optional<JSONArray> array = Optional.ofNullable(config.optJSONArray(key)); if (!array.isPresent()) { array = Optional.ofNullable(uiConfig.optJSONArray(key)); } array.ifPresent( m -> { blunderWinrateThresholds = Optional.of(new ArrayList<Double>()); m.forEach(a -> blunderWinrateThresholds.get().add(new Double(a.toString()))); }); return blunderWinrateThresholds; }
/** * Constructor for initializing from a JSON Object. Supports both 1.3-m5 and older 1.3-xx json formats. 1.3-m5 and * newer format: {"id": ENSEMBL_Id [[, "gene": HGNC_Symbol] , ...] } 1.3-old format: {"gene": HGNC_Symbol [, ...] } * * @param geneJson JSON object that holds gene details info */ public PhenoTipsGene(JSONObject geneJson) { this(geneJson.optString(ID), geneJson.optString(SYMBOL_KEY), geneJson.optString(STATUS_KEY), null, geneJson .optString(COMMENTS_KEY)); JSONArray strategyArray = geneJson.optJSONArray(STRATEGY_KEY); if (strategyArray != null) { List<String> strategies = new LinkedList<>(); strategyArray.forEach(item -> strategies.add(item.toString())); this.setStrategy(strategies); } }
/** * Gets all available Runtimes */ private List<IOSRuntime> getAllRuntimes() throws IOException, InterruptedException { CommandPromptUtil commandPromptUtil = new CommandPromptUtil(); String runtimesJSONString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j runtimes"); JSONArray runtimesJSON = new JSONObject(runtimesJSONString).getJSONArray("runtimes"); List<IOSRuntime> IOSRuntimes = new ArrayList<>(); runtimesJSON.forEach(runtime -> { IOSRuntimes.add(new IOSRuntime((JSONObject) runtime)); }); return IOSRuntimes; }
/** * Gets all available DeviceType */ private List<DeviceType> getAllDeviceTypes() throws IOException, InterruptedException { CommandPromptUtil commandPromptUtil = new CommandPromptUtil(); String deviceTypesJSONString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j devicetypes"); JSONObject devicesTypesJSON = new JSONObject(deviceTypesJSONString); JSONArray devicesTypes = devicesTypesJSON.getJSONArray("devicetypes"); List<DeviceType> deviceTypes = new ArrayList<>(); devicesTypes.forEach(deviceType -> { String name = ((JSONObject) deviceType).getString("name"); String identifier = ((JSONObject) deviceType).getString("identifier"); deviceTypes.add(new DeviceType(name, identifier)); }); return deviceTypes; }
/** * Gets all available Simulators */ public List<Device> getAllAvailableSimulators() throws IOException, InterruptedException { CommandPromptUtil commandPromptUtil = new CommandPromptUtil(); String simulatorJsonString = commandPromptUtil.runCommandThruProcess("xcrun simctl list -j devices"); JSONObject simulatorsJson = new JSONObject(simulatorJsonString); JSONObject devicesByTypeJson = (JSONObject) simulatorsJson.get("devices"); Iterator<String> keys = devicesByTypeJson.keys(); List<Device> deviceList = new ArrayList<>(); while (keys.hasNext()) { String key = keys.next(); JSONArray devicesJson = (JSONArray) devicesByTypeJson.get(key); devicesJson.forEach(deviceJson -> { deviceList.add(new Device((JSONObject) deviceJson, key)); }); } return deviceList; }
public static MediaContainer fromJson(JSONObject json) { MediaContainer container = new MediaContainer(); try { container.size = json.getInt("size"); } catch (JSONException e) { container.size = 0; } List<Video> videos = new ArrayList<>(); try { JSONArray videoArray = json.getJSONArray("Metadata"); videoArray.forEach(object -> { videos.add(Video.fromJson((JSONObject) object)); }); } catch (JSONException e) { try { //not an array, but a single object videos.add(Video.fromJson(json.getJSONObject("Video"))); } catch (JSONException e2) { //doesn't exist } } container.videos = videos; return container; }
issueNodes.forEach(issueNode -> { JSONObject issue = (JSONObject) issueNode; String closedOn = issue.getString("closed_at");
responseObj.getJSONArray("values").forEach(obj -> { JSONObject b = (JSONObject) obj; SourceCodeBranch branch = new SourceCodeBranch();
responseObj.getJSONArray("values").forEach(obj -> { BitbucketRepository bbr = new BitbucketRepository(); JSONObject rep = (JSONObject) obj;