Pankraz76 commented on code in PR #11284:
URL: https://github.com/apache/maven/pull/11284#discussion_r2438720273


##########
api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java:
##########
@@ -449,11 +446,11 @@ public Builder inputLocation(Object inputLocation) {
          * @return a new immutable XmlNode instance
          * @throws NullPointerException if name has not been set
          */
-        public XmlNode build() {
+        XmlNode build() {

Review Comment:
   https://pmd.github.io/pmd/pmd_rules_java_codestyle.html#unnecessarymodifier



##########
api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java:
##########
@@ -509,40 +506,45 @@ public int hashCode() {
             @Override
             public String toString() {
                 try {
-                    StringWriter writer = new StringWriter();
-                    XmlService.write(this, writer);
-                    return writer.toString();
-                } catch (IOException e) {
-                    return toStringObject();
+                    return XmlService.write(this, new 
StringWriter()).toString();

Review Comment:
   need fluid API to impl. like this.



##########
api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java:
##########
@@ -509,40 +506,45 @@ public int hashCode() {
             @Override
             public String toString() {
                 try {
-                    StringWriter writer = new StringWriter();
-                    XmlService.write(this, writer);
-                    return writer.toString();
-                } catch (IOException e) {
-                    return toStringObject();
+                    return XmlService.write(this, new 
StringWriter()).toString();
+                } catch (IOException ignored) {
+                    return addToStringField(
+                                    new StringJoiner(", ", "XmlNode[", "]"),
+                                    prefix,
+                                    namespaceUri,
+                                    name,
+                                    value,
+                                    attributes,
+                                    children,
+                                    inputLocation)
+                            .toString();
                 }
             }
 
-            private String toStringObject() {

Review Comment:
   Of course, it depends and might not apply to this situation. I would see 
anything in an interface as public, as that is the default scope. Interfaces 
are considered a public good, ready to be used.



##########
api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java:
##########
@@ -21,10 +21,7 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.io.StringWriter;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;

Review Comment:
   will undo sry.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to