Skip to content

Commit 8939587

Browse files
committed
Do a clean separation between data class used in export/import feature.
1 parent f535914 commit 8939587

25 files changed

Lines changed: 111 additions & 134 deletions

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/IHastusData.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package fi.hsl.jore4.hastus.data.hastus.exp
2+
3+
/**
4+
* Hastus data interface which represents a line of CSV data to be exported to Hastus.
5+
*/
6+
sealed interface IExportableItem {
7+
/**
8+
* Get the data fields of the data, can be string or number
9+
*
10+
* @return
11+
*/
12+
fun getFields(): List<Any>
13+
}

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/Place.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/Place.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
/**
44
* Represents a Hastus Place element
@@ -10,7 +10,7 @@ package fi.hsl.jore4.hastus.data.hastus
1010
data class Place(
1111
val identifier: String,
1212
val description: String
13-
) : HastusData() {
13+
) : IExportableItem {
1414

1515
override fun getFields(): List<Any> = listOf(identifier, description)
1616
}

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/Route.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/Route.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
/**
44
* A Route Hastus element, represents a Jore4 Line
@@ -16,7 +16,7 @@ data class Route(
1616
val serviceType: Int = 0,
1717
val direction: Int = 0,
1818
val serviceMode: Int
19-
) : HastusData() {
19+
) : IExportableItem {
2020

2121
override fun getFields(): List<Any> = listOf(identifier, description, serviceType, direction, serviceMode)
2222
}

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/RouteVariant.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/RouteVariant.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
/**
44
* A Route variant Hastus element, represents a Jore4 route
@@ -18,7 +18,7 @@ data class RouteVariant(
1818
val reversible: Boolean = false,
1919
val routeIdAndVariantId: String,
2020
val routeId: String
21-
) : HastusData() {
21+
) : IExportableItem {
2222

2323
override fun getFields(): List<Any> =
2424
listOf(identifier, description, direction, reversible, routeIdAndVariantId, routeId)

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/RouteVariantPoint.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/RouteVariantPoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
import fi.hsl.jore4.hastus.data.format.NumberWithAccuracy
44

@@ -23,7 +23,7 @@ data class RouteVariantPoint(
2323
val regulatedTp: Boolean,
2424
val stopLabel: String,
2525
val routeIdAndVariantId: String
26-
) : HastusData() {
26+
) : IExportableItem {
2727

2828
init {
2929
if (isTimingPoint) {

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/Stop.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/Stop.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
import fi.hsl.jore4.hastus.data.format.NumberWithAccuracy
44

@@ -28,7 +28,7 @@ data class Stop(
2828
val gpsX: NumberWithAccuracy,
2929
val gpsY: NumberWithAccuracy,
3030
val shortIdentifier: String
31-
) : HastusData() {
31+
) : IExportableItem {
3232

3333
override fun getFields(): List<Any> = listOf(
3434
identifier,

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/StopDistance.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/exp/StopDistance.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.exp
22

33
/**
44
* Stop distance Hastus element. Distances between stops.
@@ -14,7 +14,7 @@ data class StopDistance(
1414
val stopEnd: String,
1515
val baseInService: Boolean = true,
1616
val editedDistance: Int
17-
) : HastusData() {
17+
) : IExportableItem {
1818

1919
override fun getFields(): List<Any> = listOf(
2020
stopStart,

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/ApplicationRecord.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/imp/ApplicationRecord.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.imp
22

33
import java.time.LocalDate
44
import java.time.LocalTime
@@ -19,7 +19,7 @@ data class ApplicationRecord(
1919
val vscVersion: Number,
2020
val jobDate: LocalDate,
2121
val jobTime: LocalTime
22-
) : HastusData() {
22+
) : ImportableItem() {
2323

2424
constructor(elements: List<String>) : this(
2525
hastus = elements[1],
@@ -28,6 +28,4 @@ data class ApplicationRecord(
2828
jobDate = LocalDate.parse(elements[4], dateFormatter()),
2929
jobTime = LocalTime.parse(elements[5].substring(0, 6), timeFormatter())
3030
)
31-
32-
override fun getFields(): List<Any> = emptyList()
3331
}

src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/BlockRecord.kt renamed to src/main/kotlin/fi/hsl/jore4/hastus/data/hastus/imp/BlockRecord.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package fi.hsl.jore4.hastus.data.hastus
1+
package fi.hsl.jore4.hastus.data.hastus.imp
22

33
/**
44
* Block record
@@ -24,7 +24,7 @@ data class BlockRecord(
2424
val prepOutTime: Int,
2525
val prepInTime: Int,
2626
val vehicleType: Int
27-
) : HastusData() {
27+
) : ImportableItem() {
2828

2929
constructor(elements: List<String>) : this(
3030
internalNumber = elements[1],
@@ -37,6 +37,4 @@ data class BlockRecord(
3737
prepInTime = parseToInt(elements[8]),
3838
vehicleType = parseToInt(elements[9])
3939
)
40-
41-
override fun getFields(): List<Any> = emptyList()
4240
}

0 commit comments

Comments
 (0)