Streams উন্নত

কাস্টম ইন্টারমিডিয়েট স্ট্রিম অপারেশনের (custom intermediate stream operations) জন্য gatherers ব্যবহার করুন।

✕ Java 8
// Sliding window: manual implementation
List<List<T>> windows = new ArrayList<>();
for (int i = 0; i <= list.size()-3; i++) {
    windows.add(
        list.subList(i, i + 3));
}
✓ Java 24+
var windows = stream
    .gather(
        Gatherers.windowSliding(3)
    )
    .toList();
এই কোডে সমস্যা দেখছেন? আমাদের জানান।
🧩

কম্পোজেবল (Composable)

Gatherers অন্যান্য স্ট্রিম অপারেশনগুলোর (stream operations) সাথে কম্পোজ করা যায়।

📦

বিল্ট-ইন অপারেশন (Built-in Operations)

windowFixed, windowSliding, fold, scan সরাসরি ব্যবহার করা যায়।

🔧

এক্সটেনসিবল (Extensible)

যেকোনো ইন্টারমিডিয়েট ট্রান্সফরমেশনের জন্য কাস্টম Gatherers লিখুন।

পুরনো পদ্ধতি
কাস্টম কালেক্টর (Custom Collector)
আধুনিক পদ্ধতি
gather()
JDK থেকে
24
কঠিনতা
উন্নত
Stream Gatherers
উপলব্ধ

JDK 24 (JEP 485, মার্চ 2025) এ চূড়ান্ত হয়েছে।

Gatherers হলো একটি নতুন ইন্টারমিডিয়েট স্ট্রিম অপারেশন, যা স্লাইডিং উইন্ডো, ফিক্সড-সাইজ গ্রুপ এবং স্ক্যান অপারেশনের মতো জটিল ট্রান্সফরমেশন প্রকাশ করতে পারে, যা স্ট্যান্ডার্ড স্ট্রিম অপস দিয়ে সম্ভব ছিল না।