Skip to content

Commit

Permalink
refactor: change order of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jbl428 committed Jan 30, 2024
1 parent 1e44734 commit 968d838
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
36 changes: 18 additions & 18 deletions dsl/jpql/src/main/kotlin/com/linecorp/kotlinjdsl/dsl/jpql/Jpql.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T : Any, V : Number> sqrt(expr: KProperty1<T, @Exact V>): Expression<Double> {
return Expressions.sqrt(Paths.path(expr))
}

/**
* Creates an expression that represents the square root of value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sqrt(value: Expressionable<T>): Expression<Double> {
return Expressions.sqrt(value.toExpression())
}

/**
* Creates an expression that represents the plus of values.
* The values are each enclosed in parentheses.
Expand Down Expand Up @@ -569,21 +553,37 @@ 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 <T : Any, V : Number> ceiling(expr: KProperty1<T, @Exact V>): Expression<V> {
return Expressions.ceiling(Paths.path(expr))
}

/**
* Creates an expression that is enclosed in ceiling
* Creates an expression that is enclosed in ceiling.
*/
@SinceJdsl("3.4.0")
fun <T : Number> ceiling(value: Expressionable<T>): Expression<T> {
return Expressions.ceiling(value.toExpression())
}

/**
* Creates an expression that represents the square root of value.
*/
@SinceJdsl("3.4.0")
fun <T : Any, V : Number> sqrt(expr: KProperty1<T, @Exact V>): Expression<Double> {
return Expressions.sqrt(Paths.path(expr))
}

/**
* Creates an expression that represents the square root of value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sqrt(value: Expressionable<T>): Expression<Double> {
return Expressions.sqrt(value.toExpression())
}

/**
* Creates an expression that represents the count of non-null values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,6 @@ object Expressions {
return JpqlParam(name, value)
}

/**
* Creates an expression that represents the absolute value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> abs(value: Expression<T>): Expression<T> {
return JpqlAbs(value)
}

/**
* Creates an expression that represents the square root of the value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sqrt(value: Expression<T>): Expression<Double> {
return JpqlSqrt(value)
}

/**
* Creates an expression that represents the plus of values.
*
Expand All @@ -205,14 +189,6 @@ object Expressions {
return JpqlMinus(value1, value2)
}

/**
* Creates an expression that is enclosed in ceiling
*/
@SinceJdsl("3.4.0")
fun <T : Number> ceiling(value: Expression<T>): Expression<T> {
return JpqlCeiling(value)
}

/**
* Creates an expression that represents the times of values.
*
Expand All @@ -233,6 +209,30 @@ object Expressions {
return JpqlDivide(value1, value2)
}

/**
* Creates an expression that represents the absolute value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> abs(value: Expression<T>): Expression<T> {
return JpqlAbs(value)
}

/**
* Creates an expression that is enclosed in ceiling.
*/
@SinceJdsl("3.4.0")
fun <T : Number> ceiling(value: Expression<T>): Expression<T> {
return JpqlCeiling(value)
}

/**
* Creates an expression that represents the square root of the value.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sqrt(value: Expression<T>): Expression<Double> {
return JpqlSqrt(value)
}

/**
* Creates an expression that represents the count of non-null values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>(
val expected = JpqlPlus<Int>(
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<Int>(
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<Int>(
val expected = JpqlTimes<Int>(
intExpression1,
intExpression2,
)
Expand All @@ -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<Int>(
val expected = JpqlDivide<Int>(
intExpression1,
intExpression2,
)
Expand All @@ -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<Int>(
val expected = JpqlAbs<Int>(
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<Int>(
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)
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 968d838

Please sign in to comment.