Skip to content

bhf/stay-learning-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

StayTuned

stay-learning

brain

Whether you're up or down, just StayLearning.

An index of learning examples to help friends.

Each repository isolates a specific library, API, or technique and demonstrates it with minimal, runnable examples.

This document is designed to serve as a navigable index for humans, LLMs, and MCP tools.


Table of Contents


How to Use This Index

  • Each entry below describes one repository, its purpose, and the key concepts it demonstrates.
  • All repositories follow the naming convention st-learning-java-<topic>
  • Repositories marked [private] require access rights.
  • The base template repository is st-learning-java-base — use it to bootstrap new examples.

Repository Index

Topics: java streams collections functional-programming collectors

A collection of small, paired examples demonstrating the Java Streams API versus traditional (pre-stream) loop-based approaches. Each example shows the manual solution alongside the concise Stream equivalent.

Packages and examples:

Package Concept Example class
streams.filter Filtering with Stream.filter FilterExample
streams.map Transformation with Stream.map MapExample
streams.group Grouping with Collectors.groupingBy GroupExample
streams.flatmap Flattening with Stream.flatMap FlatMapExample
streams.reduce Aggregation/reduction ReduceExample
streams.find Finding with findFirst() FindExample
streams.collectors Counting, toMap, joining, partitioning, averaging, summarizing, downstream collectors CountingExample, ToMapExample, JoiningExample, PartitionExample, AveragingExample, SummarizingExample, DownstreamExample

Topics: java memory arenas foreign-memory jdk24 java.lang.foreign

Demonstrates native memory allocation and management using Java's java.lang.foreign API — specifically Arena and MemorySegment. Shows how to allocate, write, read, and free off-heap native memory.

Key class: com.bhf.learning.memory.ArenaExample

Requirements: JDK 21+ (tested on JDK 24)


Topics: java spi service-provider-interface serviceloader design-patterns extensibility

Demonstrates the Java Service Provider Interface (SPI) mechanism using ServiceLoader. Uses an IdentifierProvider interface with two implementations (RandomUuidProvider, TimestampIdProvider) and a factory that selects a provider via system property, environment variable, or ServiceLoader fallback.

Key classes:

  • Interface: com.bhf.learning.spi.IdentifierProvider
  • Implementations: RandomUuidProvider (uuid), TimestampIdProvider (timestamp)
  • Factory: com.bhf.learning.spi.IdentifierProviderFactory

Programmatic usage:

IdentifierProvider p = IdentifierProviderFactory.loadFromConfig();
System.out.println(p.name() + " -> " + p.id());

Topics: java jpms jlink modules gradle docker java21

A multi-module Gradle project demonstrating the Java Platform Module System (JPMS) and JLink for creating a minimal custom Java runtime image. Shows module-info.java usage across modules, inter-module dependencies, and Docker packaging.

Module structure:

Module Purpose
common Shared utilities and logger
messages Message types and entities (Java Records)
domain Domain logic; depends on common and messages
application Entry point, wires modules, configured for JLink

Topics: java mapstruct object-mapping dto records enums gradle-kotlin-dsl junit5

Demonstrates common MapStruct mapping patterns and recipes with JUnit 5 tests.

Examples:

Example Concept
Basic PersonEntityPersonDTO simple mapping
Record Mapping to a Java record-based DTO
Enum Mapping between different enum types (external → domain)
Source property Property-style accessors (firstName()) on source
Target property Property-style accessors on target with @AfterMapping
Iterable Iterable<Item> source → List<ItemDTO> target

Topics: java jackson json serialization deserialization streaming polymorphic

Small learning examples for Jackson mapping, including basic POJO mapping, nested objects, Java Time mapping, streaming capabilities (NDJSON), and polymorphic mapping.

Key classes / examples:

  • Person, PersonSample - Basic POJO serialization/deserialization
  • Order, Item, OrderSample - Nested objects and Java Time mapping
  • StreamingSample - Writing and reading newline-delimited JSON (NDJSON) using Jackson's streaming APIs
  • PolymorphicSample - Polymorphic mapping using @JsonTypeInfo and @JsonSubTypes with Animal (Dog, Cat)

Topics: java gradle template starter

A minimal starter template used to bootstrap new st-learning example repositories. Contains the base Gradle build setup for small Java learning projects. Use this as the starting point when creating a new topic repository.


Quick Reference

Repository Topics Access
st-learning-java-streams Streams, Collectors, Functional Public
st-learning-java-arenas Foreign Memory, Arenas, JDK 24 Public
st-learning-java-spi SPI, ServiceLoader, Extensibility Public
st-learning-java-jpms JPMS, JLink, Multi-module, Docker Private
st-learning-java-mapstruct MapStruct, DTO mapping, Records Public
st-learning-java-jackson Jackson, JSON, Serialization Public
st-learning-java-base Starter template Private

For LLMs and MCP Tools

This index repository exists at https://github.com/bhf/st-learning. To access a specific example repository:

  1. List all repos in this family: Search GitHub for org:bhf st-learning or user:bhf st-learning.
  2. Navigate to a topic: Use the table above to identify the relevant repo, then fetch its README or source files directly.
  3. Clone and run: Each repo uses Gradle and can be built with ./gradlew build or ./gradlew test. Private repos require authentication.
  4. Language/runtime: All repos use Java (JDK 21+) and Gradle (Kotlin or Groovy DSL).

Machine-readable repo list

The full index is available as st-learning-index.json.

About

st-learning: Java learning examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors