From aedc0ad573440b541ed2e37d7d81bab32ef3172c Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 25 Jul 2008 03:43:32 +0000 Subject: Compare BigDecimal properties for equality using compareTo. --- src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main/java/com/amazon') diff --git a/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java b/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java index a99ea56..82be9f2 100644 --- a/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java +++ b/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java @@ -21,6 +21,7 @@ import java.util.HashSet; import java.util.Set; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.math.BigDecimal; import org.cojen.classfile.ClassFile; import org.cojen.classfile.Modifiers; @@ -448,6 +449,11 @@ public class CodeBuilderUtil { b.invokeVirtual(TypeDesc.DOUBLE.toObjectType(), "compareTo", TypeDesc.INT, new TypeDesc[] {TypeDesc.DOUBLE.toObjectType()}); return choice ? "==" : "!="; + } else if (BigDecimal.class.isAssignableFrom(fieldType.toClass())) { + // Call compareTo to disregard scale. + TypeDesc bdType = TypeDesc.forClass(BigDecimal.class); + b.invokeVirtual(bdType, "compareTo", TypeDesc.INT, new TypeDesc[] {bdType}); + return choice ? "==" : "!="; } else { TypeDesc[] params = {TypeDesc.OBJECT}; if (fieldType.toClass() != null) { -- cgit v1.2.3