/*
 * Copyright (C) 2004-2005  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.exedio.cope;

import com.exedio.cope.function.SumFunction;
import com.exedio.cope.search.AndCondition;
import com.exedio.cope.search.Condition;
import com.exedio.cope.search.NotEqualCondition;
import com.exedio.cope.search.OrCondition;

/**
 * Utility class for creating conditions.
 * May be subclassed to access methods without class qualifier.
 * 
 * @author Ralf Wiebicke
 */
public abstract class Cope
{
	Cope()
	{}

	public static final NotEqualCondition isNotNull(final ObjectAttribute attribute)
	{
		return new NotEqualCondition(attribute, null);
	}
	
	public static final AndCondition and(final Condition condition1, final Condition condition2)
	{
		return new AndCondition(new Condition[]{condition1, condition2});
	}
	
	public static final AndCondition and(final Condition condition1, final Condition condition2, final Condition condition3)
	{
		return new AndCondition(new Condition[]{condition1, condition2, condition3});
	}
	
	public static final OrCondition or(final Condition condition1, final Condition condition2)
	{
		return new OrCondition(new Condition[]{condition1, condition2});
	}
	
	public static final OrCondition or(final Condition condition1, final Condition condition2, final Condition condition3)
	{
		return new OrCondition(new Condition[]{condition1, condition2, condition3});
	}
	
	public static final AttributeValue attributeValue(final StringAttribute attribute, final String value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final BooleanAttribute attribute, final Boolean value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final BooleanAttribute attribute, final boolean value)
	{
		return new AttributeValue(attribute, value ? Boolean.TRUE : Boolean.FALSE);
	}
	
	public static final AttributeValue attributeValue(final IntegerAttribute attribute, final Integer value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final IntegerAttribute attribute, final int value)
	{
		return new AttributeValue(attribute, new Integer(value));
	}
	
	public static final AttributeValue attributeValue(final LongAttribute attribute, final Long value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final LongAttribute attribute, final long value)
	{
		return new AttributeValue(attribute, new Long(value));
	}
	
	public static final AttributeValue attributeValue(final DoubleAttribute attribute, final Double value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final DoubleAttribute attribute, final double value)
	{
		return new AttributeValue(attribute, new Double(value));
	}
	
	public static final AttributeValue attributeValue(final ItemAttribute attribute, final Item value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final AttributeValue attributeValue(final EnumAttribute attribute, final EnumValue value)
	{
		return new AttributeValue(attribute, value);
	}
	
	public static final SumFunction sum(final IntegerFunction addend1, final IntegerFunction addend2)
	{
		return new SumFunction(new IntegerFunction[]{addend1, addend2});
	}

	public static final SumFunction sum(final IntegerFunction addend1, final IntegerFunction addend2, final IntegerFunction addend3)
	{
		return new SumFunction(new IntegerFunction[]{addend1, addend2, addend3});
	}

}

@@ -1373,762 +1373,8 @@
 %7D%0A%09%0A
-%09public static final AndCondition and(final Condition condition1, final Condition condition2)%0A%09%7B%0A%09%09return new AndCondition(new Condition%5B%5D%7Bcondition1, condition2%7D);%0A%09%7D%0A%09%0A%09public static final AndCondition and(final Condition condition1, final Condition condition2, final Condition condition3)%0A%09%7B%0A%09%09return new AndCondition(new Condition%5B%5D%7Bcondition1, condition2, condition3%7D);%0A%09%7D%0A%09%0A%09public static final OrCondition or(final Condition condition1, final Condition condition2)%0A%09%7B%0A%09%09return new OrCondition(new Condition%5B%5D%7Bcondition1, condition2%7D);%0A%09%7D%0A%09%0A%09public static final OrCondition or(final Condition condition1, final Condition condition2, final Condition condition3)%0A%09%7B%0A%09%09return new OrCondition(new Condition%5B%5D%7Bcondition1, condition2, condition3%7D);%0A%09%7D%0A%09%0A
 %09pub
@@ -3169,32 +3169,786 @@
 e, value);%0A%09%7D%0A%09%0A
+%09public static final AndCondition and(final Condition condition1, final Condition condition2)%0A%09%7B%0A%09%09return new AndCondition(new Condition%5B%5D%7Bcondition1, condition2%7D);%0A%09%7D%0A%09%0A%09public static final AndCondition and(final Condition condition1, final Condition condition2, final Condition condition3)%0A%09%7B%0A%09%09return new AndCondition(new Condition%5B%5D%7Bcondition1, condition2, condition3%7D);%0A%09%7D%0A%09%0A%09public static final OrCondition or(final Condition condition1, final Condition condition2)%0A%09%7B%0A%09%09return new OrCondition(new Condition%5B%5D%7Bcondition1, condition2%7D);%0A%09%7D%0A%09%0A%09public static final OrCondition or(final Condition condition1, final Condition condition2, final Condition condition3)%0A%09%7B%0A%09%09return new OrCondition(new Condition%5B%5D%7Bcondition1, condition2, condition3%7D);%0A%09%7D%0A%09%0A
 %09public static f

move and/or methods below attributeValue methods