Silicon-Age / opal

Silicon Age's ORM layer.
0 stars 0 forks source link

Make field names (etc.) available at compile time #5

Open jonahgreenthal opened 1 year ago

jonahgreenthal commented 1 year ago

Currently we specify OpalForms using field names as strings. Invalid field names (e.g. <%= lclOF.text("LsatName", 20) %>) lead to runtime errors. I'd love to turn these into compile-time errors.

Suggestion: Each UserFacing has nested static enums for Fields, References, and Children. Then we can do <%= lclOF.text(Contact.SimpleFields.LAST_NAME, 20) %> and we'll know about typos or outright errors at compile time.

This would also probably be a good place to put information on nullability, maximum lengths, etc., since inspecting annotations is painful. (Currently, com.opal.FieldUtility helps with this, but it's still awkwardly inspecting annotations at runtime.)