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

me.aifaq.commons.lang.UniqueList Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package me.aifaq.commons.lang;

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

/**
 * copy from {@link com.mongodb.util.UniqueList}
 *
 * @author Wang Wei [[email protected]]
 * @since 15:32 2017/6/16
 */
public class UniqueList extends ArrayList {

	private static final long serialVersionUID = -5142543069290180113L;

	@Override
	public boolean add(T t) {
		if (contains(t))
			return false;
		return super.add(t);
	}

	@Override
	public boolean addAll(Collection c) {
		boolean added = false;
		for (T t : c)
			added = add(t) || added;
		return added;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy