summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-07-25 03:43:32 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-07-25 03:43:32 +0000
commitaedc0ad573440b541ed2e37d7d81bab32ef3172c (patch)
tree762cb25d6b313a44e46a69491f2d0d0ef177a836
parent2dac6dea22e8ad78999913c4b4b1dd2e87c43700 (diff)
Compare BigDecimal properties for equality using compareTo.
-rw-r--r--src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java6
1 files changed, 6 insertions, 0 deletions
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) {