commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [commons-lang] kinow commented on a change in pull request #308: LANG-1366 : Add Feature for No ClassName and MultiLine StringStyle
Date Fri, 04 Oct 2019 10:16:09 GMT
kinow commented on a change in pull request #308: LANG-1366 : Add Feature for No ClassName
and MultiLine StringStyle
URL: https://github.com/apache/commons-lang/pull/308#discussion_r331431799
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
 ##########
 @@ -2633,4 +2647,48 @@ private Object readResolve() {
         }
 
     }
+
+    // ----------------------------------------------------------------------------
+
+    /**
+     * <p>
+     * <code>ToStringStyle</code> that outputs with No Class Name in a Multi
Line format.
+     * </p>
+     *
+     * <p>
+     * This is an inner class rather than using
+     * <code>StandardToStringStyle</code> to ensure its immutability.
+     * </p>
+     *
+     * @since 3.7
+     * @see <a href="http://json.org">json.org</a>
+     */
+    private static final class NoClassNameMultiLineToStringStyle extends ToStringStyle {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * <p>Constructor.</p>
+         * <p>
+         * <p>Use the static constant rather than instantiating.</p>
+         */
+        NoClassNameMultiLineToStringStyle() {
+            super();
+            this.setUseClassName(false);
+            this.setUseIdentityHashCode(false);
+            this.setContentStart(StringUtils.EMPTY);
+            this.setFieldSeparator(System.lineSeparator());
+            this.setFieldSeparatorAtStart(false);
+            this.setContentEnd(System.lineSeparator());
+        }
+
+        /**
+         * <p>Ensure <code>Singleton</code> after serialization.</p>
+         *
+         * @return the singleton
+         */
+        private Object readResolve() {
+            return ToStringStyle.NO_CLASS_NAME_MULTI_LINE_STYLE;
 
 Review comment:
   Really nit-picking here, but other classes in this file are referencing it without the
class name (as this is the same class...). So if possible, for consistency it could be the
same, i.e. `return NO_CLASS_NAME_MULTI_LINE_STYLE;`. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message