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

org.beetl.sql.clazz.kit.CaseInsensitiveOrderSet Maven / Gradle / Ivy

There is a newer version: 3.30.13-RELEASE
Show newest version
package org.beetl.sql.clazz.kit;

import java.util.Collection;
import java.util.LinkedHashSet;

public class CaseInsensitiveOrderSet extends LinkedHashSet {

	private static final long serialVersionUID = 9178606903603606032L;

	private final LinkedHashSet lowerSet = new LinkedHashSet();
	
	String first = null;

	//Override
	@Override
	public boolean contains(Object value) {
		
		String t = (String)value;
		return lowerSet.contains(t.toLowerCase());
	}

	//Override
	@Override
	public boolean add(String value) {
		if(value==null){
			throw new NullPointerException(value);
		}
		boolean b = lowerSet.add(value.toLowerCase());
		if (b) {
			super.add(value);
		}
		
		if(first==null){
			first = value;
		}
		return b;

	}

	//Override
	@Override
	public boolean addAll(Collection c) {
		Collection t = (Collection) c;
		for (String s : t) {
			lowerSet.add(s.toLowerCase());
		}
		return super.addAll(c);

	}

	public String getFirst() {
		return first;
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy