Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.config;
 
 
 import java.util.Map;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;

The configuration for a servlet javax.servlet.Filter.
public class FilterBuilder {
    private final FilterHolder holder;
    private final ImmutableMultimap.Builder<StringFilterHoldermappings;

    
Creates a new FilterBuilder.

Parameters:
holder the org.eclipse.jetty.servlet.FilterHolder containing the javax.servlet.Filter
mappings the mappings of URL patterns to javax.servlet.Filters
    public FilterBuilder(FilterHolder holder,
                         ImmutableMultimap.Builder<StringFilterHoldermappings) {
        this. = holder;
        this. = mappings;
    }

    
Sets the filter's name.

Parameters:
name the name of the filter
Returns:
this
    public FilterBuilder setName(String name) {
        checkArgument(!isNullOrEmpty(name), "name must be non-empty");
        .setName(name);
        return this;
    }

    
Sets the given filter initialization parameter.

Parameters:
name the name of the initialization parameter
value the value of the parameter
Returns:
this
    public FilterBuilder setInitParam(String nameString value) {
        .setInitParameter(checkNotNull(name), checkNotNull(value));
        return this;
    }

    
Sets the given filter initialization parameters.

Parameters:
params the initialization parameters
Returns:
this
    public FilterBuilder addInitParams(Map<StringStringparams) {
        for (Map.Entry<StringStringentry : checkNotNull(params).entrySet()) {
            setInitParam(entry.getKey(), entry.getValue());
        }
        return this;
    }

    
Adds the given URL pattern as a filter mapping.

Parameters:
urlPattern the URL pattern
Returns:
this
    public FilterBuilder addUrlPattern(String urlPattern) {
        .put(checkNotNull(urlPattern), );
        return this;
    }

    
Adds the given URL patterns as a filter mappings.

Parameters:
urlPattern the URL pattern
urlPatterns additional URL patterns
Returns:
this
    public FilterBuilder addUrlPatterns(String urlPatternString... urlPatterns) {
        addUrlPattern(checkNotNull(urlPattern));
        for (String pattern : checkNotNull(urlPatterns)) {
            addUrlPattern(checkNotNull(pattern));
        }
        return this;
    }
New to GrepCode? Check out our FAQ X