• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to avoid many if else [Pojo Validation]

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a validation class for eight types of messages(POJO classes) which first identifies the message class and than validate its properties.

now a pojo message class has about 46 properties, and validating these properties with if-else and then logging every validation error basicallly made the code too long and hard to read and maintain.

i want to improve my code and looking for a way to avoid many if-else statement or good way to validate pojo objects.

can any one suggest a way to move forward ?
 
Ranch Hand
Posts: 49
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i have a sample code
 
saqib sarwar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually the sample is tooooo big that it will confuse you guys ...

today i found solution about this, and now i will use JaValid

i walked through commons commons validators, i-screen and Spring validation as we are using Spring 2.0.

but i want to keep code away from xml and I cannot use Spring 2.5 annotation based validation because our project is bound to spring 2.0.

so i decided to use JaValid..

hope i would have good experience with this .. it looks like a simple annotation based framework for validation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic