8000 open-to-sealed.4 : extract mapOverlay as an extension (does not compile) · java-to-kotlin/code@bf772ed · GitHub
[go: up one dir, main page]

Skip to content

Commit bf772ed

Browse files
nprycedmcg
authored andcommitted
open-to-sealed.4 : extract mapOverlay as an extension (does not compile)
1 parent 09a5301 commit bf772ed

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/main/java/travelator/itinerary/ItineraryItem.kt

Lines changed: 18 additions & 21 deletions
4F1C
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ import java.time.Duration
88
import java.time.Period
99
import java.time.ZonedDateTime
1010

11-
sealed class ItineraryItem { // <1>
12-
abstract val id: Id<ItineraryItem> // <2>
11+
sealed class ItineraryItem {
12+
abstract val id: Id<ItineraryItem>
1313
abstract val description: String
14-
abstract val costs: List<Money>
15-
abstract val mapOverlay: MapOverlay
14+
abstract val costs: List<Money> // <1>
1615
}
1716

17+
val ItineraryItem.mapOverlay: MapOverlay // <2>
18+
get() = TODO("Not yet implemented")
19+
1820
data class Accommodation(
1921
override val id: Id<Accommodation>,
2022
val location: Location,
2123
val checkInFrom: ZonedDateTime,
2224
val checkOutBefore: ZonedDateTime,
2325
val pricePerNight: Money
24-
) : ItineraryItem() { // <3>
26+
) : ItineraryItem() {
2527
val nights = Period.between(
2628
checkInFrom.toLocalDate(),
2729
checkOutBefore.toLocalDate()
@@ -30,11 +32,9 @@ data class Accommodation(
3032

3133
override val description
3234
get() = "$nights nights at ${location.userReadableName}"
33-
3435
override val costs
3536
get() = listOf(totalPrice)
36-
37-
override val mapOverlay
37+
override val mapOverlay // <3>
3838
get() = PointOverlay(
3939
id = id,
4040
position = location.position,
@@ -44,20 +44,19 @@ data class Accommodation(
4444

4545
}
4646

47-
4847
data class Attraction(
4948
override val id: Id<Attraction>,
5049
val location: Location,
5150
val notes: String
5251
) : ItineraryItem() {
53-
override val description
54-
get() = location.userReadableName
52+
override val description get() =
53+
location.userReadableName
5554

56-
override val costs
57-
get() = emptyList<Money>()
55+
override val costs get() =
56+
emptyList<Money>()
5857

59-
override val mapOverlay
60-
get() = PointOverlay(
58+
override val mapOverlay get() =
59+
PointOverlay(
6160
position = location.position,
6261
text = description,
6362
icon = StandardIcons.ATTRACTION,
@@ -101,14 +100,12 @@ data class RestaurantBooking(
101100
val location: Location,
102101
val time: ZonedDateTime
103102
) : ItineraryItem() {
104-
override val description
105-
get() = location.userReadableName
103+
override val description get() = location.userReadableName
106104

107-
override val costs
108-
get() = emptyList<Money>()
105+
override val costs get() = emptyList<Money>()
109106

110-
override val mapOverlay
111-
get() = PointOverlay(
107+
override val mapOverlay get() =
108+
PointOverlay(
112109
id = id,
113110
position = location.position,
114111
text = location.userReadableName,

0 commit comments

Comments
 (0)
0