PageRenderTime 136ms CodeModel.GetById 49ms RepoModel.GetById 7ms app.codeStats 0ms

/src/main/java/com/atlassian/jira/plugins/bitbucket/spi/DefaultBitbucketChangeset.java

https://bitbucket.org/atlassian/jira-bitbucket-connector/
Java | 150 lines | 124 code | 22 blank | 4 comment | 6 complexity | 6818d42d331d929c5c6b8574586489ba MD5 | raw file
  1. package com.atlassian.jira.plugins.bitbucket.spi;
  2. import com.atlassian.jira.plugins.bitbucket.api.Changeset;
  3. import com.atlassian.jira.plugins.bitbucket.api.ChangesetFile;
  4. import com.atlassian.jira.plugins.bitbucket.api.SourceControlRepository;
  5. import org.apache.commons.lang.builder.EqualsBuilder;
  6. import org.apache.commons.lang.builder.HashCodeBuilder;
  7. import java.util.Date;
  8. import java.util.List;
  9. /**
  10. * Details on a changeset found in Bitbucket.
  11. * TODO rename? this class is used for GitHub changsets too
  12. */
  13. public class DefaultBitbucketChangeset implements Changeset
  14. {
  15. private final String node;
  16. private final String rawAuthor;
  17. private final String author;
  18. private final Date timestamp;
  19. private final String rawNode;
  20. private final String branch;
  21. private final String message;
  22. private final List<String> parents;
  23. private final List<ChangesetFile> files;
  24. private final int allFileCount;
  25. private final int repositoryId;
  26. public DefaultBitbucketChangeset(int repositoryId,
  27. String node, String rawAuthor, String author, Date timestamp,
  28. String rawNode, String branch, String message,
  29. List<String> parents, List<ChangesetFile> files, int allFileCount)
  30. {
  31. this.repositoryId = repositoryId;
  32. this.node = node;
  33. this.rawAuthor = rawAuthor;
  34. this.author = author;
  35. this.timestamp = timestamp;
  36. this.rawNode = rawNode;
  37. this.branch = branch;
  38. this.message = message;
  39. this.parents = parents;
  40. this.files = files;
  41. this.allFileCount = allFileCount;
  42. }
  43. public int getRepositoryId()
  44. {
  45. return repositoryId;
  46. }
  47. public String getNode()
  48. {
  49. return node;
  50. }
  51. public String getRawAuthor()
  52. {
  53. return rawAuthor;
  54. }
  55. public String getAuthor()
  56. {
  57. return author;
  58. }
  59. public Date getTimestamp()
  60. {
  61. return timestamp;
  62. }
  63. public String getRawNode()
  64. {
  65. return rawNode;
  66. }
  67. public String getBranch()
  68. {
  69. return branch;
  70. }
  71. public String getMessage()
  72. {
  73. return message;
  74. }
  75. public List<String> getParents()
  76. {
  77. return parents;
  78. }
  79. public List<ChangesetFile> getFiles()
  80. {
  81. return files;
  82. }
  83. public int getAllFileCount()
  84. {
  85. return allFileCount;
  86. }
  87. public String getCommitURL(SourceControlRepository repository)
  88. {
  89. return repository.getRepositoryUri().getCommitUrl(node);
  90. }
  91. @Override
  92. public boolean equals(Object o)
  93. {
  94. if (this == o) return true;
  95. if (o == null || getClass() != o.getClass()) return false;
  96. DefaultBitbucketChangeset that = (DefaultBitbucketChangeset) o;
  97. return new EqualsBuilder()
  98. .append(author, that.author)
  99. .append(branch, that.branch)
  100. .append(files, that.files)
  101. .append(message, that.message)
  102. .append(node, that.node)
  103. .append(parents, that.parents)
  104. .append(rawAuthor, that.rawAuthor)
  105. .append(rawNode, that.rawNode)
  106. .append(repositoryId, that.repositoryId)
  107. .append(timestamp, that.timestamp)
  108. .append(allFileCount, that.allFileCount)
  109. .isEquals();
  110. }
  111. @Override
  112. public int hashCode()
  113. {
  114. return new HashCodeBuilder()
  115. .append(author)
  116. .append(branch)
  117. .append(files)
  118. .append(message)
  119. .append(node)
  120. .append(parents)
  121. .append(rawAuthor)
  122. .append(rawNode)
  123. .append(repositoryId)
  124. .append(timestamp)
  125. .append(allFileCount)
  126. .hashCode();
  127. }
  128. }