import org.sonar.api.PropertyType;
import org.sonar.server.exceptions.BadRequestException;
+import javax.annotation.Nullable;
+
import java.util.List;
public class BooleanTypeValidation implements TypeValidation {
}
@Override
- public void validate(String value, List<String> options) {
+ public void validate(String value, @Nullable List<String> options) {
if (!StringUtils.equalsIgnoreCase(value, "true") && !StringUtils.equalsIgnoreCase(value, "false")) {
throw new BadRequestException("errors.type.notBoolean", value);
}
import org.sonar.api.PropertyType;
import org.sonar.server.exceptions.BadRequestException;
+import javax.annotation.Nullable;
+
import java.util.List;
public class IntegerTypeValidation implements TypeValidation {
}
@Override
- public void validate(String value, List<String> options) {
+ public void validate(String value, @Nullable List<String> options) {
if (!NumberUtils.isDigits(value)) {
throw new BadRequestException("errors.type.notInteger", value);
}
import org.sonar.api.PropertyType;
import org.sonar.server.exceptions.BadRequestException;
+import javax.annotation.Nullable;
+
import java.util.List;
public class StringListTypeValidation implements TypeValidation {
}
@Override
- public void validate(String value, List<String> options) {
- if (!options.contains(value)) {
+ public void validate(String value, @Nullable List<String> options) {
+ if (options != null && !options.contains(value)) {
String optionsAsString = StringUtils.join(options, ", ");
throw new BadRequestException("errors.type.notInOptions", value, optionsAsString);
}
import org.sonar.api.PropertyType;
+import javax.annotation.Nullable;
+
import java.util.List;
public class StringTypeValidation implements TypeValidation {
}
@Override
- public void validate(String value, List<String> options) {
+ public void validate(String value, @Nullable List<String> options) {
// Nothing to do
}
import org.sonar.api.PropertyType;
+import javax.annotation.Nullable;
+
import java.util.List;
public class TextTypeValidation implements TypeValidation {
}
@Override
- public void validate(String value, List<String> options) {
+ public void validate(String value, @Nullable List<String> options) {
// Nothing to do
}
@Test
public void not_fail_on_valid_option() {
validation.validate("a", newArrayList("a", "b", "c"));
+ validation.validate("a", null);
}
@Test