From 968d8380901c8e273dade3fe56fba9a27ebead4a Mon Sep 17 00:00:00 2001 From: Jake Son Date: Wed, 31 Jan 2024 06:31:38 +0900 Subject: [PATCH] refactor: change order of methods --- .../com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt | 36 +++++----- .../querymodel/jpql/expression/Expressions.kt | 48 +++++++------- .../jpql/expression/ExpressionsTest.kt | 66 +++++++++---------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt index 82d3a3405..bd66a02eb 100644 --- a/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt +++ b/dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt @@ -336,22 +336,6 @@ open class Jpql : JpqlDsl { return Paths.treat(this.toPath(), type) } - /** - * Creates an expression that represents the square root of value. - */ - @SinceJdsl("3.4.0") - fun sqrt(expr: KProperty1): Expression { - return Expressions.sqrt(Paths.path(expr)) - } - - /** - * Creates an expression that represents the square root of value. - */ - @SinceJdsl("3.4.0") - fun sqrt(value: Expressionable): Expression { - return Expressions.sqrt(value.toExpression()) - } - /** * Creates an expression that represents the plus of values. * The values are each enclosed in parentheses. @@ -569,7 +553,7 @@ open class Jpql : JpqlDsl { } /** - * Creates an expression that is enclosed in ceiling + * Creates an expression that is enclosed in ceiling. */ @SinceJdsl("3.4.0") fun ceiling(expr: KProperty1): Expression { @@ -577,13 +561,29 @@ open class Jpql : JpqlDsl { } /** - * Creates an expression that is enclosed in ceiling + * Creates an expression that is enclosed in ceiling. */ @SinceJdsl("3.4.0") fun ceiling(value: Expressionable): Expression { return Expressions.ceiling(value.toExpression()) } + /** + * Creates an expression that represents the square root of value. + */ + @SinceJdsl("3.4.0") + fun sqrt(expr: KProperty1): Expression { + return Expressions.sqrt(Paths.path(expr)) + } + + /** + * Creates an expression that represents the square root of value. + */ + @SinceJdsl("3.4.0") + fun sqrt(value: Expressionable): Expression { + return Expressions.sqrt(value.toExpression()) + } + /** * Creates an expression that represents the count of non-null values. * diff --git a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt index 1313701f6..8dea29f7c 100644 --- a/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt +++ b/query-model/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/Expressions.kt @@ -169,22 +169,6 @@ object Expressions { return JpqlParam(name, value) } - /** - * Creates an expression that represents the absolute value. - */ - @SinceJdsl("3.4.0") - fun abs(value: Expression): Expression { - return JpqlAbs(value) - } - - /** - * Creates an expression that represents the square root of the value. - */ - @SinceJdsl("3.4.0") - fun sqrt(value: Expression): Expression { - return JpqlSqrt(value) - } - /** * Creates an expression that represents the plus of values. * @@ -205,14 +189,6 @@ object Expressions { return JpqlMinus(value1, value2) } - /** - * Creates an expression that is enclosed in ceiling - */ - @SinceJdsl("3.4.0") - fun ceiling(value: Expression): Expression { - return JpqlCeiling(value) - } - /** * Creates an expression that represents the times of values. * @@ -233,6 +209,30 @@ object Expressions { return JpqlDivide(value1, value2) } + /** + * Creates an expression that represents the absolute value. + */ + @SinceJdsl("3.4.0") + fun abs(value: Expression): Expression { + return JpqlAbs(value) + } + + /** + * Creates an expression that is enclosed in ceiling. + */ + @SinceJdsl("3.4.0") + fun ceiling(value: Expression): Expression { + return JpqlCeiling(value) + } + + /** + * Creates an expression that represents the square root of the value. + */ + @SinceJdsl("3.4.0") + fun sqrt(value: Expression): Expression { + return JpqlSqrt(value) + } + /** * Creates an expression that represents the count of non-null values. * diff --git a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt index 255c8e9ef..ae4abfdda 100644 --- a/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt +++ b/query-model/jpql/src/test/kotlin/com/linecorp/kotlinjdsl/querymodel/jpql/expression/ExpressionsTest.kt @@ -280,38 +280,40 @@ class ExpressionsTest : WithAssertions { } @Test - fun abs() { + fun plus() { // when - val actual = Expressions.abs(intExpression1) + val actual = Expressions.plus(intExpression1, intExpression2) // then - val expected = JpqlAbs( + val expected = JpqlPlus( intExpression1, + intExpression2, ) assertThat(actual).isEqualTo(expected) } @Test - fun sqrt() { + fun minus() { // when - val actual = Expressions.sqrt(intExpression1) + val actual = Expressions.minus(intExpression1, intExpression2) // then - val expected = JpqlSqrt( + val expected = JpqlMinus( intExpression1, + intExpression2, ) assertThat(actual).isEqualTo(expected) } @Test - fun plus() { + fun times() { // when - val actual = Expressions.plus(intExpression1, intExpression2) + val actual = Expressions.times(intExpression1, intExpression2) // then - val expected = JpqlPlus( + val expected = JpqlTimes( intExpression1, intExpression2, ) @@ -320,12 +322,12 @@ class ExpressionsTest : WithAssertions { } @Test - fun minus() { + fun div() { // when - val actual = Expressions.minus(intExpression1, intExpression2) + val actual = Expressions.div(intExpression1, intExpression2) // then - val expected = JpqlMinus( + val expected = JpqlDivide( intExpression1, intExpression2, ) @@ -334,28 +336,39 @@ class ExpressionsTest : WithAssertions { } @Test - fun times() { + fun abs() { // when - val actual = Expressions.times(intExpression1, intExpression2) + val actual = Expressions.abs(intExpression1) // then - val expected = JpqlTimes( + val expected = JpqlAbs( intExpression1, - intExpression2, ) assertThat(actual).isEqualTo(expected) } @Test - fun div() { + fun ceiling() { // when - val actual = Expressions.div(intExpression1, intExpression2) + val actual = Expressions.ceiling(doubleExpression1) // then - val expected = JpqlDivide( + val expected = JpqlCeiling( + doubleExpression1, + ) + + assertThat(actual).isEqualTo(expected) + } + + @Test + fun sqrt() { + // when + val actual = Expressions.sqrt(intExpression1) + + // then + val expected = JpqlSqrt( intExpression1, - intExpression2, ) assertThat(actual).isEqualTo(expected) @@ -916,17 +929,4 @@ class ExpressionsTest : WithAssertions { assertThat(actual).isEqualTo(expected) } - - @Test - fun ceiling() { - // when - val actual = Expressions.ceiling(doubleExpression1) - - // then - val expected = JpqlCeiling( - doubleExpression1, - ) - - assertThat(actual).isEqualTo(expected) - } }