|
@@ -1,7 +1,12 @@
|
|
|
package com.sagacloud.util.math;
|
|
|
|
|
|
public class ValueObjectUtil {
|
|
|
+
|
|
|
public static ValueObject compute(String operator, ValueObject a, ValueObject b) {
|
|
|
+ if (a.is_null() || b.is_null()) {
|
|
|
+ return new ValueObject(null);
|
|
|
+ }
|
|
|
+
|
|
|
ValueObject result = new ValueObject();
|
|
|
if (a.type == 0 && b.type == 0) {
|
|
|
if (operator.equals("+")) {
|
|
@@ -44,7 +49,36 @@ public class ValueObjectUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public static boolean stringcompare(String operator, ValueObject b) {
|
|
|
+ if (operator.equals("==")) {
|
|
|
+ return b.stringValue == null;
|
|
|
+ } else if (operator.equals("!=")) {
|
|
|
+ return b.stringValue != null;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public static boolean stringcompare(String operator, ValueObject a, ValueObject b) {
|
|
|
+ if (a.is_null() && b.is_null()) {
|
|
|
+ if (operator.equals("==")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else if (a.is_null()) {
|
|
|
+ if (operator.equals("<") || operator.equals("<=") || operator.equals("!=")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else if (b.is_null()) {
|
|
|
+ if (operator.equals(">") || operator.equals(">=") || operator.equals("!=")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
int cmp = a.stringValue.compareTo(b.stringValue);
|
|
|
if (operator.equals("<")) {
|
|
|
return cmp < 0;
|
|
@@ -62,7 +96,36 @@ public class ValueObjectUtil {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public static boolean compare(String operator, ValueObject b) {
|
|
|
+ if (operator.equals("==")) {
|
|
|
+ return b.stringValue == null;
|
|
|
+ } else if (operator.equals("!=")) {
|
|
|
+ return b.stringValue != null;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public static boolean compare(String operator, ValueObject a, ValueObject b) {
|
|
|
+ if (a.is_null() && b.is_null()) {
|
|
|
+ if (operator.equals("==")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else if (a.is_null()) {
|
|
|
+ if (operator.equals("<") || operator.equals("<=") || operator.equals("!=")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else if (b.is_null()) {
|
|
|
+ if (operator.equals(">") || operator.equals(">=") || operator.equals("!=")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (a.type == 0 && b.type == 0) {
|
|
|
if (operator.equals("<")) {
|
|
|
return a.intValue < b.intValue;
|