Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to avoid if conditions using design pattern

513500Oct 10 2009 — edited Oct 10 2009
 if(searchDto.getName()!=null){
     String filter="and name='{0}';
     query =query+MessageFormat.formatMessage(filter,searchDto.getName())
}
..

...
..


{code}

I have many such if conditions to create my search query , I am wondering how can I avoid such conditions and make code cleaner using some desing pattern , what is design pattern applicable to this?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2009
Added on Oct 10 2009
3 comments
137 views