PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/plugin-module-codegen-engine/src/main/java/com/atlassian/plugins/codegen/modules/jira/JqlFunctionModuleCreator.java

https://bitbucket.org/mmeinhold/amps
Java | 50 lines | 35 code | 10 blank | 5 comment | 1 complexity | ca4ea61eb6ada720c10d001bf530b927 MD5 | raw file
 1package com.atlassian.plugins.codegen.modules.jira;
 2
 3import com.atlassian.plugins.codegen.PluginProjectChangeset;
 4import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
 5import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
 6
 7import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
 8
 9/**
10 * @since 3.6
11 */
12@JiraPluginModuleCreator
13public class JqlFunctionModuleCreator extends AbstractPluginModuleCreator<JqlFunctionProperties>
14{
15
16    public static final String MODULE_NAME = "JQL Function";
17    private static final String TEMPLATE_PREFIX = "templates/jira/jql/";
18
19    //stub
20    private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "JqlFunction.java.vtl";
21    private static final String UNIT_TEST_TEMPLATE = TEMPLATE_PREFIX + "JqlFunctionTest.java.vtl";
22
23    //examples
24    private static final String EXAMPLE_CLASS_TEMPLATE = TEMPLATE_PREFIX + "Example" + CLASS_TEMPLATE;
25
26    private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "jql-function-plugin.xml.vtl";
27
28    @Override
29    public PluginProjectChangeset createModule(JqlFunctionProperties props) throws Exception
30    {
31        PluginProjectChangeset ret = new PluginProjectChangeset()
32            .with(MOCKITO_TEST)
33            .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
34
35        if (props.includeExamples())
36        {
37            return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
38        }
39        else
40        {
41            return ret.with(createClassAndTests(props, CLASS_TEMPLATE, UNIT_TEST_TEMPLATE));
42        }
43    }
44
45    @Override
46    public String getModuleName()
47    {
48        return MODULE_NAME;
49    }
50}