6 Replies Latest reply on Feb 6, 2008 2:49 PM by supernovasoftware.com

    An annotation I would like to see: @Trim

      Here's an idea / wish I've had for a long time:

      Most of the fields in most of my biz objects are strings. Usually they are strings which should always be trimmed, so most of my setter methods look like:

      public void setCity(String city) {
       if(city == null) {
       this.city = null;
       return;
       }
       this.city = city.trim();
      }


      There's never a reason for leading or trailing space in the "city" field or the "name" field or most of the fields actually.

      It would be cool to have an annotation called @Trim that I could put on set methods, which trims the string (if it's not null) before setting it.

      It seems like this would be easy to do. If I knew how Seam annotation processing worked, I would do it myself and submit it. If anyone can give me some brief pointers of how to get started, I'll start.