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   
9   /**
10   * This class gives the location of a particular resource
11   */
12  public class ResourceLocation {
13      private final String location;
14      private final String name;
15      private final String type;
16      private final String contentType;
17      private final String content;
18      private final Map<String, String> params;
19  
20      public ResourceLocation(String location, String name, String type, String contentType, String content, Map<String, String> params) {
21          this.location = location;
22          this.name = name;
23          this.type = type;
24          this.contentType = contentType;
25          this.content = content;
26          this.params = ImmutableMap.copyOf(Maps.filterEntries(params, KEY_AND_VALUE_NOT_NULL));
27      }
28  
29      /**
30       * Necessary because {@link com.atlassian.plugin.loaders.LoaderUtils#getParams(org.dom4j.Element)} allows <code>null</code>s through
31       */
32      private static final Predicate<Map.Entry<?, ?>> KEY_AND_VALUE_NOT_NULL = e -> e.getKey() != null && e.getValue() != null;
33  
34      public String getLocation() {
35          return location;
36      }
37  
38      public String getName() {
39          return name;
40      }
41  
42      public String getType() {
43          return type;
44      }
45  
46      public String getContentType() {
47          return contentType;
48      }
49  
50      public String getContent() {
51          return content;
52      }
53  
54      public String getParameter(String key) {
55          return params.get(key);
56      }
57  
58      public Map<String, String> getParams() {
59          return params;
60      }
61  }