ExprValue.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 java.io.Serializable;
10
import java.time.Instant;
11
import java.time.LocalDate;
12
import java.time.LocalDateTime;
13
import java.time.LocalTime;
14
import java.time.temporal.TemporalAmount;
15
import java.util.List;
16
import java.util.Map;
17
import org.opensearch.sql.data.type.ExprCoreType;
18
import org.opensearch.sql.data.type.ExprType;
19
import org.opensearch.sql.exception.ExpressionEvaluationException;
20
import org.opensearch.sql.storage.bindingtuple.BindingTuple;
21
22
/**
23
 * The definition of the Expression Value.
24
 */
25
public interface ExprValue extends Serializable, Comparable<ExprValue> {
26
  /**
27
   * Get the Object value of the Expression Value.
28
   */
29
  Object value();
30
31
  /**
32
   * Get the {@link ExprCoreType} of the Expression Value.
33
   */
34
  ExprType type();
35
36
  /**
37
   * Is null value.
38
   *
39
   * @return true: is null value, otherwise false
40
   */
41
  default boolean isNull() {
42 1 1. isNull : replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isNull → KILLED
    return false;
43
  }
44
45
  /**
46
   * Is missing value.
47
   *
48
   * @return true: is missing value, otherwise false
49
   */
50
  default boolean isMissing() {
51 1 1. isMissing : replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isMissing → KILLED
    return false;
52
  }
53
54
  /**
55
   * Is Number value.
56
   *
57
   * @return true: is number value, otherwise false
58
   */
59
  default boolean isNumber() {
60 1 1. isNumber : replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isNumber → KILLED
    return false;
61
  }
62
63
  /**
64
   * Get the {@link BindingTuple}.
65
   */
66
  default BindingTuple bindingTuples() {
67 1 1. bindingTuples : replaced return value with null for org/opensearch/sql/data/model/ExprValue::bindingTuples → KILLED
    return BindingTuple.EMPTY;
68
  }
69
70
  /**
71
   * Get byte value.
72
   */
73
  default Byte byteValue() {
74
    throw new ExpressionEvaluationException(
75
        "invalid to get byteValue from value of type " + type());
76
  }
77
78
  /**
79
   * Get short value.
80
   */
81
  default Short shortValue() {
82
    throw new ExpressionEvaluationException(
83
        "invalid to get shortValue from value of type " + type());
84
  }
85
86
  /**
87
   * Get integer value.
88
   */
89
  default Integer integerValue() {
90
    throw new ExpressionEvaluationException(
91
        "invalid to get integerValue from value of type " + type());
92
  }
93
94
  /**
95
   * Get long value.
96
   */
97
  default Long longValue() {
98
    throw new ExpressionEvaluationException(
99
        "invalid to get longValue from value of type " + type());
100
  }
101
102
  /**
103
   * Get float value.
104
   */
105
  default Float floatValue() {
106
    throw new ExpressionEvaluationException(
107
        "invalid to get floatValue from value of type " + type());
108
  }
109
110
  /**
111
   * Get float value.
112
   */
113
  default Double doubleValue() {
114
    throw new ExpressionEvaluationException(
115
        "invalid to get doubleValue from value of type " + type());
116
  }
117
118
  /**
119
   * Get string value.
120
   */
121
  default String stringValue() {
122
    throw new ExpressionEvaluationException(
123
        "invalid to get stringValue from value of type " + type());
124
  }
125
126
  /**
127
   * Get boolean value.
128
   */
129
  default Boolean booleanValue() {
130
    throw new ExpressionEvaluationException(
131
        "invalid to get booleanValue from value of type " + type());
132
  }
133
134
  /**
135
   * Get timestamp value.
136
   */
137
  default Instant timestampValue() {
138
    throw new ExpressionEvaluationException(
139
        "invalid to get timestampValue from value of type " + type());
140
  }
141
142
  /**
143
   * Get time value.
144
   */
145
  default LocalTime timeValue() {
146
    throw new ExpressionEvaluationException(
147
        "invalid to get timeValue from value of type " + type());
148
  }
149
150
  /**
151
   * Get date value.
152
   */
153
  default LocalDate dateValue() {
154
    throw new ExpressionEvaluationException(
155
        "invalid to get dateValue from value of type " + type());
156
  }
157
158
  /**
159
   * Get datetime value.
160
   */
161
  default LocalDateTime datetimeValue() {
162
    throw new ExpressionEvaluationException(
163
        "invalid to get datetimeValue from value of type " + type());
164
  }
165
166
  /**
167
   * Get interval value.
168
   */
169
  default TemporalAmount intervalValue() {
170
    throw new ExpressionEvaluationException(
171
        "invalid to get intervalValue from value of type " + type());
172
  }
173
174
  /**
175
   * Get map value.
176
   */
177
  default Map<String, ExprValue> tupleValue() {
178
    throw new ExpressionEvaluationException(
179
        "invalid to get tupleValue from value of type " + type());
180
  }
181
182
  /**
183
   * Get collection value.
184
   */
185
  default List<ExprValue> collectionValue() {
186
    throw new ExpressionEvaluationException(
187
        "invalid to get collectionValue from value of type " + type());
188
  }
189
190
  /**
191
   * Get the value specified by key from {@link ExprTupleValue}.
192
   * This method only be implemented in {@link ExprTupleValue}.
193
   */
194
  default ExprValue keyValue(String key) {
195 1 1. keyValue : replaced return value with null for org/opensearch/sql/data/model/ExprValue::keyValue → KILLED
    return ExprMissingValue.of();
196
  }
197
}

Mutations

42

1.1
Location : isNull
Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()]
replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isNull → KILLED

51

1.1
Location : isMissing
Killed by : org.opensearch.sql.data.model.ExprNullValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNullValueTest]/[method:equal()]
replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isMissing → KILLED

60

1.1
Location : isNumber
Killed by : org.opensearch.sql.data.utils.ExprValueOrderingTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.utils.ExprValueOrderingTest]/[method:order_compare_value_with_different_type()]
replaced boolean return with true for org/opensearch/sql/data/model/ExprValue::isNumber → KILLED

67

1.1
Location : bindingTuples
Killed by : org.opensearch.sql.data.model.ExprValueUtilsTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprValueUtilsTest]/[method:bindingTuples()]
replaced return value with null for org/opensearch/sql/data/model/ExprValue::bindingTuples → KILLED

195

1.1
Location : keyValue
Killed by : org.opensearch.sql.data.model.ExprNumberValueTest.[engine:junit-jupiter]/[class:org.opensearch.sql.data.model.ExprNumberValueTest]/[method:key_value()]
replaced return value with null for org/opensearch/sql/data/model/ExprValue::keyValue → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0