View Javadoc

1   /*
2    * $Id: DefaultCreditAgency.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.examples.loanbroker.credit;
12  
13  import org.mule.examples.loanbroker.messages.CreditProfile;
14  import org.mule.examples.loanbroker.messages.Customer;
15  
16  /**
17   * Provides the credit profile for a customer.
18   */
19  public class DefaultCreditAgency implements CreditAgencyService
20  {
21       public CreditProfile getCreditProfile(Customer customer)
22       {
23           CreditProfile cp = new CreditProfile();
24           cp.setCreditHistory(getCreditHistoryLength(customer.getSsn()));
25           cp.setCreditScore(getCreditScore(customer.getSsn()));
26           return cp;
27       }
28  
29       protected int getCreditScore(int ssn)
30       {
31           int credit_score;
32  
33           credit_score = (int)(Math.random() * 600 + 300);
34  
35           return credit_score;
36       }
37  
38       protected int getCreditHistoryLength(int ssn)
39       {
40           int credit_history_length;
41  
42           credit_history_length = (int)(Math.random() * 19 + 1);
43  
44           return credit_history_length;
45       }
46  }