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

net.anotheria.anodoc.query2.QueryInProperty Maven / Gradle / Ivy

package net.anotheria.anodoc.query2;

import java.util.Collection;

import net.anotheria.util.StringUtils;

/**
 * Difference with QueryProperty is collection of possible values instead of single value.
 * 
 * IMPORTANT:Tested only in postgressql!
 * 
 * @author denis
 *
 */
public class QueryInProperty extends QueryProperty{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8649073486730051958L;

	public QueryInProperty(String aName, Collection aValues){
		super(aName, aValues);
	}

	@Override
	public boolean doesMatch(Object o) {
		return o== null ?getOriginalValue() == null :
			getListValue().contains(o);
	}

	@Override
	public String getComparator() {
		return " IN ";
	}

	@Override
	public Object getValue() {
		Collection values = getListValue(); 
		return StringUtils.surroundWith(StringUtils.concatenateTokens(values, ',', '\'', '\''), '(', ')');
	}
	
	@SuppressWarnings("unchecked")
	private Collection getListValue(){
		return (Collection) getOriginalValue();
	}

	@Override
	public boolean unprepaireable() {
		return true;
	}
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy