Feature: Assume

From ADempiere
Jump to: navigation, search
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

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:

  1. 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.
  2. 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

Development

Added new, rather simple method org.compiere.util.Util.assume(boolean, String)

Developers