View Javadoc

1   /*
2    * LICENSE
3    *
4    * "THE BEER-WARE LICENSE" (Revision 42):
5    * "Sven Strittmatter" <ich@weltraumschaf.de> wrote this file.
6    * As long as you retain this notice you can do whatever you want with
7    * this stuff. If we meet some day, and you think this stuff is worth it,
8    * you can buy me a beer in return.
9    */
10  package org.jenkinsci.plugins.darcs;
11  
12  import hudson.scm.SCMRevisionState;
13  
14  /**
15   * Represents the revision state of a repository.
16   *
17   * The state consists of all changes in a repository. The comparison is made over a digest from the DarcsChangeSetList.
18   *
19   * @author Sven Strittmatter <ich@weltraumschaf.de>
20   */
21  public class DarcsRevisionState extends SCMRevisionState {
22  
23      /**
24       * Holds all patches as DarcsChangeSet objects.
25       */
26      private final DarcsChangeSetList changes;
27  
28      /**
29       * Initializes object with empty change set list.
30       */
31      public DarcsRevisionState() {
32          this(new DarcsChangeSetList());
33      }
34  
35      /**
36       * Dedicated constructor.
37       *
38       * @param changes list of change sets
39       */
40      public DarcsRevisionState(final DarcsChangeSetList changes) {
41          super();
42          this.changes = changes;
43      }
44  
45      /**
46       * Returns the current revision state change set list.
47       *
48       * @return never {@code null}
49       */
50      public DarcsChangeSetList getChanges() {
51          return changes;
52      }
53  
54      @Override
55      public String toString() {
56          return getChanges().digest();
57      }
58  
59      @Override
60      public boolean equals(final Object obj) {
61          if (!(obj instanceof DarcsRevisionState)) {
62              return false;
63          }
64  
65          final DarcsRevisionState other = (DarcsRevisionState) obj;
66          return getChanges().equals(other.getChanges());
67      }
68  
69      @Override
70      public int hashCode() {
71          return changes.hashCode();
72      }
73  }