PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/com/atlassian/jira/collector/plugin/components/Collector.java

https://bitbucket.org/knecht_andreas/jira-issue-collector-plugin/
Java | 221 lines | 178 code | 34 blank | 9 comment | 10 complexity | 5b50704068b9a357026be8954f72f05b MD5 | raw file
  1. package com.atlassian.jira.collector.plugin.components;
  2. import static com.atlassian.jira.util.dbc.Assertions.notNull;
  3. /**
  4. * Represents an issue collector and all its relevant configuration. This includes in what project and issue type
  5. * issues will be created, what user will be used for the reporter as well as a form template to use to get
  6. * user input and a trigger type.
  7. * </p>
  8. * To construct a new collector one should use the provided {@link Builder}.
  9. *
  10. * @since v1.0
  11. */
  12. public final class Collector
  13. {
  14. public static class Builder
  15. {
  16. private String id = null;
  17. private String name;
  18. private Long projectId;
  19. private Long issueTypeId;
  20. private String reporter;
  21. private String description = null;
  22. private Template template = null;
  23. private boolean enabled = false;
  24. private boolean recordWebInfo = false;
  25. private boolean useCredentials = false;
  26. private Trigger trigger = null;
  27. public Builder id(final String id)
  28. {
  29. this.id = id;
  30. return this;
  31. }
  32. public Builder collector(final Collector collector)
  33. {
  34. this.id = collector.getId();
  35. this.name = collector.getName();
  36. this.projectId = collector.getProjectId();
  37. this.issueTypeId = collector.getIssueTypeId();
  38. this.reporter = collector.getReporter();
  39. this.description = collector.getDescription();
  40. this.enabled = collector.isEnabled();
  41. this.recordWebInfo = collector.isRecordWebInfo();
  42. this.template = collector.getTemplate();
  43. this.useCredentials = collector.isUseCredentials();
  44. this.trigger = collector.getTrigger();
  45. return this;
  46. }
  47. public Builder name(final String name)
  48. {
  49. this.name = name;
  50. return this;
  51. }
  52. public Builder projectId(final Long projectId)
  53. {
  54. this.projectId = projectId;
  55. return this;
  56. }
  57. public Builder issueTypeId(final Long issueTypeId)
  58. {
  59. this.issueTypeId = issueTypeId;
  60. return this;
  61. }
  62. public Builder reporter(final String reporter)
  63. {
  64. this.reporter = reporter;
  65. return this;
  66. }
  67. public Builder description(final String description)
  68. {
  69. this.description = description;
  70. return this;
  71. }
  72. public Builder template(final Template template)
  73. {
  74. this.template = template;
  75. return this;
  76. }
  77. public Builder enabled(final boolean enabled)
  78. {
  79. this.enabled = enabled;
  80. return this;
  81. }
  82. public Builder recoredWebInfo(final boolean enabled)
  83. {
  84. this.recordWebInfo = enabled;
  85. return this;
  86. }
  87. public Builder useCredentials(final boolean useCredentials)
  88. {
  89. this.useCredentials = useCredentials;
  90. return this;
  91. }
  92. public Builder trigger(final Trigger trigger)
  93. {
  94. this.trigger = trigger;
  95. return this;
  96. }
  97. public Collector build()
  98. {
  99. return new Collector(id, name, projectId, issueTypeId, reporter, description, template, enabled, recordWebInfo, useCredentials, trigger);
  100. }
  101. }
  102. private final String id;
  103. private final String name;
  104. private final Long projectId;
  105. private final Long issueTypeId;
  106. private final String reporter;
  107. private final String description;
  108. private final Template template;
  109. private final boolean enabled;
  110. private final boolean recordWebInfo;
  111. private final boolean useCredentials;
  112. private final Trigger trigger;
  113. private Collector(final String id, final String name, final Long projectId, final Long issueTypeId,
  114. final String reporter, final String description, final Template template,
  115. final boolean enabled, final boolean recordWebInfo, final boolean useCredentials, final Trigger trigger)
  116. {
  117. this.id = id;
  118. this.recordWebInfo = recordWebInfo;
  119. this.name = notNull("name", name);
  120. this.projectId = notNull("projectId", projectId);
  121. this.issueTypeId = notNull("issueTypeId", issueTypeId);
  122. this.reporter = notNull("reporter", reporter);
  123. this.template = notNull("template", template);
  124. this.description = description;
  125. this.enabled = enabled;
  126. this.useCredentials = useCredentials;
  127. this.trigger = notNull("trigger", trigger);
  128. }
  129. public String getId()
  130. {
  131. return id;
  132. }
  133. public String getName()
  134. {
  135. return name;
  136. }
  137. public Long getProjectId()
  138. {
  139. return projectId;
  140. }
  141. public Long getIssueTypeId()
  142. {
  143. return issueTypeId;
  144. }
  145. public String getReporter()
  146. {
  147. return reporter;
  148. }
  149. public String getDescription()
  150. {
  151. return description;
  152. }
  153. public Template getTemplate()
  154. {
  155. return template;
  156. }
  157. public boolean isEnabled()
  158. {
  159. return enabled;
  160. }
  161. public boolean isRecordWebInfo()
  162. {
  163. return recordWebInfo;
  164. }
  165. public boolean isUseCredentials()
  166. {
  167. return useCredentials;
  168. }
  169. public Trigger getTrigger()
  170. {
  171. return trigger;
  172. }
  173. @Override
  174. public boolean equals(final Object o)
  175. {
  176. if (this == o) { return true; }
  177. if (o == null || getClass() != o.getClass()) { return false; }
  178. final Collector collector = (Collector) o;
  179. if (id != null ? !id.equals(collector.id) : collector.id != null) { return false; }
  180. return true;
  181. }
  182. @Override
  183. public int hashCode()
  184. {
  185. return id != null ? id.hashCode() : 0;
  186. }
  187. }