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

com.almondtools.util.collections.ArrayLists Maven / Gradle / Ivy

Go to download

Regular expression matchers, searcher, lexers based on deterministic finite automata

There is a newer version: 0.3.3
Show newest version
package com.almondtools.util.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class ArrayLists {

	private ArrayList list;

	private ArrayLists() {
		this.list = new ArrayList();
	}

	private ArrayLists(Collection list) {
		this.list = new ArrayList(list);
	}

	public static  ArrayLists list(T... elements) {
		return new ArrayLists(java.util.Arrays.asList(elements));
	}

	public static  ArrayLists empty() {
		return new ArrayLists();
	}

	public static  ArrayList of(T... elements) {
		return new ArrayList(java.util.Arrays.asList(elements));
	}

	public static  ArrayList of(Predicate cond, T... elements) {
		ArrayList list = new ArrayList();
		for (T element : elements) {
			if (cond.evaluate(element)) {
				list.add(element);
			}
		}
		return list;
	}
	
	public ArrayLists add(T add) {
		list.add(add);
		return this;
	}

	public ArrayLists addConditional(boolean b, T add) {
		list.add(add);
		return this;
	}

	public ArrayLists addAll(T... add) {
		list.addAll(java.util.Arrays.asList(add));
		return this;
	}

	public ArrayLists addAll(List add) {
		list.addAll(add);
		return this;
	}

	public ArrayLists remove(T remove) {
		list.remove(remove);
		return this;
	}

	public ArrayLists removeConditional(boolean b, T remove) {
		if (b) {
			list.remove(remove);
		}
		return this;
	}

	public ArrayLists removeAll(T... remove) {
		list.removeAll(java.util.Arrays.asList(remove));
		return this;
	}

	public ArrayLists removeAll(List remove) {
		list.removeAll(remove);
		return this;
	}

	public ArrayLists retain(T retain) {
		Set retainAll = new HashSet();
		retainAll.add(retain);
		list.retainAll(retainAll);
		return this;
	}

	public ArrayLists retainConditional(boolean b, T retain) {
		if (b) {
			Set retainAll = new HashSet();
			retainAll.add(retain);
			list.retainAll(retainAll);
		}
		return this;
	}

	public ArrayLists retainAll(List retain) {
		list.retainAll(retain);
		return this;
	}

	public ArrayLists retainAll(T... retain) {
		list.retainAll(java.util.Arrays.asList(retain));
		return this;
	}

	public ArrayList build() {
		return list;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy