Feature: Assume
From ADempiere
This Wiki is read-only for reference purposes to avoid broken links.
Note: Feature has been committed into development branch: http://adempiere.hg.sourceforge.net:8000/hgroot/adempiere/adempiere/rev/8d7294249818
Contents
Introduction
Tobi 11:17, 10 September 2011 (UTC):
I'd like to contribute a little static method "Util.assume" that I used a lot at metas. It's similar to the java "assert" keyword, but there are two advantages:
- If the assumption doesn't hold, it throws and AdempiereException, which adempiere itself can handle (display to user, create AD_Issue etc) much better than the AssertionError that would be thrown by assert.
- Assumptions are always checked, not only when the "-ea" cmd-line parameter is used. I think that this is more suitable for an ERP system, because of the bigger complexity it comes with.
- Plus, for me it turned you that I never had to access the DB to check my assumptions. Therefore, the performance impact turned out to be neglectable.
Documentation
The feature is rather simple; This changeset from the feature-branch shows, how the method could be used: http://adempiere.hg.sourceforge.net/hgweb/adempiere/adempiere/rev/492abbedd43e
Technical Specifications
References
- FR3407104: https://sourceforge.net/tracker/?func=detail&aid=3407104&group_id=176962&atid=879335
- ADempiere HG repo: http://adempiere.hg.sourceforge.net:8000/hgroot/adempiere/adempiere
- Feature Branch: feature/FR3407104_assume
Development
Added new, rather simple method org.compiere.util.Util.assume(boolean, String)