notEqual method

  1. @override
Variant notEqual(
  1. Variant value1,
  2. Variant value2
)
override

Performs '<>' operation for two variants.

  • value1 The first operand for this operation.
  • value2 The second operand for this operation. Returns A result variant object.

Implementation

@override
Variant notEqual(Variant value1, Variant value2) {
  var result = Variant();

  // Processes VariantType.Null values.
  if (value1.type == VariantType.Null && value2.type == VariantType.Null) {
    result.asBoolean = false;
    return result;
  }
  if (value1.type == VariantType.Null || value2.type == VariantType.Null) {
    result.asBoolean = true;
    return result;
  }

  // Converts second operant to the type of the first operand.
  value2 = convert(value2, value1.type);

  // Performs operation.
  switch (value1.type) {
    case VariantType.Integer:
      result.asBoolean = value1.asInteger != value2.asInteger;
      return result;
    case VariantType.Long:
      result.asBoolean = value1.asLong != value2.asLong;
      return result;
    case VariantType.Float:
      result.asBoolean = value1.asFloat != value2.asFloat;
      return result;
    case VariantType.Double:
      result.asBoolean = value1.asDouble != value2.asDouble;
      return result;
    case VariantType.String:
      result.asBoolean = value1.asString != value2.asString;
      return result;
    case VariantType.TimeSpan:
      result.asBoolean = value1.asTimeSpan != value2.asTimeSpan;
      return result;
    case VariantType.DateTime:
      result.asBoolean = value1.asDateTime.millisecondsSinceEpoch !=
          value2.asDateTime.millisecondsSinceEpoch;
      return result;
    case VariantType.Boolean:
      result.asBoolean = value1.asBoolean != value2.asBoolean;
      return result;
    case VariantType.Object:
      result.asObject = value1.asObject != value2.asObject;
      return result;
    default:
      throw Exception("Operation '<>' is not supported for type " +
          typeToString(value1.type));
  }
}