001 /* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 /* 015 * This file has been modified by Chris Pheby in accordance with Section 4.2 016 * of the Apache Software License 017 */ 018 package org.jadira.dependencynavigator.model; 019 020 /********************************************************************** 021 * you may not use this file except in compliance with the License. You may obtain a copy of the License at 022 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software 023 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 024 * either express or implied. See the License for the specific language governing permissions and limitations under the 025 * License. Contributors: 026 **********************************************************************/ 027 028 import java.util.ArrayList; 029 import java.util.List; 030 031 /** 032 * Contains a list of all the instances of a given artifact 033 */ 034 public class ArtifactInstanceMap { 035 private String groupId; 036 private String artifactId; 037 private String version; 038 039 private List<Artifact> instances; 040 041 private boolean selected; 042 043 public ArtifactInstanceMap(Artifact initialArtifact) { 044 instances = new ArrayList<Artifact>(); 045 groupId = initialArtifact.getGroupId(); 046 artifactId = initialArtifact.getArtifactId(); 047 version = initialArtifact.getVersion(); 048 selected = false; 049 } 050 051 public void addInstance(Artifact artifactInstance) { 052 instances.add(artifactInstance); 053 } 054 055 public String getArtifactId() { 056 return artifactId; 057 } 058 059 public String getGroupId() { 060 return groupId; 061 } 062 063 public List<Artifact> getInstances() { 064 return instances; 065 } 066 067 public String getVersion() { 068 return version; 069 } 070 071 public void select(boolean state) { 072 selected = state; 073 for (Artifact artifact : instances) { 074 artifact.select(state ? Artifact.SELECTED_PRINCIPLE : Artifact.SELECTED_NONE); 075 } 076 } 077 078 public boolean isSelected() { 079 return selected; 080 } 081 }