Skip to content

Commit

Permalink
[PR #295] make defensive copy instead of unmodifiable view
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaskabc authored and ledsoft committed Sep 13, 2024
1 parent d4e2676 commit df23e79
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import org.springframework.lang.NonNull;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
* Indicates that validation for a set of vocabularies was finished.
Expand All @@ -17,9 +19,9 @@ public class VocabularyValidationFinishedEvent extends VocabularyEvent {
* Vocabulary closure of {@link #vocabularyIri}.
* IRIs of vocabularies that are imported by {@link #vocabularyIri} and were part of the validation.
*/
private final Collection<URI> vocabularyIris;
private final List<URI> vocabularyIris;

private final Collection<ValidationResult> validationResults;
private final List<ValidationResult> validationResults;

/**
* @param source the source of the event
Expand All @@ -31,17 +33,18 @@ public VocabularyValidationFinishedEvent(@NonNull Object source, @NonNull URI or
@NonNull Collection<URI> vocabularyIris,
@NonNull List<ValidationResult> validationResults) {
super(source, originVocabularyIri);
this.vocabularyIris = Collections.unmodifiableCollection(vocabularyIris);
this.validationResults = Collections.unmodifiableCollection(validationResults);
// defensive copy
this.vocabularyIris = new ArrayList<>(vocabularyIris);
this.validationResults = new ArrayList<>(validationResults);
}

@NonNull
public Collection<URI> getVocabularyIris() {
return vocabularyIris;
public List<URI> getVocabularyIris() {
return Collections.unmodifiableList(vocabularyIris);
}

@NonNull
public Collection<ValidationResult> getValidationResults() {
return validationResults;
public List<ValidationResult> getValidationResults() {
return Collections.unmodifiableList(validationResults);
}
}

0 comments on commit df23e79

Please sign in to comment.