private void populatePromotionParameters(List<String> params, Object promotionObj) { final Promotion promotion = (Promotion) promotionObj; for (ParameterValue value : promotion.getParameterValues()) { if (value instanceof StringParameterValue) { if (StringUtils.isNotBlank(((StringParameterValue) value).value)) { params.add("<strong>" + value.getName() + "</strong>: " + ((StringParameterValue) value).value); } } else if (value instanceof FileParameterValue) { params.add("<strong>" + value.getName() + "</strong>: " + ((FileParameterValue) value).getLocation()); } else if (value instanceof BooleanParameterValue) { if (((BooleanParameterValue) value).value) { params.add("<strong>" + value.getName() + "</strong>: " + Boolean.toString(((BooleanParameterValue) value).value)); } } // TODO: there are more types } }
private static ParameterValue getBooleanParam(JSONObject formData, String paramName) { JSONObject paramObj = JSONObject.fromObject(formData.get(paramName)); String name = paramObj.getString("name"); FlakyTestResultAction.logger.log(Level.FINE, "Param: " + name + " with value: " + paramObj.getBoolean("value")); return new BooleanParameterValue(name, paramObj.getBoolean("value")); }
@Override public ParameterDefinition copyWithDefaultValue(ParameterValue defaultValue) { if(defaultValue instanceof BooleanParameterValue) { BooleanParameterValue value = (BooleanParameterValue)defaultValue; return new PersistentBooleanParameterDefinition(getName(), value.value, isSuccessfulOnly(), getDescription()); } else { return this; } }
@Override public ParameterValue createValue(StaplerRequest req, JSONObject jo) { BooleanParameterValue value = req.bindJSON(BooleanParameterValue.class, jo); value.setDescription(getDescription()); return value; }
public ParameterValue createValue(String value) { return new BooleanParameterValue(getName(), Boolean.valueOf(value), getDescription()); }
@Override public BooleanParameterValue getDefaultParameterValue() { return new BooleanParameterValue(getName(), isDefaultValue(), getDescription()); }