Skip to Main Content

Integration

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!

Formatting TopLink Expressions

jhurneFeb 18 2009 — edited Feb 19 2009
I'm a big fan of formatting code so that is as readable as possible. When it comes to TopLink Expressions, there is definitely a way to format them so that they are virtually unreadable, and a way to format them to be readable.

Only problem is, I haven't figured the best way to format them to be as readable as possible. How do some of you format your TopLink Expressions?

Here's an example of an unreadable expression:
ExpressionBuilder expBldr1 = new ExpressionBuilder();
Expression exp1 = builder.get("company").get("address").get("state").equal("NY");
Expression exp2 = builder.get("company").get("address").get("city").equal("New York");
Expression exp3 = exp1.or(exp2);
Expression exp4 = builder.get("employee").get("hireDate").greaterThan(someDate);
Expression exp5 = exp3.and(exp4);
{code}To me, this is pretty hard to read, even for this relatively simple example.  It gets a lot worse with more complex expressions.  What would you do to make this more readable?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2009
Added on Feb 18 2009
3 comments
643 views