package com.crm.rely.backend.util;

import org.springframework.util.StringUtils;

/**
 * Created by max on 2020/7/29.
 */
public class NameUtil {

    public static String getName(String country, String firstName, String middleName, String lastName) {

        if (firstName == null){
            firstName = "";
        }
        if (middleName == null){
            middleName = "";
        }
        if (lastName == null){
            lastName = "";
        }

        StringBuffer stringBuffer = new StringBuffer();
        if ("CN".equals(country)){
            stringBuffer.append(lastName);
            if (!StringUtils.isEmpty(middleName)){
                stringBuffer.append(middleName);
            }
            stringBuffer.append(firstName);
        }else {
            stringBuffer.append(firstName);
            if (!StringUtils.isEmpty(middleName)){
                stringBuffer.append(" ");
                stringBuffer.append(middleName);
            }
            stringBuffer.append(" ");
            stringBuffer.append(lastName);
        }
        return stringBuffer.toString();

    }

}
