package info.bukova.isspst;

import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BigDecimalUtils
{
	private final static Logger log = LoggerFactory.getLogger(BigDecimalUtils.class.getName());

	public static boolean isEqualByDecimalForFilter(BigDecimal value, BigDecimal search)
	{
		if (search == null)
		{
			return true;
		}

		if (value == null)
		{
			value = BigDecimal.ZERO;
		}

		String valueS = value.toPlainString();
		String searchS = search.toPlainString();
		boolean result = (valueS.compareTo(searchS) == 0);

		String s = "search='" + searchS + "', value='" + valueS + "', equal=" + (result ? "true" : "false");
		log.info(s);

		return result;
	}
}
