This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import org.springframework.lang.NonNull; | |
import java.util.UUID; | |
public class Account { | |
private final UUID id; | |
private final String name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package packages | |
import kotlin.random.Random | |
data class Stamp(val price: Double) | |
data class Package(val address: String, var stamp: Stamp? = null) { | |
fun unpack(): Any = TODO("Not yet implemented") | |
} | |
object MailService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun letExample() { | |
val content = openPackage()?.let { | |
registerAddress(it.address) | |
it.unpack() | |
} ?: "nothing in there" | |
playAroundWith(content) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun alsoExample() { | |
val address = "Someone somewhere 12345" | |
val stamp = Stamp(50.0) | |
val pack = Package(address, stamp) | |
MailService.sendPackage(pack).also { | |
informCustomer(it.address) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun applyExample() { | |
val address = "Someone somewhere 12345" | |
val pack = Package(address) | |
.apply { this.stamp = Stamp(50.0) } | |
MailService.sendPackage(pack) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun runExample() { | |
val address = "Someone somewhere 12345" | |
val stamp = Stamp(50.0) | |
val brokenPackage = Package(address, stamp) | |
val pack = brokenPackage.run { | |
Package(this.address, this.stamp) | |
} | |
MailService.sendPackage(pack) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calendarish; | |
import java.time.DayOfWeek; | |
import java.time.Duration; | |
import java.time.LocalDate; | |
import java.time.Month; | |
import java.time.ZoneId; | |
import java.time.temporal.ChronoField; | |
import java.time.temporal.WeekFields; | |
import java.util.Calendar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package some.system; | |
import third.party.Coords; | |
import third.party.CoordsConverter; | |
public class UntrustworthyCoordsConverterFacade { | |
public static ImmutableCoords fromRT90ToWGS84(ImmutableCoords rt90) { | |
Coords coordsToSend = new Coords(rt90.x, rt90.y); | |
Coords transformedCoords = CoordsConverter.fromRT90ToWGS84(coordsToSend); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package some.system; | |
public class ImmutableCoords { | |
public final double x; | |
public final double y; | |
public ImmutableCoords(final double x, final double y) { | |
this.x = x; | |
this.y = y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package third.party; | |
public class CoordsConverter { | |
public static Coords fromRT90ToWGS84(Coords coords) { | |
// some complex logic | |
} | |
// more conversions | |
} |
NewerOlder