Skip to content

Commit

Permalink
null check before stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Capt-Mac committed Oct 9, 2024
1 parent b749ee2 commit 7269d90
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,24 @@ protected List<Either3<IdType, String, CanonicalType>> liftMeasureParameters(
List<IdType> measureId, List<String> measureIdentifier, List<CanonicalType> measureUrl) {

List<Either3<IdType, String, CanonicalType>> eitherList = new ArrayList<>();

measureId.stream()
.filter(this::isValidMeasureIdType)
.map(Eithers::<IdType, String, CanonicalType>forLeft3)
.forEach(eitherList::add);
measureIdentifier.stream()
.filter(Objects::nonNull)
.map(Eithers::<IdType, String, CanonicalType>forMiddle3)
.forEach(eitherList::add);
measureUrl.stream()
.filter(this::isValidCanonical)
.map(Eithers::<IdType, String, CanonicalType>forRight3)
.forEach(eitherList::add);
if (measureId != null) {
measureId.stream()
.filter(this::isValidMeasureIdType)
.map(Eithers::<IdType, String, CanonicalType>forLeft3)
.forEach(eitherList::add);
}
if (measureIdentifier != null) {
measureIdentifier.stream()
.filter(Objects::nonNull)
.map(Eithers::<IdType, String, CanonicalType>forMiddle3)
.forEach(eitherList::add);
}
if (measureUrl != null) {
measureUrl.stream()
.filter(this::isValidCanonical)
.map(Eithers::<IdType, String, CanonicalType>forRight3)
.forEach(eitherList::add);
}
if (eitherList.isEmpty()) {
throw new IllegalArgumentException("no measure resolving parameter was specified");
}
Expand Down

0 comments on commit 7269d90

Please sign in to comment.