private static List<String> validateValues(List<String> values, WebService.Param definition) { Integer maximumValues = definition.maxValuesAllowed(); checkArgument(maximumValues == null || values.size() <= maximumValues, "'%s' can contains only %s values, got %s", definition.key(), maximumValues, values.size()); values.forEach(value -> validatePossibleValues(definition.key(), value, definition)); return values; }
assertThat(organizations.exampleValue()).isEqualTo("my-org-1,foocorp"); assertThat(organizations.since()).isEqualTo("6.3"); assertThat(organizations.maxValuesAllowed()).isEqualTo(500);
private static void writeParam(JsonWriter writer, WebService.Param param) { writer.beginObject(); writer.prop("key", param.key()); writer.prop("description", param.description()); writer.prop("since", param.since()); writer.prop("required", param.isRequired()); writer.prop("internal", param.isInternal()); writer.prop("defaultValue", param.defaultValue()); writer.prop("exampleValue", param.exampleValue()); writer.prop("deprecatedSince", param.deprecatedSince()); writer.prop("deprecatedKey", param.deprecatedKey()); writer.prop("deprecatedKeySince", param.deprecatedKeySince()); writer.prop("maxValuesAllowed", param.maxValuesAllowed()); ofNullable(param.possibleValues()).ifPresent(possibleValues -> writer.name("possibleValues").beginArray().values(possibleValues).endArray()); ofNullable(param.maximumLength()).ifPresent(maximumLength -> writer.prop("maximumLength", maximumLength)); ofNullable(param.minimumLength()).ifPresent(minimumLength -> writer.prop("minimumLength", minimumLength)); ofNullable(param.maximumValue()).ifPresent(maximumValue -> writer.prop("maximumValue", maximumValue)); writer.endObject(); }
private static void writeParam(JsonWriter writer, WebService.Param param) { writer.beginObject(); writer.prop("key", param.key()); writer.prop("description", param.description()); writer.prop("since", param.since()); writer.prop("required", param.isRequired()); writer.prop("internal", param.isInternal()); writer.prop("defaultValue", param.defaultValue()); writer.prop("exampleValue", param.exampleValue()); writer.prop("deprecatedSince", param.deprecatedSince()); writer.prop("deprecatedKey", param.deprecatedKey()); writer.prop("deprecatedKeySince", param.deprecatedKeySince()); writer.prop("maxValuesAllowed", param.maxValuesAllowed()); ofNullable(param.possibleValues()).ifPresent(possibleValues -> writer.name("possibleValues").beginArray().values(possibleValues).endArray()); ofNullable(param.maximumLength()).ifPresent(maximumLength -> writer.prop("maximumLength", maximumLength)); ofNullable(param.minimumLength()).ifPresent(minimumLength -> writer.prop("minimumLength", minimumLength)); ofNullable(param.maximumValue()).ifPresent(maximumValue -> writer.prop("maximumValue", maximumValue)); writer.endObject(); }
private static List<String> validateValues(List<String> values, WebService.Param definition) { Integer maximumValues = definition.maxValuesAllowed(); checkArgument(maximumValues == null || values.size() <= maximumValues, "'%s' can contains only %s values, got %s", definition.key(), maximumValues, values.size()); values.forEach(value -> validatePossibleValues(definition.key(), value, definition)); return values; }
assertThat(severityParam.defaultValue()).isEqualTo("MAJOR"); assertThat(severityParam.possibleValues()).containsOnly("INFO", "MAJOR", "BLOCKER"); assertThat(severityParam.maxValuesAllowed()).isEqualTo(10);