
package com.exedio.cope.lib.search;

import java.util.Date;
import java.util.TreeSet;

import com.exedio.cope.lib.BooleanAttribute;
import com.exedio.cope.lib.DateAttribute;
import com.exedio.cope.lib.DoubleAttribute;
import com.exedio.cope.lib.Function;
import com.exedio.cope.lib.IntegerFunction;
import com.exedio.cope.lib.Item;
import com.exedio.cope.lib.ItemAttribute;
import com.exedio.cope.lib.LongAttribute;
import com.exedio.cope.lib.ObjectAttribute;
import com.exedio.cope.lib.Statement;
import com.exedio.cope.lib.StringFunction;

public final class EqualCondition extends Condition
{
	public final Function function;
	public final Object value;

	public EqualCondition(final ObjectAttribute function)
	{
		this.function = function;
		this.value = null;
	}
	
	public EqualCondition(final ObjectAttribute function, final Object value)
	{
		this.function = function;
		this.value = value;
	}
	
	public EqualCondition(final StringFunction function, final String value)
	{
		this.function = function;
		this.value = value;
	}
	
	public EqualCondition(final IntegerFunction function, final Integer value)
	{
		this.function = function;
		this.value = value;
	}
	
	public EqualCondition(final LongAttribute attribute, final Long value)
	{
		this.function = attribute;
		this.value = value;
	}
	
	public EqualCondition(final BooleanAttribute attribute, final Boolean value)
	{
		this.function = attribute;
		this.value = value;
	}
	
	public EqualCondition(final DoubleAttribute attribute, final Double value)
	{
		this.function = attribute;
		this.value = value;
	}
	
	public EqualCondition(final DateAttribute attribute, final Date value)
	{
		this.function = attribute;
		this.value = value;
	}
	
	public EqualCondition(final ItemAttribute attribute, final Item value)
	{
		this.function = attribute;
		this.value = value;
	}
	
	public final void appendStatement(final Statement bf)
	{
		bf.append(function);
		if(value!=null)
			bf.append('=').
				appendValue(function, value);
		else
			bf.append(" is null");
	}

	public final void check(final TreeSet fromTypes)
	{
		check(function, fromTypes);
	}

	public final String toString()
	{
		return function.getName() + "='" + value + '\'';
	}
	
}

@@ -35,31 +35,8 @@
 h;%0A%0A
-import java.util.Date;%0A
 impo
@@ -89,308 +89,60 @@
 lib.
-BooleanAttribute;%0Aimport com.exedio.cope.lib.DateAttribute;%0Aimport com.exedio.cope.lib.DoubleAttribute;%0Aimport com.exedio.cope.lib.Function;%0Aimport com.exedio.cope.lib.IntegerFunction;%0Aimport com.exedio.cope.lib.Item;%0Aimport com.exedio.cope.lib.ItemAttribute;%0Aimport com.exedio.cope.lib.LongAttribute
+Function;%0Aimport com.exedio.cope.lib.IntegerFunction
 ;%0Aim
@@ -896,673 +896,8 @@
 %7D%0A%09%0A
-%09public EqualCondition(final LongAttribute attribute, final Long value)%0A%09%7B%0A%09%09this.function = attribute;%0A%09%09this.value = value;%0A%09%7D%0A%09%0A%09public EqualCondition(final BooleanAttribute attribute, final Boolean value)%0A%09%7B%0A%09%09this.function = attribute;%0A%09%09this.value = value;%0A%09%7D%0A%09%0A%09public EqualCondition(final DoubleAttribute attribute, final Double value)%0A%09%7B%0A%09%09this.function = attribute;%0A%09%09this.value = value;%0A%09%7D%0A%09%0A%09public EqualCondition(final DateAttribute attribute, final Date value)%0A%09%7B%0A%09%09this.function = attribute;%0A%09%09this.value = value;%0A%09%7D%0A%09%0A%09public EqualCondition(final ItemAttribute attribute, final Item value)%0A%09%7B%0A%09%09this.function = attribute;%0A%09%09this.value = value;%0A%09%7D%0A%09%0A
 %09pub

remove some not-needed constructors