package info.bukova.isspst;

import org.jfree.util.Log;

public class BooleanUtils
{
	private static final String TAG = BooleanUtils.class.getSimpleName();

	public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
	{
		boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
		boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
		boolean equals = (bool1 == bool2);
		return equals;
	}

	public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
	{
		if ((b1 == null) && (b2 == null))
		{
			return true;
		}
		else if ((b1 != null) && (b2 != null))
		{
			return (b1.booleanValue() == b2.booleanValue());
		}

		return false;
	}

	public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
	{
		if (filterValue == null)
		{
			// Show all records
			return true;
		}
		
		if (value == null)
		{
			// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
			Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
			return true;
		}
		
		return (value.booleanValue() == filterValue.booleanValue());
	}
}
