Skip to content

Latest commit

 

History

History
128 lines (102 loc) · 3.96 KB

File metadata and controls

128 lines (102 loc) · 3.96 KB

Copilot Instructions for java.evolved

Project Overview

This is a static site showcasing modern Java patterns vs legacy approaches. It is hosted on GitHub Pages at https://javaevolved.github.io.

Architecture

Source of Truth: JSON Files

Each pattern is defined as a JSON file under content/category/:

content/language/type-inference-with-var.json
content/collections/immutable-list-creation.json
content/streams/stream-tolist.json
...

Categories: language, collections, strings, streams, concurrency, io, errors, datetime, security, tooling

Generated Files (DO NOT EDIT)

The following are generated by html-generators/generate.java and must not be edited directly:

  • site/index.html — homepage with preview cards (generated from templates/index.html)
  • site/language/*.html, site/collections/*.html, etc. — detail pages
  • site/data/snippets.json — aggregated search index

Run jbang html-generators/generate.java to rebuild all generated files from the JSON sources.

Manually Maintained Files

  • site/app.js — client-side search, filtering, code highlighting
  • site/styles.css — all styling
  • templates/slug-template.html — HTML template with {{placeholder}} tokens used by the generator
  • templates/index.html — homepage template with {{tipCards}} and {{snippetCount}} placeholders
  • templates/index-card.html — preview card template for the homepage grid

Project Structure

content/            # Source JSON files (one per pattern, organized by category)
site/               # Deployable site (static assets + generated HTML)
templates/          # HTML templates for detail pages
html-generators/    # Build scripts and pre-built JAR

JSON Snippet Schema

Each content/category/slug.json file has this structure:

{
  "id": 1,
  "slug": "type-inference-with-var",
  "title": "Type inference with var",
  "category": "language",
  "difficulty": "beginner|intermediate|advanced",
  "jdkVersion": "10",
  "oldLabel": "Java 8",
  "modernLabel": "Java 10+",
  "oldApproach": "Explicit Types",
  "modernApproach": "var keyword",
  "oldCode": "// old way...",
  "modernCode": "// modern way...",
  "summary": "One-line description.",
  "explanation": "How it works paragraph.",
  "whyModernWins": [
    { "icon": "", "title": "Short title", "desc": "One sentence." },
    { "icon": "👁", "title": "Short title", "desc": "One sentence." },
    { "icon": "🔒", "title": "Short title", "desc": "One sentence." }
  ],
  "support": {
    "state": "available",
    "description": "Widely available since JDK 10 (March 2018)"
  },
  "prev": "category/slug-of-previous",
  "next": "category/slug-of-next",
  "related": [
    "category/slug-1",
    "category/slug-2",
    "category/slug-3"
  ],
  "docs": [
    { "title": "Javadoc or Guide Title", "href": "https://docs.oracle.com/..." }
  ]
}

Key Rules

  • slug must match the filename (without .json)
  • category must match the parent folder name
  • whyModernWins must have exactly 3 entries
  • related must have exactly 3 entries (as category/slug paths)
  • docs must have at least 1 entry linking to Javadoc or Oracle documentation
  • prev/next are category/slug paths or null for first/last
  • Code in oldCode/modernCode uses \n for newlines

Category Display Names

ID Display
language Language
collections Collections
strings Strings
streams Streams
concurrency Concurrency
io I/O
errors Errors
datetime Date/Time
security Security
tooling Tooling

Adding a New Pattern

  1. Create content/category/new-slug.json with all required fields
  2. Update prev/next in the adjacent patterns' JSON files
  3. Run jbang html-generators/generate.java

Local Development

jbang html-generators/generate.java  # Build HTML pages + snippets.json
jwebserver -d site -p 8090              # Serve locally