-
Notifications
You must be signed in to change notification settings - Fork 1
WritingContractsWithSpEL
Sebastian Hoß edited this page Oct 5, 2013
·
2 revisions
See the SpEL reference documentation
To reference the enclosing instance of the annotated business class, use the constant this
. To reference the result of the method invocation use the constant return
. The following class shows an example:
class SpELInsuranceCompany {
@Contract( preconditions = { @Clause(value = "#damage > 0", message = "Reported damage must be positive!", exception = IllegalStateException.class), @Clause(value = "#damage <= maximumReportableDamage", message = "We won't pay that!", exception = IllegalStateException.class) }, postconditions = { @Clause(value = "#return >= 0", message = "We won't take any more!"), @Clause(value = "#return <= remainingMoney", message = "We can't pay that much!") }) public double calculateCover(final double damage) { // some calculations }
public double getMaximumReportableDamage() { // some value }
public double getRemainingMoney() { // some value }
}