Accept the same boolean values in RestRequest

Added `no` as a possible value to `paramBooleanAsOptional`, also reused existing code from `Booleans.parseBoolean`

Closes #4808
This commit is contained in:
Luca Cavanna 2014-01-20 13:11:59 +01:00
parent 7129b9e6e6
commit 32428bf683
1 changed files with 1 additions and 5 deletions

View File

@ -136,11 +136,7 @@ public abstract class RestRequest implements ToXContent.Params {
@Override
public Boolean paramAsBooleanOptional(String key, Boolean defaultValue) {
String sValue = param(key);
if (sValue == null) {
return defaultValue;
}
return !(sValue.equals("false") || sValue.equals("0") || sValue.equals("off"));
return Booleans.parseBoolean(param(key), defaultValue);
}
public TimeValue paramAsTime(String key, TimeValue defaultValue) {