package com.ruoyi.web.modules.trading.support;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.trading.domain.AppYakMarketQuoteRow;

/**
 * 牦牛行情市场位置拼接。
 */
public final class YakMarketLocationSupport
{
    private YakMarketLocationSupport()
    {
    }

    public static String build(AppYakMarketQuoteRow row)
    {
        if (row == null)
        {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        appendPart(sb, row.getProvinceName());
        appendPart(sb, row.getCityName());
        appendPart(sb, row.getCountyName());
        if (StringUtils.isNotEmpty(row.getMarketDetailAddress()))
        {
            if (sb.length() > 0)
            {
                sb.append(' ');
            }
            sb.append(row.getMarketDetailAddress().trim());
        }
        return sb.toString();
    }

    private static void appendPart(StringBuilder sb, String part)
    {
        if (StringUtils.isEmpty(part))
        {
            return;
        }
        if (sb.length() > 0)
        {
            sb.append(' ');
        }
        sb.append(part.trim());
    }
}
