Skip to content

Commit

Permalink
expected artifacts from hashmap to map
Browse files Browse the repository at this point in the history
  • Loading branch information
Xabier Laiseca committed Jul 22, 2019
1 parent 6f9408f commit a746d98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TemplatedPipelineRequest {
String id;
String schema;
String type;
List<HashMap<String, Object>> expectedArtifacts;
List<Map<String, Object>> expectedArtifacts;
Map<String, Object> trigger = new HashMap<>();
Map<String, Object> config;
Map<String, Object> template;
Expand Down Expand Up @@ -129,11 +129,11 @@ public boolean isKeepWaitingPipelines() {
return keepWaitingPipelines;
}

public void setExpectedArtifacts(List<HashMap<String, Object>> expectedArtifacts) {
public void setExpectedArtifacts(List<Map<String, Object>> expectedArtifacts) {
this.expectedArtifacts = expectedArtifacts;
}

public List<HashMap<String, Object>> getExpectedArtifacts() {
public List<Map<String, Object>> getExpectedArtifacts() {
return this.expectedArtifacts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void addExpectedArtifacts(
TemplateConfiguration configuration,
TemplatedPipelineRequest request) {

List<HashMap<String, Object>> mergedExpectedArtifacts =
List<Map<String, Object>> mergedExpectedArtifacts =
mergeExpectedArtifact(
emptyListIfNull(configuration.getConfiguration().getExpectedArtifacts()),
emptyListIfNull(request.getExpectedArtifacts()));
Expand All @@ -175,13 +175,13 @@ private void addExpectedArtifacts(
pipeline.put("expectedArtifacts", mergedExpectedArtifacts);
}

private List<HashMap<String, Object>> emptyListIfNull(List<HashMap<String, Object>> eas) {
private List<? extends Map<String, Object>> emptyListIfNull(List<? extends Map<String, Object>> eas) {
return Optional.ofNullable(eas).orElse(Collections.emptyList());
}

private List<HashMap<String, Object>> mergeExpectedArtifact(
List<HashMap<String, Object>> eas1, List<HashMap<String, Object>> eas2) {
HashMap<String, HashMap<String, Object>> mergedByName = new HashMap<>();
private List<Map<String, Object>> mergeExpectedArtifact(
List<? extends Map<String, Object>> eas1, List<? extends Map<String, Object>> eas2) {
HashMap<String, Map<String, Object>> mergedByName = new HashMap<>();

eas1.forEach(artifact -> mergedByName.put(String.valueOf(artifact.get("id")), artifact));
eas2.forEach(artifact -> mergedByName.put(String.valueOf(artifact.get("id")), artifact));
Expand Down

0 comments on commit a746d98

Please sign in to comment.