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

com.kenshoo.pl.entity.equalityfunctions.ComparableEqualityFunction Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
package com.kenshoo.pl.entity.equalityfunctions;

import org.apache.commons.lang3.ObjectUtils;

/**
 * This Function overrides the default Bid Field comparison of using {@code equals()} with {@code compare()}.
 * It is needed because BigDecimals' {@code equals()} takes into account the number's scale, which means 
* {@code 0.0 != 0.00}
* This can cause strange behaviours, especially when comparing UI values against DB values.
* Using {@code compare()} instead solves this problem as it ignores scale when the values are the same.

* * Created by yuvalr on 5/22/16. */ public class ComparableEqualityFunction> implements EntityValueEqualityFunction { private static final ComparableEqualityFunction INSTANCE = new ComparableEqualityFunction(); private ComparableEqualityFunction() { } @Override public Boolean apply(T bigDecimal, T bigDecimal2) { return ObjectUtils.compare(bigDecimal, bigDecimal2) == 0; } public static > ComparableEqualityFunction getInstance() { //noinspection unchecked return INSTANCE; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy