View Javadoc

1   /*
2    *  Licensed under the Apache License, Version 2.0 (the "License");
3    *  you may not use this file except in compliance with the License.
4    *  You may obtain a copy of the License at
5    *
6    *      http://www.apache.org/licenses/LICENSE-2.0
7    *
8    *  Unless required by applicable law or agreed to in writing, software
9    *  distributed under the License is distributed on an "AS IS" BASIS,
10   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   *  See the License for the specific language governing permissions and
12   *  limitations under the License.
13   */
14  /*
15   * This file has been modified by Chris Pheby in accordance with Section 4.2
16   * of the Apache Software License
17   */
18  package org.jadira.dependencynavigator.model;
19  
20  /**********************************************************************
21   * you may not use this file except in compliance with the License. You may obtain a copy of the License at
22   * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
23   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
24   * either express or implied. See the License for the specific language governing permissions and limitations under the
25   * License. Contributors:
26   **********************************************************************/
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * Contains a list of all the instances of a given artifact
33   */
34  public class ArtifactInstanceMap {
35      private String groupId;
36      private String artifactId;
37      private String version;
38  
39      private List<Artifact> instances;
40  
41      private boolean selected;
42  
43      public ArtifactInstanceMap(Artifact initialArtifact) {
44          instances = new ArrayList<Artifact>();
45          groupId = initialArtifact.getGroupId();
46          artifactId = initialArtifact.getArtifactId();
47          version = initialArtifact.getVersion();
48          selected = false;
49      }
50  
51      public void addInstance(Artifact artifactInstance) {
52          instances.add(artifactInstance);
53      }
54  
55      public String getArtifactId() {
56          return artifactId;
57      }
58  
59      public String getGroupId() {
60          return groupId;
61      }
62  
63      public List<Artifact> getInstances() {
64          return instances;
65      }
66  
67      public String getVersion() {
68          return version;
69      }
70  
71      public void select(boolean state) {
72          selected = state;
73          for (Artifact artifact : instances) {
74              artifact.select(state ? Artifact.SELECTED_PRINCIPLE : Artifact.SELECTED_NONE);
75          }
76      }
77  
78      public boolean isSelected() {
79          return selected;
80      }
81  }