Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
shouwn committed Feb 8, 2024
1 parent b3693a7 commit 54a5970
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 152 deletions.
16 changes: 9 additions & 7 deletions docs/en/jpql-with-kotlin-jdsl/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ locate("Book", path(Book::title))
* EXP (exp)
* FLOOR (floor)
* LN (ln)
* ROUND (round)
* SIGN (sign)
* SIZE (size)
* SQRT (sqrt)
* ROUND (round)
* SIZE (size)

```kotlin
abs(path(Book::price))
Expand All @@ -242,13 +242,13 @@ floor(path(Book::price))

ln(path(Book::price))

round(path(Book::price), 2)

sign(path(Book::price))

size(path(Book::authors))

sqrt(path(Book::price))

round(path(Book::price), 2)

size(path(Book::authors))
```

| Function | DSL function |
Expand All @@ -261,17 +261,19 @@ sqrt(path(Book::price))

* CURRENT\_DATE (currentDate)
* CURRENT\_TIME (currentTime)
* LOCAL DATE (localDate)

```kotlin
currentDate()

currentTime()

localDate()
```

| Function | DSL function |
|--------------------|--------------|
| CURRENT\_TIMESTAMP | not yet |
| LOCAL DATE | support |
| LOCAL TIME | not yet |
| LOCAL DATETIME | not yet |
| EXTRACT | not yet |
Expand Down
16 changes: 9 additions & 7 deletions docs/ko/jpql-with-kotlin-jdsl/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ locate("Book", path(Book::title))
* EXP (exp)
* FLOOR (floor)
* LN (ln)
* ROUND (round)
* SIGN (sign)
* SIZE (size)
* SQRT (sqrt)
* ROUND (round)
* SIZE (size)

```kotlin
abs(path(Book::price))
Expand All @@ -238,13 +238,13 @@ floor(path(Book::price))

ln(path(Book::price))

round(path(Book::price), 2)

sign(path(Book::price))

size(path(Book::authors))

sqrt(path(Book::price))

round(path(Book::price), 2)

size(path(Book::authors))
```

| Function | DSL function |
Expand All @@ -257,17 +257,19 @@ sqrt(path(Book::price))

* CURRENT\_DATE (currentDate)
* CURRENT\_TIME (currentTime)
* LOCAL DATE (localDate)

```kotlin
currentDate()

currentTime()

localDate()
```

| Function | DSL function |
|--------------------|--------------|
| CURRENT\_TIMESTAMP | not yet |
| LOCAL DATE | support |
| LOCAL TIME | not yet |
| LOCAL DATETIME | not yet |
| EXTRACT | not yet |
Expand Down
122 changes: 61 additions & 61 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 @@ -619,6 +619,46 @@ open class Jpql : JpqlDsl {
return Expressions.ln(value.toExpression())
}

/**
* Creates an expression that represents the sign of value.
*
* - If value is positive, it returns 1.
* - If value is negative, it returns -1.
* - If value is zero, it returns 0.
*/
@SinceJdsl("3.4.0")
fun <T : Any, V : Number> sign(expr: KProperty1<T, @Exact V>): Expression<Int> {
return Expressions.sign(Paths.path(expr))
}

/**
* Creates an expression that represents the sign of value.
*
* - If value is positive, it returns 1.
* - If value is negative, it returns -1.
* - If value is zero, it returns 0.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sign(value: Expressionable<T>): Expression<Int> {
return Expressions.sign(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 rounding of the value to a specified scale.
*/
Expand Down Expand Up @@ -652,59 +692,49 @@ open class Jpql : JpqlDsl {
}

/**
* Creates an expression that represents the sign of value.
*
* - If value is positive, it returns 1.
* - If value is negative, it returns -1.
* - If value is zero, it returns 0.
*/
@SinceJdsl("3.4.0")
fun <T : Any, V : Number> sign(expr: KProperty1<T, @Exact V>): Expression<Int> {
return Expressions.sign(Paths.path(expr))
}

/**
* Creates an expression that represents the sign of value.
*
* - If value is positive, it returns 1.
* - If value is negative, it returns -1.
* - If value is zero, it returns 0.
* Creates an expression that the number of elements of the collection.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sign(value: Expressionable<T>): Expression<Int> {
return Expressions.sign(value.toExpression())
fun <T : Any, V, S : Collection<V>> size(expr: KProperty1<T, @Exact S>): Expression<Int> {
return Expressions.size(Paths.path(expr))
}

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

/**
* Creates an expression that represents the square root of value.
* Creates an expression that represents the current date.
*
* This is the same as ```CURRENT_DATE```.
*/
@SinceJdsl("3.4.0")
fun <T : Number> sqrt(value: Expressionable<T>): Expression<Double> {
return Expressions.sqrt(value.toExpression())
fun currentDate(): Expression<Date> {
return Expressions.currentDate()
}

/**
* Creates an expression that the number of elements of the collection.
* Creates an expression that represents the current time.
*
* This is the same as ```CURRENT_TIME```.
*/
@SinceJdsl("3.4.0")
fun <T : Any, V, S : Collection<V>> size(expr: KProperty1<T, @Exact S>): Expression<Int> {
return Expressions.size(Paths.path(expr))
fun currentTime(): Expression<Time> {
return Expressions.currentTime()
}

/**
* Creates an expression that the number of elements of the collection.
* Creates an expression that represents the local date.
*
* This is the same as ```LOCAL DATE```.
*/
@SinceJdsl("3.4.0")
fun <T, S : Collection<T>> size(path: Pathable<S>): Expression<Int> {
return Expressions.size(path.toPath())
fun localDate(): Expression<LocalDate> {
return Expressions.localDate()
}

/**
Expand Down Expand Up @@ -1551,36 +1581,6 @@ open class Jpql : JpqlDsl {
)
}

/**
* Creates an expression that represents the current date.
*
* This is the same as ```CURRENT_DATE```.
*/
@SinceJdsl("3.4.0")
fun currentDate(): Expression<Date> {
return Expressions.currentDate()
}

/**
* Creates an expression that represents the current time.
*
* This is the same as ```CURRENT_TIME```.
*/
@SinceJdsl("3.4.0")
fun currentTime(): Expression<Time> {
return Expressions.currentTime()
}

/**
* Creates an expression that represents the local date.
*
* This is the same as ```LOCAL DATE```.
*/
@SinceJdsl("3.4.0")
fun localDate(): Expression<LocalDate> {
return Expressions.localDate()
}

/**
* Creates an expression that represents predefined database functions and user-defined database functions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test
import java.time.LocalDate

class LocalDateDslTest {

@Test
fun localDate() {
// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,6 @@ object Expressions {
return JpqlLn(value)
}

/**
* Creates an expression that represents the rounding of the specified value to a specified scale.
*/
@SinceJdsl("3.4.0")
fun <T : Number> round(value: Expression<T>, scale: Expression<Int>): Expression<T> {
return JpqlRound(value, scale)
}

/**
* Creates an expression that represents the sign of a numeric value.
*/
Expand All @@ -285,6 +277,14 @@ object Expressions {
return JpqlSqrt(value)
}

/**
* Creates an expression that represents the rounding of the specified value to a specified scale.
*/
@SinceJdsl("3.4.0")
fun <T : Number> round(value: Expression<T>, scale: Expression<Int>): Expression<T> {
return JpqlRound(value, scale)
}

/**
* Creates an expression that represents the number of elements of the collection.
*/
Expand All @@ -293,6 +293,30 @@ object Expressions {
return JpqlSize(path)
}

/**
* Creates an expression that represents the current date.
*/
@SinceJdsl("3.4.0")
fun currentDate(): Expression<Date> {
return JpqlCurrentDate
}

/**
* Creates an expression that represents the current time.
*/
@SinceJdsl("3.4.0")
fun currentTime(): Expression<Time> {
return JpqlCurrentTime
}

/**
* Creates an expression that represents the local date.
*/
@SinceJdsl("3.4.0")
fun localDate(): Expression<LocalDate> {
return JpqlLocalDate
}

/**
* Creates an expression that represents the count of non-null values.
*
Expand Down Expand Up @@ -630,14 +654,6 @@ object Expressions {
return JpqlLocate(substring, string, start)
}

/**
* Creates an expression that represents the local date.
*/
@SinceJdsl("3.4.0")
fun localDate(): Expression<LocalDate> {
return JpqlLocalDate
}

/**
* Creates an expression that represents predefined database functions and user-defined database functions.
*/
Expand Down Expand Up @@ -728,20 +744,4 @@ object Expressions {
fun <T : Any> parentheses(expr: Expression<T>): Expression<T> {
return JpqlExpressionParentheses(expr)
}

/**
* Creates an expression that represents the current date.
*/
@SinceJdsl("3.4.0")
fun currentDate(): Expression<Date> {
return JpqlCurrentDate
}

/**
* Creates an expression that represents the current time.
*/
@SinceJdsl("3.4.0")
fun currentTime(): Expression<Time> {
return JpqlCurrentTime
}
}
Loading

0 comments on commit 54a5970

Please sign in to comment.