package com.tsi.app.common.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class StringUtils {

    private StringUtils() {}

    public static String getString(boolean value) {
        return value ? "1" : "0";
    }

    public static List<String> splitEmpty(String value, String separator) {
        List<String> results = new ArrayList<String>();
        StringTokenizer stringTokenizer = new StringTokenizer(value, separator);
        while (stringTokenizer.hasMoreTokens()) {
            results.add(stringTokenizer.nextToken().trim());
        }
        return results;
    }

    public static List<String> split(String value, String separator) {
        String[] splits = value.split(separator);
        List<String> results = new ArrayList<String>();
        for (int ii = 0; ii < splits.length; ii++) {
            splits[ii] = splits[ii].trim();
            if (splits[ii].length() > 0) {
                results.add(splits[ii]);
            }
        }
        return results;
    }

    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }

    public static boolean isBlank(String s) {
        return s == null || s.trim().isEmpty();
    }

}
