[ 
https://issues.apache.org/jira/browse/LANG-378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Barrie Treloar updated LANG-378:
--------------------------------

    Attachment: LANG-378-patch.txt

*Background*

  Because the ToStringStyle instances are meant to be singletons it is 
important that they be thread safe.
  
  This is currently achieved in the architecture by not making the setter 
methods public, and avoiding the use of any state.
  
  The downside to this implementation is that subclases of ToStringStyle may 
inadvertantly break this compact by using
  the setters outside of initialisation.
  
*Overview*

  Created an immutable data class (ToStringStyleData) to hold all the state 
needed by ToStringStyle.  

  A builder class (ToStringStyleDataBuilder) was created to create instances of 
the data class.

  In ToStringStyle the methods appendArrayStart, appendArraySeparator, 
appendArrayEnd were created and used internally instead of directly appending 
styleData.arrayStart, styleData.arraySeparator, styleData.arrayEnd as this 
allows subclasses to alter their behaviour.

  Modified subclasses as needed to make use of data and builder classes.

  Modified test cases and added new test cases for 
MultiLineWithIndentToStringStyle
  
*Details*

*Source File changes*

* New MultiLineWithIndentToStringStyle "ToStringStyle" created that has 
ThreadLocal state "MultiLineWithIndentToStringStyleData" containing the 
indentation string and indentation level.

* StandardToStringStyle has had all getter and setter methods deprecated.  The 
setter methods also no longer do anything as changing state is not thread safe.

* ToStringStyle 
** all fields moved into an immutable Data class "ToStringStyleData", which can 
be build via the Builder class "ToStringStyleDataBuilder".
** all getter and setter methods for these fields deprecated as the setters are 
not thread safe and the getters can use the styleData variable directly.
** appendArrayStart, appendArraySeparator, appendArrayEnd methods created and 
used internally instead of directly appending styleData.arrayStart, 
styleData.arraySeparator, styleData.arrayEnd
** All internal subclasses upgraded to use ToStringStyleDataBuilder to create 
their specific instance of ToStringStyleData
  
*Test File changes*

* ToStringStyleDataBuilderTest created from ToStringStyleTest as it wasn't 
really testing ToStringStyle but the StyleData handling of nulls passed in to 
setters of strings.

* BuilderTestSuite modified to use ToStringStyleDataBuilderTest

* StandardToStringStyleTest modified to use style data builder

* Fixed defect in tearDown() that was not resetting the default style back to 
ToStringStyle.DEFAULT_STYLE

* MultiLineWithIndentToStringStyleTest created with 22 example classes and 
expected output.
  Note: This class had to copy in IOUtils.toString from commons-io

*Patch Included*
Patched against LANG_2_2_X rev 452939


> Add new ToStyle to support MultiLine with Indent
> ------------------------------------------------
>
>                 Key: LANG-378
>                 URL: https://issues.apache.org/jira/browse/LANG-378
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.builder.*
>    Affects Versions: 2.3
>            Reporter: Barrie Treloar
>            Priority: Minor
>             Fix For: 3.x
>
>         Attachments: LANG-378-patch.txt, LANG-378-patch.txt, 
> MultiLineWithIndentToStyle.zip
>
>
> Multiline support  places everything on a new line with no indentation to 
> help in readability.
> Attached is a patch (with tests) to support Multiline behaviour with 
> indentation.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to