mthmulders commented on code in PR #697: URL: https://github.com/apache/maven/pull/697#discussion_r842727086
########## maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/NodeBufferingParser.java: ########## @@ -38,44 +37,54 @@ private final List<Event> buffer = new ArrayList<>(); - private final String nodeName; + private final ArrayList<String> stack = new ArrayList<>(); Review Comment: Shouldn't this variable be of type `List<String>`? "Program against interfaces, not implementations." ########## maven-model-transform/src/main/java/org/apache/maven/model/transform/pull/NodeBufferingParser.java: ########## @@ -38,44 +37,54 @@ private final List<Event> buffer = new ArrayList<>(); - private final String nodeName; + private final ArrayList<String> stack = new ArrayList<>(); private boolean buffering; - public NodeBufferingParser( XmlPullParser xmlPullParser, String nodeName ) + public NodeBufferingParser( XmlPullParser xmlPullParser ) { super( xmlPullParser ); - this.nodeName = Objects.requireNonNull( nodeName ); } @Override protected boolean accept() throws XmlPullParserException, IOException { - if ( nodeName.equals( xmlPullParser.getName() ) ) + int event = xmlPullParser.getEventType(); + if ( event == START_TAG ) { - if ( xmlPullParser.getEventType() == START_TAG && !buffering ) + String name = xmlPullParser.getName(); + stack.add( name ); + if ( !buffering ) { - buffer.add( bufferEvent() ); - buffering = true; - return false; + buffering = shouldBuffer( stack ); } - if ( xmlPullParser.getEventType() == END_TAG && buffering ) + } + else if ( event == END_TAG ) + { + stack.remove( stack.size() - 1 ); + if ( buffering ) { - buffer.add( bufferEvent() ); - process( buffer ); - buffering = false; - buffer.clear(); - return false; + buffering = shouldBuffer( stack ); + if ( !buffering ) + { + buffer.add( bufferEvent() ); + process( buffer ); + buffering = false; + buffer.clear(); + return false; + } } } - else if ( buffering ) + if ( buffering ) { buffer.add( bufferEvent() ); return false; } return true; } + protected abstract boolean shouldBuffer( ArrayList<String> stack ); Review Comment: Shouldn't this method argument (and its implementations) declare `List<String>`? "Program against interfaces, not implementations." -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org