1   package com.atlassian.plugins.codegen;
2   
3   import static com.google.common.base.Preconditions.checkNotNull;
4   
5   /**
6    * Describes a resource file that should be added to the project.
7    */
8   public class ResourceFile implements PluginProjectChange
9   {
10      private final String relativePath;
11      private final String name;
12      private final String content;
13      
14      public static ResourceFile resourceFile(String relativePath, String name, String content)
15      {
16          return new ResourceFile(relativePath, name, content);
17      }
18      
19      private ResourceFile(String relativePath, String name, String content)
20      {
21          this.relativePath = normalizePath(checkNotNull(relativePath, "relativePath"));
22          this.name = checkNotNull(name, "name");
23          this.content = checkNotNull(content, "content");
24      }
25  
26      public String getRelativePath()
27      {
28          return relativePath;
29      }
30  
31      public String getName()
32      {
33          return name;
34      }
35      
36      public String getContent()
37      {
38          return content;
39      }
40      
41      private String normalizePath(String path)
42      {
43          return (path.endsWith("/")) ? path.substring(0, path.length() - 1) : path;
44      }
45          
46      @Override
47      public String toString()
48      {
49          return "[resource: " + name + "]";
50      }
51  }