Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes deprecated methods #477

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/main/java/com/ezylang/evalex/data/EvaluationValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.ezylang.evalex.data;

import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.conversion.DefaultEvaluationValueConverter;
import com.ezylang.evalex.parser.ASTNode;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -87,19 +86,6 @@ public enum DataType {

DataType dataType;

/**
* Creates a new evaluation value by using the default converter and configuration.
*
* @param value Any object that the default converter can convert.
* @throws IllegalArgumentException if the data type can't be mapped.
* @see DefaultEvaluationValueConverter
* @deprecated Use {@link EvaluationValue(Object, ExpressionConfiguration)} instead.
*/
@Deprecated(since = "3.1.0", forRemoval = true)
public EvaluationValue(Object value) {
this(value, ExpressionConfiguration.defaultConfiguration());
}

/**
* Creates a new evaluation value by using the configured converter and configuration.
*
Expand Down Expand Up @@ -233,19 +219,6 @@ public static EvaluationValue structureValue(Map<?, ?> value) {
return new EvaluationValue(value, DataType.STRUCTURE);
}

/**
* Creates a new evaluation value from a double value using the specified {@link MathContext}.
*
* @param value The double value.
* @param mathContext The math context to use.
* @deprecated since 3.1.0 - Use {@link EvaluationValue(Object, ExpressionConfiguration)}.
*/
@Deprecated(since = "3.1.0", forRemoval = true)
public EvaluationValue(double value, MathContext mathContext) {
this.dataType = DataType.NUMBER;
this.value = new BigDecimal(Double.toString(value), mathContext);
}

/**
* Checks if the value is of type {@link DataType#NUMBER}.
*
Expand Down
38 changes: 18 additions & 20 deletions src/test/java/com/ezylang/evalex/data/EvaluationValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@ void testNull() {
assertDataIsCorrect(value, null, null, null);
}

@Test
@SuppressWarnings("removal")
void testDeprecatedConstructor() {
ExpressionConfiguration expressionConfiguration =
ExpressionConfiguration.builder().mathContext(new MathContext(3)).build();
EvaluationValue evaluationValue =
new EvaluationValue(3.9876, expressionConfiguration); // NOSONAR - deprecated
assertThat(evaluationValue.getNumberValue()).isEqualByComparingTo("3.99");
}

@Test
@SuppressWarnings("removal")
void testNullValueSameInstance() {
EvaluationValue nullValue1 = EvaluationValue.nullValue(); // NOSONAR - deprecated
EvaluationValue nullValue2 = EvaluationValue.nullValue(); // NOSONAR - deprecated
assertThat(nullValue1).isSameAs(nullValue2);
}

@Test
void nestedEvaluationValue() throws EvaluationException, ParseException {
EvaluationValue value1 = EvaluationValue.of("Hello", defaultConfiguration());
Expand All @@ -557,26 +575,6 @@ void nestedEvaluationValue() throws EvaluationException, ParseException {
assertThat(result.getBooleanValue()).isTrue();
}

@Test
@SuppressWarnings("removal")
void testDeprecatedDoubleMathContext() {
EvaluationValue evaluationValue64 =
new EvaluationValue(3.9876, MathContext.DECIMAL64); // NOSONAR - deprecated
assertThat(evaluationValue64.getNumberValue()).isEqualByComparingTo("3.9876");

EvaluationValue evaluationValue3 =
new EvaluationValue(3.9876, new MathContext(3)); // NOSONAR - deprecated
assertThat(evaluationValue3.getNumberValue()).isEqualByComparingTo("3.99");
}

@Test
@SuppressWarnings("removal")
void testDeprecatedConstructor() {
EvaluationValue value = new EvaluationValue("124"); // NOSONAR - deprecated
assertThat(value.isStringValue()).isTrue();
assertThat(value.getStringValue()).isEqualTo("124");
}

private void assertDataIsCorrect(
EvaluationValue value, String stringValue, BigDecimal numberValue, Boolean booleanValue) {
assertThat(value.getStringValue()).isEqualTo(stringValue);
Expand Down
Loading