Return to Snippet

Revision: 50481
at August 24, 2011 10:24 by m3rol666


Initial Code
static void trimObjectProperties(GroovyObject o,String wichSide)
{
	o.getProperties().each{

	if(wichSide.equals(RIGHT)) //you can add more trim types
	{
		if(it.value)
			if(it.value.class.equals(String.class))
			{
                         o.setProperty(it.getKey(), rightTrim(it.value)) //call the trim method
			}
	}
   }
}

Initial URL


Initial Description
I used this because I had a legacy db table that all fields are char.  the right spaces were a pita. The rightTrim function can be viewed in my profile

Initial Title
Dinamically  trim all object\'s string properties

Initial Tags
groovy

Initial Language
Groovy