View Javadoc
1   package com.atlassian.plugin.elements;
2   
3   import com.google.common.base.Predicate;
4   import com.google.common.collect.ImmutableMap;
5   import com.google.common.collect.Maps;
6   
7   import java.util.Map;
8   import java.util.Map.Entry;
9   
10  /**
11   * This class gives the location of a particular resource
12   */
13  public class ResourceLocation {
14      private final String location;
15      private final String name;
16      private final String type;
17      private final String contentType;
18      private final String content;
19      private final Map<String, String> params;
20  
21      public ResourceLocation(String location, String name, String type, String contentType, String content, Map<String, String> params) {
22          this.location = location;
23          this.name = name;
24          this.type = type;
25          this.contentType = contentType;
26          this.content = content;
27          this.params = ImmutableMap.copyOf(Maps.filterEntries(params, KEY_AND_VALUE_NOT_NULL));
28      }
29  
30      /**
31       * Necessary because {@link com.atlassian.plugin.loaders.LoaderUtils#getParams(org.dom4j.Element)} allows <code>null</code>s through
32       */
33      private static final Predicate<Map.Entry<?, ?>> KEY_AND_VALUE_NOT_NULL = new Predicate<Map.Entry<?, ?>>() {
34          @Override
35          public boolean apply(Entry<?, ?> e) {
36              return e.getKey() != null && e.getValue() != null;
37          }
38      };
39  
40      public String getLocation() {
41          return location;
42      }
43  
44      public String getName() {
45          return name;
46      }
47  
48      public String getType() {
49          return type;
50      }
51  
52      public String getContentType() {
53          return contentType;
54      }
55  
56      public String getContent() {
57          return content;
58      }
59  
60      public String getParameter(String key) {
61          return params.get(key);
62      }
63  
64      public Map<String, String> getParams() {
65          return params;
66      }
67  }