1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package org.apache.maven.model.building;
20  
21  import java.util.ArrayList;
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Objects;
26  
27  import org.apache.maven.model.Model;
28  import org.apache.maven.model.Profile;
29  
30  
31  
32  
33  
34  
35  @Deprecated(since = "4.0.0")
36  class DefaultModelBuildingResult implements ModelBuildingResult {
37  
38      private Model effectiveModel;
39  
40      private List<String> modelIds;
41  
42      private Map<String, Model> rawModels;
43  
44      private Map<String, List<Profile>> activePomProfiles;
45  
46      private List<Profile> activeExternalProfiles;
47  
48      private List<ModelProblem> problems;
49  
50      DefaultModelBuildingResult() {
51          modelIds = new ArrayList<>();
52          rawModels = new HashMap<>();
53          activePomProfiles = new HashMap<>();
54          activeExternalProfiles = new ArrayList<>();
55          problems = new ArrayList<>();
56      }
57  
58      @Override
59      public Model getEffectiveModel() {
60          return effectiveModel;
61      }
62  
63      public DefaultModelBuildingResult setEffectiveModel(Model model) {
64          this.effectiveModel = model;
65  
66          return this;
67      }
68  
69      @Override
70      public List<String> getModelIds() {
71          return modelIds;
72      }
73  
74      public DefaultModelBuildingResult addModelId(String modelId) {
75          
76          Objects.requireNonNull(modelId, "modelId cannot null");
77  
78          modelIds.add(modelId);
79  
80          return this;
81      }
82  
83      @Override
84      public Model getRawModel() {
85          return rawModels.get(modelIds.get(0));
86      }
87  
88      @Override
89      public Model getRawModel(String modelId) {
90          return rawModels.get(modelId);
91      }
92  
93      public DefaultModelBuildingResult setRawModel(String modelId, Model rawModel) {
94          
95          Objects.requireNonNull(modelId, "modelId cannot null");
96  
97          rawModels.put(modelId, rawModel);
98  
99          return this;
100     }
101 
102     @Override
103     public List<Profile> getActivePomProfiles(String modelId) {
104         return activePomProfiles.get(modelId);
105     }
106 
107     public DefaultModelBuildingResult setActivePomProfiles(String modelId, List<Profile> activeProfiles) {
108         
109         Objects.requireNonNull(modelId, "modelId cannot null");
110 
111         if (activeProfiles != null) {
112             this.activePomProfiles.put(modelId, new ArrayList<>(activeProfiles));
113         } else {
114             this.activePomProfiles.remove(modelId);
115         }
116 
117         return this;
118     }
119 
120     @Override
121     public List<Profile> getActiveExternalProfiles() {
122         return activeExternalProfiles;
123     }
124 
125     public DefaultModelBuildingResult setActiveExternalProfiles(List<Profile> activeProfiles) {
126         if (activeProfiles != null) {
127             this.activeExternalProfiles = new ArrayList<>(activeProfiles);
128         } else {
129             this.activeExternalProfiles.clear();
130         }
131 
132         return this;
133     }
134 
135     @Override
136     public List<ModelProblem> getProblems() {
137         return problems;
138     }
139 
140     public DefaultModelBuildingResult setProblems(List<ModelProblem> problems) {
141         if (problems != null) {
142             this.problems = new ArrayList<>(problems);
143         } else {
144             this.problems.clear();
145         }
146 
147         return this;
148     }
149 }