package mapper;
import api.v1.Customer;
import exceptions.PoseidonException;
import models.CustomerModel;
import play.mvc.Http;
import java.util.ArrayList;
import java.util.List;
public class CustomerMapper {
public List<Customer> mapToApi(List<CustomerModel> mCustomers) {
List<Customer> customerList = new ArrayList<>();
for (CustomerModel mCustomer : mCustomers) {
Customer customer = mapToApi(mCustomer);
customerList.add(customer);
}
return customerList;
}
public Customer mapToApi(CustomerModel mCustomer) {
Customer customer = new Customer();
customer.id = mCustomer.id;
customer.name = mCustomer.name;
customer.username = mCustomer.username;
customer.password = mCustomer.password;
customer.info = mCustomer.info;
customer.customer_number = mCustomer.customer_number;
return customer;
}
public CustomerModel mapToModel(Customer customer, CustomerModel model) {
if (model == null) model = new CustomerModel();
model.name = customer.name;
model.username = customer.username;
model.password = customer.password;
model.info = customer.info;
model.customer_number = customer.customer_number;
return model;
}
}