View Javadoc
1   /*
2    * Copyright (c) 2017.  Markus Graube
3    */
4   
5   package de.tud.plt.r43ples.optimization;
6   
7   import de.tud.plt.r43ples.existentobjects.ChangeSet;
8   import de.tud.plt.r43ples.existentobjects.Revision;
9   import de.tud.plt.r43ples.existentobjects.RevisionGraph;
10  import org.apache.logging.log4j.LogManager;
11  import org.apache.logging.log4j.Logger;
12  
13  import java.util.LinkedList;
14  
15  public class ChangeSetPath {
16  
17      /**
18       * The logger.
19       **/
20      private Logger logger = LogManager.getLogger(ChangeSetPath.class);
21  
22      /**
23       * The start revision.
24       */
25      private Revision startRevision;
26      /**
27       * The target revision.
28       */
29      private Revision targetRevision;
30      /**
31       * The path from start to target revision.
32       */
33      private LinkedList<ChangeSet> changeSets;
34  
35      /**
36       * The corresponding revision graph.
37       */
38      private RevisionGraph revisionGraph;
39  
40  
41      /**
42       * The constructor.
43       *
44       * @param revisionGraph  the revision graph
45       * @param startRevision  the start revision of the path
46       * @param targetRevision the target revision of the path
47       */
48      public ChangeSetPath(RevisionGraph revisionGraph, Revision startRevision, Revision targetRevision) {
49          this.revisionGraph = revisionGraph;
50  
51          this.startRevision = startRevision;
52          this.targetRevision = targetRevision;
53  
54          changeSets = new LinkedList<>();
55      }
56  
57      /**
58       * Adds a changeset to the revision path end.
59       *
60       * @param changeSet the revision to add to the end of the list
61       */
62      public void addRevisionToPathEnd(ChangeSet changeSet) {
63          changeSets.add(changeSet);
64      }
65  
66      /**
67       * Adds a changeSet to the changeSet path start.
68       *
69       * @param changeSet the changeSet to add to the end of the list
70       */
71      public void addRevisionToPathStart(ChangeSet changeSet) {
72          changeSets.addFirst(changeSet);
73      }
74  
75      /**
76       * Get the revision path. The revision path starts with the start revision and ends with the target revision.
77       *
78       * @return the revision path
79       */
80      public LinkedList<ChangeSet> getRevisionPath() {
81          return changeSets;
82      }
83  
84      public Revision getTargetRevision() {
85          return targetRevision;
86      }
87  
88      public Revision getStartRevision() {
89          return startRevision;
90      }
91  }