View Javadoc

1   /**
2    * Extension Point initial generated by Mod4j at: Tue Jul 01 09:08:09 CEST 2008
3    */
4   
5   package org.company.thesandbox.domain.businessrules;
6   
7   import org.company.thesandbox.domain.Customer;
8   import org.springframework.validation.Errors;
9   
10  /**
11   * If Customer has one ear, he/she get a discount of 50 percent.
12   * 
13   * This ExtensionPoint is intended to be manually changed by developers.
14   * 
15   */
16  public class OneEarDiscount extends OneEarDiscountImplBase {
17  
18      /**
19       * {@inheritDoc}
20       */
21      public void validate(Object target, Errors errors) {
22  
23          Customer cust = (Customer) target;
24          if (cust.getNumberOfEars() == 1 && cust.getDiscountPercentage() != 50) {
25              errors.rejectValue("discountPercentage", "businessrule.OneEarDiscount.not.valid", new Integer[] {
26                      new Integer(50), new Integer(cust.getDiscountPercentage()) }, "discountPercentage"
27                      + " for Customers with one ear should be " + 50 + ", but was " + cust.getDiscountPercentage());
28          }
29  
30      }
31  
32  }