package com.arrebol.taxiservicios.wrapper;

import com.arrebol.taxiservicios.model.core.User;
import java.io.Serializable;

/**
 *
 * @author Carlos Janitzio Zavala Lopez
 */
public class UserWrapper implements Serializable {

    private static final long serialVersionUID = 8727018969987902326L;

    private String id;
    private String userName;
    private String fullName;
    private String avatar;

    /**
     *
     * @param userName role
     * @param fullName complete name
     * @param avatar image to show.
     */
    public UserWrapper(String userName, String fullName, String avatar) {
        this.userName = userName;
        this.fullName = fullName;
        this.avatar = avatar;
    }

    public UserWrapper(User user) {
        userName = user.getUserName();
        avatar = user.getPerson().getAvatar();

        StringBuilder parseName = new StringBuilder(user.getPerson().getFirstName() + " ");

        parseName.append(null == user.getPerson().getSecondName() ? "" : user.getPerson().getSecondName() + " ");
        parseName.append(null == user.getPerson().getLastName() ? "" : user.getPerson().getLastName() + " ");
        parseName.append(null == user.getPerson().getMiddleName() ? "" : user.getPerson().getMiddleName());

        fullName = parseName.toString();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

}
