public static void addOptionalString(JsonObject jsonObject, Map<String, Object> yamlSource, String jsonField, String yamlFieldName) { String value = getOptionalString(yamlSource, yamlFieldName); if (value != null) jsonObject.addProperty(jsonField, value); }
public static void addRequiredString(JsonObject jsonObject, Map<String, Object> yamlSource, String jsonField, String yamlFieldName) { String value = getOptionalString(yamlSource, yamlFieldName); if (value == null) throw new YamlConfigException("String field " + yamlFieldName + ": is required"); jsonObject.addProperty(jsonField, value); }
private void addRunInstances(Map<String, Object> jobMap, JsonObject jobJson) { String runInstancesText = getOptionalString(jobMap, YAML_JOB_RUN_INSTANCES_FIELD); if (runInstancesText != null) { if ("all".equalsIgnoreCase(runInstancesText)) jobJson.addProperty(JSON_JOB_RUN_INSTANCES_FIELD, "all"); else { try { jobJson.addProperty(JSON_JOB_RUN_INSTANCES_FIELD, NumberFormat.getInstance().parse(runInstancesText)); } catch (ParseException e) { throw new YamlConfigException(YAML_JOB_RUN_INSTANCES_FIELD + " must be 'all' or a number", e); } } } }
String git = getOptionalString(materialMap, YAML_SHORT_KEYWORD_GIT); if (git != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "git"); material.addProperty("url", git); String svn = getOptionalString(materialMap, YAML_SHORT_KEYWORD_SVN); if (svn != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "svn"); material.addProperty("url", svn); String hg = getOptionalString(materialMap, YAML_SHORT_KEYWORD_HG); if (hg != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "hg"); material.addProperty("url", hg); String dependency = getOptionalString(materialMap, YAML_SHORT_KEYWORD_DEPENDENCY); if (dependency != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "dependency"); String scm_id = getOptionalString(materialMap, YAML_SHORT_KEYWORD_SCM_ID); if (scm_id != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "plugin"); material.addProperty("scm_id", scm_id); String package_id = getOptionalString(materialMap, YAML_SHORT_KEYWORD_PACKAGE_ID); if (package_id != null) { material.addProperty(JSON_MATERIAL_TYPE_FIELD, "package"); material.addProperty("package_id", package_id);