All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atomicbits.scraml.gradleplugin.util.ListUtils Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.atomicbits.scraml.gradleplugin.util;

import java.util.List;

/**
 * Created by peter on 18/10/17.
 */
public class ListUtils {

    static public String mkString(List list, String delimiter) {
        return mkStringHelper(list, delimiter, new StringBuilder());
    }

    static private String mkStringHelper(List list, String delimiter, StringBuilder sb) {

        if (list == null || list.isEmpty()) {
            return sb.toString();
        } else if (list.size() == 1) {
            String head = list.get(0);
            return sb.append(head).toString();
        } else {
            String head = list.get(0);
            List tail = list.subList(1, list.size());
            return mkStringHelper(tail, delimiter, sb.append(head).append(delimiter));
        }

    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy