import java.util.*;
import java.util.concurrent.*;
import java.util.stream.*;

/** Companion for "Java Roadmap 2026". One screen of code per stage you will meet. Run: java RoadmapTour.java (JDK 21+) */
public class RoadmapTour {
    // Stage 1-2: core syntax + OOP (records, sealed types, pattern matching)
    sealed interface Shape permits Circle, Rect {}
    record Circle(double r) implements Shape {}
    record Rect(double w, double h) implements Shape {}
    static double area(Shape s) {
        return switch (s) {
            case Circle c -> Math.PI * c.r() * c.r();
            case Rect(double w, double h) -> w * h;
        };
    }

    record Employee(String name, String dept, int salary) {}

    public static void main(String[] args) throws Exception {
        System.out.println("[1-2] core + OOP    : area(Rect 3x4) = " + area(new Rect(3, 4)));

        // Stage 3: collections + streams
        List<Employee> staff = List.of(new Employee("Asha", "ENG", 250), new Employee("Rohan", "ENG", 180),
                new Employee("Sneha", "SALES", 200), new Employee("Karan", "SALES", 90));
        Map<String, Integer> payroll = staff.stream()
                .collect(Collectors.groupingBy(Employee::dept, TreeMap::new, Collectors.summingInt(Employee::salary)));
        System.out.println("[3]   collections   : payroll by dept = " + payroll);

        // Stage 4: concurrency (virtual threads)
        try (var ex = Executors.newVirtualThreadPerTaskExecutor()) {
            List<Future<Integer>> fs = IntStream.rangeClosed(1, 5).mapToObj(i -> ex.submit(() -> i * i)).toList();
            int sum = 0;
            for (Future<Integer> f : fs) sum += f.get();
            System.out.println("[4]   concurrency   : sum of squares on 5 virtual threads = " + sum);
        }

        // Stage 5: JVM
        System.out.println("[5]   JVM           : running on Java " + Runtime.version().feature()
                + ", heap max > 0 = " + (Runtime.getRuntime().maxMemory() > 0));

        // Stage 6-10 live in frameworks: see the roadmap post for the posts that cover each one
        System.out.println("[6-10] Spring Boot, data, microservices, cloud, AI -> see the roadmap on ankurm.com");
    }
}
