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