Skip to content

Commit

Permalink
Convert missing check to stream logic.
Browse files Browse the repository at this point in the history
Fixes: SE-13618
  • Loading branch information
oolscireum committed Oct 2, 2024
1 parent a98dd42 commit 78a8a23
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

/**
* Compiles a sources file into a {@link sirius.pasta.tagliatelle.Template}.
Expand Down Expand Up @@ -436,14 +437,13 @@ private void parseAttributes(TagHandler handler) {
* @param attributes the set of attributes which were parsed
*/
private void checkMissingAttributes(TagHandler handler, Set<String> attributes) {
Set<String> missingAttributes = new HashSet<>(handler.getRequiredAttributeNames());
missingAttributes.removeAll(attributes);
if (!missingAttributes.isEmpty()) {
missingAttributes.forEach(attr -> context.error(reader.current(),
"Missing required attribute. %s missing the required attribute '%s'.",
handler.getTagName(),
attr));
}
handler.getRequiredAttributeNames()
.stream()
.filter(Predicate.not(attributes::contains))
.forEach(attr -> context.error(reader.current(),
"Missing required attribute. %s missing the required attribute '%s'.",
handler.getTagName(),
attr));
}

private void parseAttributeExpression(TagHandler handler,
Expand Down

0 comments on commit 78a8a23

Please sign in to comment.