This file contains hidden or 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
| import java.util.Objects; | |
| import java.util.Optional; | |
| import lombok.Builder; | |
| import lombok.Value; | |
| import lombok.experimental.Accessors; | |
| import org.jspecify.annotations.NonNull; | |
| import org.jspecify.annotations.Nullable; | |
| @Value // ← Use Lombok's @Value to simulate Java Record | |
| @Accessors(fluent = true) // ← Great choice to mimic Record accessors |
This file contains hidden or 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
| @Configuration | |
| @Profile("routes-filter") | |
| class FilterConfiguration { | |
| companion object { | |
| private val log = Loggers.getLogger(FilterConfiguration::class.java) | |
| } | |
| @Bean | |
| fun filterGateway(builder: RouteLocatorBuilder): RouteLocator = | |
| builder.routes() |
This file contains hidden or 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
| diff --git a/README.md b/README.md | |
| index ced9bd0..d30d6ec 100644 | |
| --- a/README.md | |
| +++ b/README.md | |
| @@ -53,6 +53,9 @@ Each module is implemented in both [Java](./java) and [Kotlin](./kotlin) to comp | |
| - Implemented parallel Kotlin versions of Java examples | |
| - Updated to Spring Boot 3.5.x while the book uses an older Spring Boot version 2.5.0 | |
| - Adopted a monorepo approach with [Gradle Multi-project Builds][gradle-multiproject] and [Gradle Composite Builds][gradle-composite-builds] to manage both Java and Kotlin implementations in a single repository | |
| + - Learned that Gradle Kotlin DSL supports both type-safe and string-based dependency declarations, and that the string-based form was required | |
| + in [`08:rsocket/build.gradle.kts`](./kotlin/08-rsocket/build.gradle.kts) when adding dependencies inside `afterEvaluate` |
This file contains hidden or 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
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.function.Function; | |
| class PricingDiscountApp { | |
| public static void main(String[] args) { | |
| final var customer1 = new Customer("1", "John Doe", CustomerType.VIP); | |
| final var customer2 = new Customer("2", "Jane Doe", CustomerType.REGULAR); | |
| final var customer3 = new Customer("3", "Business Corp", CustomerType.BUSINESS); |
This file contains hidden or 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
| import java.time.LocalDateTime; | |
| import java.util.List; | |
| import java.util.function.Function; | |
| import java.util.stream.Collectors; | |
| class DocumentProcessorApp { | |
| public static void main(String[] args) { | |
| final var trinity = new Submitter("trin123"); | |
| final var morpheus = new Approver("morph456"); |
This file contains hidden or 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
| import java.math.BigDecimal; | |
| import java.time.Duration; | |
| import java.time.LocalDateTime; | |
| import java.util.*; | |
| import java.util.stream.Collector; | |
| import java.util.stream.Collectors; | |
| class TripAnalyzerApp1 { | |
| private static final List<Trip> TRIPS = List.of( | |
| new Trip(TripType.BUSINESS, "Tokyo", Duration.ofHours(5),LocalDateTime.of(2025, 5, 25, 8, 0), "Thomas Anderson", new BigDecimal("1200.00")), |
This file contains hidden or 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
| import static java.time.temporal.ChronoUnit.HOURS; | |
| import java.time.Instant; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.Optional; | |
| import java.util.concurrent.atomic.AtomicLong; | |
| import java.util.function.Function; | |
| import java.util.function.Supplier; |
This file contains hidden or 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
| sealed interface Permission permits Read, Write {} | |
| record Read() implements Permission {} | |
| record Write() implements Permission {} | |
| record Execute() {} | |
| class ResourceAction { | |
| public String perform(Permission permission) { | |
| return String.format("Performing action with %s...", permission.getClass().getSimpleName()); | |
| } |
This file contains hidden or 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
| // Basic domain record | |
| public record Customer(String id, String email) {} |
This file contains hidden or 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
| type Functor<T> = { | |
| map<R>(fn: (val: T) => R): Functor<R> | |
| concat(other: Functor<T>, combiner: (a: T, b: T) => T): Functor<T> | |
| getValue(): T | |
| } | |
| function id<T>(value: T): Functor<T> { | |
| return { | |
| map<R>(fn: (val: T) => R): Functor<R> { | |
| return id(fn(value)) |
NewerOlder