1/**
2 * Copyright (C) 2010 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.inject.servlet;
18
19import java.util.Map;
20
21/**
22 * Abstract implementation for all servlet module bindings
23 *
24 * @author sameb@google.com (Sam Berlin)
25 */
26class AbstractServletModuleBinding<T> implements ServletModuleBinding {
27
28  private final Map<String, String> initParams;
29  private final String pattern;
30  private final T target;
31  private final UriPatternMatcher patternMatcher;
32
33  AbstractServletModuleBinding(Map<String, String> initParams, String pattern, T target,
34      UriPatternMatcher patternMatcher) {
35    this.initParams = initParams;
36    this.pattern = pattern;
37    this.target = target;
38    this.patternMatcher = patternMatcher;
39  }
40
41  public Map<String, String> getInitParams() {
42    return initParams;
43  }
44
45  public String getPattern() {
46    return pattern;
47  }
48
49  protected T getTarget() {
50    return target;
51  }
52
53  public UriPatternType getUriPatternType() {
54    return patternMatcher.getPatternType();
55  }
56
57  public boolean matchesUri(String uri) {
58    return patternMatcher.matches(uri);
59  }
60
61}
62