Class CustomBigDecimalComparator

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.math.BigDecimal a, java.math.BigDecimal b)
      Called by JaVers to compare two Values.
      java.lang.String toString​(java.math.BigDecimal value)
      This method has two roles.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomBigDecimalComparator

        public CustomBigDecimalComparator​(int significantDecimalPlaces)
    • Method Detail

      • equals

        public boolean equals​(java.math.BigDecimal a,
                              java.math.BigDecimal b)
        Description copied from interface: CustomValueComparator
        Called by JaVers to compare two Values.
        Specified by:
        equals in interface CustomValueComparator<java.math.BigDecimal>
        Parameters:
        a - not null
        b - not null
      • toString

        public java.lang.String toString​(java.math.BigDecimal value)
        Description copied from interface: CustomValueComparator
        This method has two roles. First, it is used when Values are compared in hashing contexts. Second, it is used to build Entity Ids from Values.

        Hashcode role

        When a Value class has custom toString(), it is used instead of Object.hashCode() when comparing Values in hashing contexts, so: Custom toString() implementation should be aligned with custom CustomValueComparator.equals(Object, Object) in the same way like Object.hashCode() should be aligned with Object.equals(Object).

        Entity Id role

        Each Value can serve as an Entity Id.
        When a Value has custom toString() function, it is used for creating InstanceId for Entities. If a Value doesn't have a custom toString() , default ReflectionUtil.reflectiveToString(Object)) is used.

        See full example CustomToStringExample.groovy.
        Specified by:
        toString in interface CustomValueComparator<java.math.BigDecimal>
        Parameters:
        value - not null