Java Code Examples for com.google.gson.JsonArray#addAll()
The following examples show how to use
com.google.gson.JsonArray#addAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java From Prism4j with Apache License 2.0 | 6 votes |
@NotNull private static JsonArray simplify(@NotNull List<? extends Prism4j.Node> nodes) { // root array final JsonArray array = new JsonArray(); for (Prism4j.Node node : nodes) { if (node instanceof Prism4j.Text) { final String literal = ((Prism4j.Text) node).literal(); if (literal.trim().length() != 0) { array.add(literal); } } else { final Prism4j.Syntax syntax = (Prism4j.Syntax) node; final JsonArray inner = new JsonArray(); inner.add(syntax.type()); if (syntax.tokenized()) { inner.add(simplify(syntax.children())); } else { inner.addAll(simplify(syntax.children())); } array.add(inner); } } return array; }
Example 2
Source File: ElasticSearchReportPreprocessor.java From vind with Apache License 2.0 | 6 votes |
private JsonArray extractFilterFields(JsonElement filters) { final JsonArray fs = new JsonArray(); //Single filter object or a list of filters if (filters.isJsonObject()) { fs.add(filters.getAsJsonObject()); } else { fs.addAll(filters.getAsJsonArray()); } return Streams.stream(fs.iterator()) .map(JsonElement::getAsJsonObject) .flatMap( jo -> { if (jo.has("delegates")){ return Streams.stream(extractFilterFields(jo.get("delegates")).iterator()); } else { return Stream.of(jo); } }) .filter( f -> ! environmentFilters.contains(f)) .filter( f -> ! systemFieldFilters.contains(f.getAsJsonObject().get("field").getAsString())) .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); }
Example 3
Source File: ElasticSearchReportPreprocessor.java From vind with Apache License 2.0 | 6 votes |
private Boolean equalFilters(JsonElement fs1, JsonElement fs2) { //Prepare element 1 final JsonArray filters1 = new JsonArray(); if (fs1.isJsonObject()) { filters1.add(fs1.getAsJsonObject()); } else { filters1.addAll(fs1.getAsJsonArray()); } //Prepare element 2 final JsonArray filters2 = new JsonArray(); if (fs2.isJsonObject()) { filters2.add(fs2.getAsJsonObject()); } else { filters2.addAll(fs2.getAsJsonArray()); } return equalFilters(filters1,filters2); }
Example 4
Source File: JsonOps.java From DataFixerUpper with MIT License | 5 votes |
@Override public DataResult<JsonElement> mergeToList(final JsonElement list, final JsonElement value) { if (!(list instanceof JsonArray) && list != empty()) { return DataResult.error("mergeToList called with not a list: " + list, list); } final JsonArray result = new JsonArray(); if (list != empty()) { result.addAll(list.getAsJsonArray()); } result.add(value); return DataResult.success(result); }
Example 5
Source File: JsonOps.java From DataFixerUpper with MIT License | 5 votes |
@Override public DataResult<JsonElement> mergeToList(final JsonElement list, final List<JsonElement> values) { if (!(list instanceof JsonArray) && list != empty()) { return DataResult.error("mergeToList called with not a list: " + list, list); } final JsonArray result = new JsonArray(); if (list != empty()) { result.addAll(list.getAsJsonArray()); } values.forEach(result::add); return DataResult.success(result); }
Example 6
Source File: MergeArraysService.java From cs-actions with Apache License 2.0 | 5 votes |
public @NotNull Map<String, String> execute(@NotNull MergeArraysInput input) { List<RuntimeException> validationErrs = this.validator.validate(input); if (!validationErrs.isEmpty()) { throw validationErrs.get(0); } JsonArray mergedArray = new JsonArray(); mergedArray.addAll(input.getArray1()); mergedArray.addAll(input.getArray2()); String returnResult = mergedArray.toString(); return OutputUtilities.getSuccessResultsMap(returnResult); }
Example 7
Source File: TalosProducer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
private void pushMetricData() { JsonArray jsonArray = new JsonArray(); for (Map.Entry<Integer, PartitionSender> entry : partitionSenderMap.entrySet()) { jsonArray.addAll(entry.getValue().getFalconData()); } falconWriter.pushFaclonData(jsonArray.toString()); }
Example 8
Source File: TalosConsumer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
private void pushMetricData() { JsonArray jsonArray = new JsonArray(); for (Map.Entry<Integer, PartitionFetcher> entry : partitionFetcherMap.entrySet()) { jsonArray.addAll(entry.getValue().getFalconData()); } falconWriter.pushFaclonData(jsonArray.toString()); }
Example 9
Source File: GreedyConsumer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
private void pushMetricData() { JsonArray jsonArray = new JsonArray(); for (Map.Entry<Integer, GreedyPartitionFetcher> entry : partitionFetcherMap.entrySet()) { jsonArray.addAll(entry.getValue().getFalconData()); } jsonArray.addAll(getPartitionLag()); falconWriter.pushFaclonData(jsonArray.toString()); }
Example 10
Source File: OperatorGenerator.java From streamsx.topology with Apache License 2.0 | 4 votes |
private void paramClause(JsonObject graphConfig, JsonObject op, StringBuilder sb) { // VMArgs only apply to Java SPL operators. boolean isJavaOp = OpProperties.LANGUAGE_JAVA.equals(jstring(op, OpProperties.LANGUAGE)); JsonArray vmArgs = null; if (isJavaOp && graphConfig.has(ContextProperties.VMARGS)) vmArgs = GsonUtilities.array(graphConfig, ContextProperties.VMARGS); // determine if we need to inject submission param names and values // info. boolean addSPInfo = false; ParamsInfo stvOpParamInfo = stvHelper.getSplInfo(); if (stvOpParamInfo != null) { if (MODEL_FUNCTIONAL.equals(jstring(op, MODEL))) addSPInfo = true; } JsonObject params = jobject(op, "parameters"); if (vmArgs == null && GsonUtilities.jisEmpty(params) && !addSPInfo) { return; } sb.append(" param\n"); for (Entry<String, JsonElement> on : params.entrySet()) { String name = on.getKey(); JsonObject param = on.getValue().getAsJsonObject(); if ("vmArg".equals(name)) { JsonArray fullVmArgs = new JsonArray(); fullVmArgs.addAll(GsonUtilities.array(param, "value")); if (vmArgs != null) fullVmArgs.addAll(vmArgs); // stringArray(param, "value", v -> fullVmArgs.); // objectArray(graphConfig, ContextProperties.VMARGS, v -> // fullVmArgs.add(v)); vmArgs = fullVmArgs; continue; } sb.append(" "); sb.append(name); sb.append(": "); splValueSupportingSubmission(param, sb); sb.append(";\n"); } if (vmArgs != null) { JsonObject tmpVMArgParam = new JsonObject(); tmpVMArgParam.add("value", vmArgs); sb.append(" "); sb.append("vmArg"); sb.append(": "); splValueSupportingSubmission(tmpVMArgParam, sb); sb.append(";\n"); } if (addSPInfo) { sb.append(" "); sb.append(FunctionalOpProperties.NAME_SUBMISSION_PARAM_NAMES); sb.append(": "); sb.append(stvOpParamInfo.names); sb.append(";\n"); sb.append(" "); sb.append(FunctionalOpProperties.NAME_SUBMISSION_PARAM_VALUES); sb.append(": "); sb.append(stvOpParamInfo.values); sb.append(";\n"); } }
Example 11
Source File: TaggerJsonOutputAdapter.java From AIDR with GNU Affero General Public License v3.0 | 4 votes |
public JsonArray getNominalLabels() { JsonArray arr = new JsonArray(); if (nominal_labels != null) arr.addAll(nominal_labels); return arr; }