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

aQute.lib.collections.ExtList Maven / Gradle / Ivy

Go to download

This framework extension fragment contains an extender that facilitates the use of JRE SPI providers (components typically plugged in to the JRE through META-INF/services resources).

There is a newer version: 1.3.7
Show newest version
package aQute.lib.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class ExtList extends ArrayList {
	private static final long serialVersionUID = 1L;

	@SafeVarargs
	public ExtList(T... ts) {
		super(ts.length);
		for (T t : ts) {
			add(t);
		}
	}

	public ExtList(int size) {
		super(size);
	}

	public ExtList(Collection col) {
		super(col);
	}

	public ExtList(Iterable col) {
		for (T t : col)
			add(t);
	}

	public static ExtList from(String s) {
		// TODO make sure no \ before comma
		return from(s, "\\s*,\\s*");
	}

	public static ExtList from(String s, String delimeter) {
		ExtList result = new ExtList<>();
		String[] parts = s.split(delimeter);
		Collections.addAll(result, parts);
		return result;
	}

	public String join() {
		return join(",");
	}

	public String join(String del) {
		StringBuilder sb = new StringBuilder();
		String d = "";
		for (T t : this) {
			sb.append(d);
			d = del;
			if (t != null)
				sb.append(t);
		}
		return sb.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy