Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.jersey.params;

A parameter encapsulating boolean values. If the query parameter value is "true", regardless of case, the returned value is java.lang.Boolean.TRUE. If the query parameter value is "false", regardless of case, the returned value is java.lang.Boolean.FALSE. All other values will return a 400 Bad Request response.
 
 public class BooleanParam extends AbstractParam<Boolean> {
    public BooleanParam(String input) {
        super(input);
    }
    @Override
    protected String errorMessage(String inputException e) {
        return '"' + input + "\" must be \"true\" or \"false\".";
    }
    @Override
    protected Boolean parse(String inputthrows Exception {
        if ("true".equalsIgnoreCase(input)) {
            return .;
        }
        if ("false".equalsIgnoreCase(input)) {
            return .;
        }
        throw new Exception();
    }
New to GrepCode? Check out our FAQ X