package com.ihaoin.hooloo.device.util;

import java.util.List;

public class StringAppend {
    public static final String SPLITER_ENTER = "\n";
    private StringBuffer stringBuffer = new StringBuffer();
    private String spliter = "";

    public StringAppend(String spliter) {
        this.spliter = spliter;
    }

    public StringAppend append(String string) {
        if (StringUtils.isEmpty(string)) {
            return this;
        }
        if (stringBuffer.length() > 0) {
            stringBuffer.append(spliter);
        }
        stringBuffer.append(string);
        return this;
    }

    public StringAppend append(List<String> list) {
        if (list == null || list.isEmpty()) {
            return this;
        }
        list.forEach(item -> {
            this.append(item);
        });
        return this;
    }

    @Override
    public String toString() {
        return stringBuffer.toString();
    }
}
