commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcint <...@git.apache.org>
Subject [GitHub] commons-lang pull request: Multiline recursive to string style
Date Wed, 04 Nov 2015 00:48:26 GMT
Github user mcint commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/34#discussion_r43829569
  
    --- Diff: src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java
---
    @@ -0,0 +1,218 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * 
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.commons.lang3.builder;
    +
    +import org.apache.commons.lang3.ClassUtils;
    +import org.apache.commons.lang3.SystemUtils;
    +
    +/**
    + * <p>Works with {@link ToStringBuilder} to create a "deep" <code>toString</code>.

    + * But instead a single line like the {@link RecursiveToStringStyle} this creates a multiline
String 
    + * similar to the {@link ToStringStyle.MultiLineToStringStyle}.</p>
    + * 
    + * <p>To use this class write code as follows:</p>
    + *
    + * <pre>
    + * public class Job {
    + *   String title;
    + *   ...
    + * }
    + * 
    + * public class Person {
    + *   String name;
    + *   int age;
    + *   boolean smoker;
    + *   Job job;
    + * 
    + *   ...
    + * 
    + *   public String toString() {
    + *     return new ReflectionToStringBuilder(this, new MultilineRecursiveToStringStyle()).toString();
    + *   }
    + * }
    + * </pre>
    + *
    + * <p>
    + * This will produce a toString of the format:<br>
    + * <code>Person@7f54[ <br>
    + * &nbsp; name=Stephen, <br>
    + * &nbsp; age=29, <br>
    + * &nbsp; smoker=false, <br>
    + * &nbsp; job=Job@43cd2[ <br>
    + * &nbsp; &nbsp; title=Manager <br>
    + * &nbsp;  ] <br>
    + * ]
    + * </code>
    + * </p>
    + * 
    + * @since 3.4
    + */
    +class MultilineRecursiveToStringStyle extends RecursiveToStringStyle {
    --- End diff --
    
    Should this have been public? I've been trying to use this class, but can neither import
it nor find a factory method that might give me an instance of the class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message