Coverage Report - org.mule.samples.voipservice.to.CustomerTO
 
Classes in this File Line Coverage Branch Coverage Complexity
CustomerTO
0%
0/54
0%
0/10
1.462
 
 1  
 /*
 2  
  * $Id: CustomerTO.java 7963 2007-08-21 08:53:15Z 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.samples.voipservice.to;
 12  
 
 13  
 import org.mule.samples.voipservice.LocaleMessage;
 14  
 
 15  
 import java.io.Serializable;
 16  
 import java.util.ArrayList;
 17  
 import java.util.List;
 18  
 
 19  
 public class CustomerTO implements Serializable, Cloneable
 20  
 {
 21  
     /**
 22  
      * Serial version
 23  
      */
 24  
     private static final long serialVersionUID = -7760891283901332894L;
 25  
 
 26  
     private String firstName;
 27  
     private String lastName;
 28  
     private AddressTO addressTO;
 29  
 
 30  
     private static final List CUSTOMERS;
 31  
 
 32  
     static
 33  
     {
 34  0
         CUSTOMERS = new ArrayList();
 35  
 
 36  0
         CUSTOMERS.add(new CustomerTO("Binil", "Das"));
 37  0
         CUSTOMERS.add(new CustomerTO("Rajesh", "Warrier"));
 38  0
         CUSTOMERS.add(new CustomerTO("Jacob", "Oommen"));
 39  0
         CUSTOMERS.add(new CustomerTO("Shahanas", "Mohammed"));
 40  0
         CUSTOMERS.add(new CustomerTO("Sowmya", "Hubert"));
 41  0
         CUSTOMERS.add(new CustomerTO("Ann", "Binil"));
 42  0
         CUSTOMERS.add(new CustomerTO("Rajesh", "Ravindran"));
 43  0
         CUSTOMERS.add(new CustomerTO("Renjit", "Hubert"));
 44  0
         CUSTOMERS.add(new CustomerTO("Brijesh", "Deb"));
 45  0
         CUSTOMERS.add(new CustomerTO("Rama", "Varma"));
 46  0
     }
 47  
 
 48  
     public CustomerTO()
 49  
     {
 50  0
         super();
 51  0
     }
 52  
 
 53  
     public CustomerTO(String firstName, String lastName)
 54  
     {
 55  0
         this(firstName, lastName, null);
 56  0
     }
 57  
 
 58  
     public CustomerTO(String firstName, String lastName, AddressTO addressTO)
 59  0
     {
 60  0
         this.firstName = firstName;
 61  0
         this.lastName = lastName;
 62  0
         this.addressTO = addressTO;
 63  0
     }
 64  
 
 65  
     public String getName()
 66  
     {
 67  
 
 68  0
         String name = firstName;
 69  0
         String lastName = null;
 70  0
         if (this.lastName == null)
 71  
         {
 72  0
             lastName = "";
 73  
         }
 74  
         else
 75  
         {
 76  0
             lastName = this.lastName;
 77  
         }
 78  0
         return name + " " + lastName;
 79  
     }
 80  
 
 81  
     public void setFirstName(String firstName)
 82  
     {
 83  0
         this.firstName = firstName;
 84  0
     }
 85  
 
 86  
     public String getFirstName()
 87  
     {
 88  0
         return firstName;
 89  
     }
 90  
 
 91  
     public void setLastName(String lastName)
 92  
     {
 93  0
         this.lastName = lastName;
 94  0
     }
 95  
 
 96  
     public String getLastName()
 97  
     {
 98  0
         return lastName;
 99  
     }
 100  
 
 101  
     public void setAddress(AddressTO addressTO)
 102  
     {
 103  0
         this.addressTO = addressTO;
 104  0
     }
 105  
 
 106  
     public AddressTO getAddress()
 107  
     {
 108  0
         return addressTO;
 109  
     }
 110  
 
 111  
     public Object clone()
 112  
     {
 113  0
         Object clone = null;
 114  
         try
 115  
         {
 116  0
             clone = super.clone();
 117  0
             if (null != addressTO)
 118  
             {
 119  0
                 ((CustomerTO)clone).setAddress((AddressTO)addressTO.clone());
 120  
             }
 121  
         }
 122  0
         catch (CloneNotSupportedException cloneNotSupportedException)
 123  
         {
 124  
             // too bad
 125  0
         }
 126  0
         return clone;
 127  
     }
 128  
 
 129  
     public String toString()
 130  
     {
 131  0
         StringBuffer stringBuffer = new StringBuffer();
 132  0
         if (this.firstName != null)
 133  
         {
 134  0
             stringBuffer.append(LocaleMessage.getFirstNameCaption(getName()));
 135  
         }
 136  0
         if (this.addressTO != null)
 137  
         {
 138  0
             stringBuffer.append(LocaleMessage.getAddressCaption(addressTO));
 139  
         }
 140  0
         return stringBuffer.toString();
 141  
     }
 142  
 
 143  
     public static CustomerTO getRandomCustomer()
 144  
     {
 145  
 
 146  0
         int index = new Double(Math.random() * 10).intValue();
 147  
         // AddressTO addressTO = (AddressTO) ADDRESSES.get(index);
 148  0
         CustomerTO customerTO = (CustomerTO)((CustomerTO)CUSTOMERS.get(index)).clone();
 149  0
         if (null == customerTO.getAddress())
 150  
         {
 151  0
             customerTO.setAddress(AddressTO.getRandomAddress());
 152  
         }
 153  0
         return customerTO;
 154  
     }
 155  
 
 156  
 }