PageRenderTime 27ms CodeModel.GetById 22ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-api/src/main/java/com/atlassian/plugins/codegen/SourceFile.java

https://bitbucket.org/mmeinhold/amps
Java | 55 lines | 40 code | 9 blank | 6 comment | 0 complexity | cbaa590e96a46f8bb35e669a6b1f548b MD5 | raw file
 1package com.atlassian.plugins.codegen;
 2
 3import static com.google.common.base.Preconditions.checkNotNull;
 4
 5/**
 6 * Describes a source file that should be added to the project.
 7 */
 8public class SourceFile implements PluginProjectChange
 9{
10    /**
11     * Specifies whether to add the file to {@code src/main} or {@code src/test}.
12     */
13    public enum SourceGroup
14    {
15        MAIN,
16        TESTS
17    };
18
19    private final ClassId classId;
20    private final SourceGroup sourceGroup;
21    private final String content;
22    
23    public static SourceFile sourceFile(ClassId classId, SourceGroup sourceGroup, String content)
24    {
25        return new SourceFile(classId, sourceGroup, content);
26    }
27    
28    private SourceFile(ClassId classId, SourceGroup sourceGroup, String content)
29    {
30        this.classId = checkNotNull(classId, "classId");
31        this.sourceGroup = checkNotNull(sourceGroup, "sourceGroup");
32        this.content = checkNotNull(content, "content");
33    }
34
35    public ClassId getClassId()
36    {
37        return classId;
38    }
39
40    public SourceGroup getSourceGroup()
41    {
42        return sourceGroup;
43    }
44
45    public String getContent()
46    {
47        return content;
48    }
49    
50    @Override
51    public String toString()
52    {
53        return "[class: " + classId + "]";
54    }
55}