CustomerLogInViewPopulator.java
package org.andromda.samples.carrental.customers.web.login;
/**
* Provides the ability to populate any view in the Customer LogIn
*/
public final class CustomerLogInViewPopulator
{
/**
* Map fields from CustomerLoginAuthenticateFormImpl form
* to CustomerLoginAuthenticateFormImpl form
*
* @param fromForm origin form
* @param toForm destiny form
*/
public static void populateForm(CustomerLoginAuthenticateFormImpl fromForm, CustomerLoginAuthenticateFormImpl toForm)
{
if(fromForm.isCustomerNoSet())
{
toForm.setCustomerNo(fromForm.getCustomerNo());
}
if(fromForm.isPasswordSet())
{
toForm.setPassword(fromForm.getPassword());
}
}
/**
* Map fields from CustomerLogInFormImpl form
* to CustomerLoginAuthenticateFormImpl form
*
* @param fromForm origin form
* @param toForm destiny form
*/
public static void populateForm(CustomerLogInFormImpl fromForm, CustomerLoginAuthenticateFormImpl toForm)
{
if(fromForm.isCustomerNoSet())
{
toForm.setCustomerNo(fromForm.getCustomerNo());
}
if(fromForm.isPasswordSet())
{
toForm.setPassword(fromForm.getPassword());
}
}
/**
* Populates the view using the appropriate view populator.
*
* @param fromForm the origin form
* @param toForm the destiny form
*/
public static void populateForm(Object fromForm, CustomerLoginAuthenticateFormImpl toForm)
{
if(fromForm instanceof CustomerLoginAuthenticateFormImpl)
{
populateForm((CustomerLoginAuthenticateFormImpl)fromForm,toForm);
}
else if(fromForm instanceof CustomerLogInFormImpl)
{
populateForm((CustomerLogInFormImpl)fromForm,toForm);
}
}
}