ExprBooleanValue.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
7
package org.opensearch.sql.data.model;
8
9
import com.google.common.base.Objects;
10
import org.opensearch.sql.data.type.ExprCoreType;
11
import org.opensearch.sql.data.type.ExprType;
12
13
/**
14
 * Expression Boolean Value.
15
 */
16
public class ExprBooleanValue extends AbstractExprValue {
17
  private static final ExprBooleanValue TRUE = new ExprBooleanValue(true);
18
  private static final ExprBooleanValue FALSE = new ExprBooleanValue(false);
19
20
  private final Boolean value;
21
22
  private ExprBooleanValue(Boolean value) {
23
    this.value = value;
24
  }
25
26
  public static ExprBooleanValue of(Boolean value) {
27 2 1. of : negated conditional → KILLED
2. of : replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::of → KILLED
    return value ? TRUE : FALSE;
28
  }
29
30
  @Override
31
  public Object value() {
32 1 1. value : replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::value → KILLED
    return value;
33
  }
34
35
  @Override
36
  public ExprType type() {
37 1 1. type : replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::type → KILLED
    return ExprCoreType.BOOLEAN;
38
  }
39
40
  @Override
41
  public Boolean booleanValue() {
42 2 1. booleanValue : replaced Boolean return with False for org/opensearch/sql/data/model/ExprBooleanValue::booleanValue → KILLED
2. booleanValue : replaced Boolean return with True for org/opensearch/sql/data/model/ExprBooleanValue::booleanValue → KILLED
    return value;
43
  }
44
45
  @Override
46
  public String toString() {
47 1 1. toString : replaced return value with "" for org/opensearch/sql/data/model/ExprBooleanValue::toString → KILLED
    return value.toString();
48
  }
49
50
  @Override
51
  public int compare(ExprValue other) {
52 1 1. compare : replaced int return with 0 for org/opensearch/sql/data/model/ExprBooleanValue::compare → KILLED
    return Boolean.compare(value, other.booleanValue());
53
  }
54
55
  @Override
56
  public boolean equal(ExprValue other) {
57 2 1. equal : replaced boolean return with false for org/opensearch/sql/data/model/ExprBooleanValue::equal → SURVIVED
2. equal : replaced boolean return with true for org/opensearch/sql/data/model/ExprBooleanValue::equal → KILLED
    return value.equals(other.booleanValue());
58
  }
59
60
  @Override
61
  public int hashCode() {
62 1 1. hashCode : replaced int return with 0 for org/opensearch/sql/data/model/ExprBooleanValue::hashCode → KILLED
    return Objects.hashCode(value);
63
  }
64
}

Mutations

27

1.1
Location : of
Killed by : org.opensearch.sql.expression.operator.predicate.UnaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.UnaryPredicateOperatorTest]/[test-template:test_isnull_predicate(org.opensearch.sql.expression.Expression, org.opensearch.sql.expression.Expression)]/[test-template-invocation:#14]
negated conditional → KILLED

2.2
Location : of
Killed by : org.opensearch.sql.data.model.ExprNumberValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNumberValueTest]/[method:getShortValueFromIncompatibleExprValue()]
replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::of → KILLED

32

1.1
Location : value
Killed by : org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest]/[test-template:test_equal(org.opensearch.sql.data.model.ExprValue, org.opensearch.sql.data.model.ExprValue)]/[test-template-invocation:#8]
replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::value → KILLED

37

1.1
Location : type
Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[test-template:getType(org.opensearch.sql.data.model.ExprValue, org.opensearch.sql.data.type.ExprCoreType)]/[test-template-invocation:#8]
replaced return value with null for org/opensearch/sql/data/model/ExprBooleanValue::type → KILLED

42

1.1
Location : booleanValue
Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[test-template:getValue(org.opensearch.sql.data.model.ExprValue, java.util.function.Function, java.lang.Object)]/[test-template-invocation:#8]
replaced Boolean return with False for org/opensearch/sql/data/model/ExprBooleanValue::booleanValue → KILLED

2.2
Location : booleanValue
Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:natural_order_boolean_value()]
replaced Boolean return with True for org/opensearch/sql/data/model/ExprBooleanValue::booleanValue → KILLED

47

1.1
Location : toString
Killed by : org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest]/[test-template:test_xor(java.lang.Boolean, java.lang.Boolean)]/[test-template-invocation:#4]
replaced return value with "" for org/opensearch/sql/data/model/ExprBooleanValue::toString → KILLED

52

1.1
Location : compare
Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:natural_order_boolean_value()]
replaced int return with 0 for org/opensearch/sql/data/model/ExprBooleanValue::compare → KILLED

57

1.1
Location : equal
Killed by : none
replaced boolean return with false for org/opensearch/sql/data/model/ExprBooleanValue::equal → SURVIVED

2.2
Location : equal
Killed by : org.opensearch.sql.expression.operator.predicate.UnaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.UnaryPredicateOperatorTest]/[test-template:test_if_predicate(org.opensearch.sql.expression.Expression, org.opensearch.sql.expression.Expression, org.opensearch.sql.expression.Expression, org.opensearch.sql.expression.Expression)]/[test-template-invocation:#7]
replaced boolean return with true for org/opensearch/sql/data/model/ExprBooleanValue::equal → KILLED

62

1.1
Location : hashCode
Killed by : org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.predicate.BinaryPredicateOperatorTest]/[test-template:test_xor(java.lang.Boolean, java.lang.Boolean)]/[test-template-invocation:#1]
replaced int return with 0 for org/opensearch/sql/data/model/ExprBooleanValue::hashCode → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0