From 2f26e0c03c6165c7f15c8c95ebcdd4a52b593aaa Mon Sep 17 00:00:00 2001 From: Kacper Stasiuk Date: Mon, 17 Jan 2022 13:59:36 +0100 Subject: [PATCH] More styling changes to address codacy --- .../org/ktorm/support/postgresql/EarthDistance.kt | 15 +++++++++------ .../org/ktorm/support/postgresql/SqlTypes.kt | 9 +++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/EarthDistance.kt b/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/EarthDistance.kt index 094c5fd0..02a51baf 100644 --- a/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/EarthDistance.kt +++ b/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/EarthDistance.kt @@ -8,6 +8,9 @@ import org.ktorm.schema.ColumnDeclaring import org.ktorm.schema.DoubleSqlType import org.ktorm.schema.SqlType +/** + * Enum for 'cube' and 'earthdistance' binary operators. + */ public enum class CubeExpressionType(private val value: String) { /** * Cube overlaps operator, translated to the && operator in PostgreSQL. @@ -182,7 +185,7 @@ public fun earthDistance( /** * Get distance between 2 points on earth. -**/ + */ public fun earthDistance( point1: ColumnDeclaring, point2: Earth @@ -191,7 +194,7 @@ public fun earthDistance( /** * Get distance between 2 points on earth. - **/ + */ public fun earthDistance( point1: Earth, point2: ColumnDeclaring @@ -200,7 +203,7 @@ public fun earthDistance( /** * Get distance between 2 points on earth. - **/ + */ public fun earthDistance( point1: Earth, point2: Earth @@ -224,7 +227,7 @@ public fun earthBox( /** * Creates a bounding cube, sized to contain all the points that are not farther than radius meters from a given point. -**/ + */ public fun earthBox( point: ColumnDeclaring, radius: Double @@ -233,7 +236,7 @@ public fun earthBox( /** * Creates a bounding cube, sized to contain all the points that are not farther than radius meters from a given point. - **/ + */ public fun earthBox( point: Earth, radius: ColumnDeclaring @@ -242,7 +245,7 @@ public fun earthBox( /** * Creates a bounding cube, sized to contain all the points that are not farther than radius meters from a given point. - **/ + */ public fun earthBox( point: Earth, radius: Double diff --git a/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/SqlTypes.kt b/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/SqlTypes.kt index 2696f511..3d8e14d4 100644 --- a/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/SqlTypes.kt +++ b/ktorm-support-postgresql/src/main/kotlin/org/ktorm/support/postgresql/SqlTypes.kt @@ -126,6 +126,10 @@ public class PgEnumType>(private val enumClass: Class) : SqlType< */ public typealias Earth = Triple +/** + * Represents a point on Earth's surface + * Part of PostgreSQL's `earthdistance` SQL extension. + */ public object PGEarthType : SqlType(Types.OTHER, "earth") { override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: Earth) { ps.setObject(index, parameter, Types.OTHER) @@ -153,13 +157,14 @@ public fun BaseTable<*>.earth(name: String): Column = registerColumn(name * Part of PostgreSQL's `cube` SQL extension. * https://www.postgresql.org/docs/9.5/cube.html */ -public class Cube( +public data class Cube( public val first: DoubleArray, public val second: DoubleArray ) { init { - if (first.size != second.size) + if (first.size != second.size) { throw IllegalArgumentException("Cube should be initialized with same size arrays") + } } override fun toString(): String {