TypeScript’s primitive types — string, number, boolean — are broad buckets. A literal type narrows that bucket to exactly one value, like "north" instead of any string, or 42 instead of any number. On their own, literals look trivial. But combined with union types, template literal types, and discriminated unions, they form the backbone of the precise, self-documenting APIs that make TypeScript genuinely safer than JavaScript. This guide explores every facet of literal types with practical, real-world examples.
Tag Archives: Java
Top 40 Spring MVC Interview Questions and Answers (2025)
Spring MVC is the foundational web layer of the Spring Framework, and it remains a favourite topic in Java developer interviews at every level. Even in a world dominated by Spring Boot auto-configuration, interviewers probe Spring MVC knowledge to gauge whether a candidate truly understands what happens under the hood. This guide covers the 40 most-asked Spring MVC interview questions, organised from core concepts through advanced topics, each with a concise, interview-ready answer.
Continue reading Top 40 Spring MVC Interview Questions and Answers (2025)How to Use Jersey Client to Call REST Services in Java
The Jersey Client API is the reference implementation of the JAX-RS 2.x/3.x client specification. It provides a fluent, type-safe way to consume REST endpoints from any Java application — no framework required beyond Jersey itself. In this guide you will learn how to perform every HTTP method, pass headers and query parameters, consume and produce JSON, add Basic and Bearer token authentication, and handle errors gracefully.
Continue reading How to Use Jersey Client to Call REST Services in JavaResilience4j Circuit Breaker in Spring Boot: The Modern Replacement for Hystrix
Netflix Hystrix is in maintenance mode and has been for years. The modern replacement is Resilience4j — a lightweight, modular fault-tolerance library designed for Java 8+ and first-class Spring Boot integration. In this guide you will implement a Circuit Breaker, a Rate Limiter, a Retry mechanism, and a Bulkhead in Spring Boot 3 using Resilience4j, with annotated code, configuration, and Actuator metrics all in one place.
Continue reading Resilience4j Circuit Breaker in Spring Boot: The Modern Replacement for HystrixMastering Cache Control with ETag in Spring Boot RESTful APIs
An ETag (Entity Tag) is a short fingerprint — typically an MD5 or SHA hash of a resource’s content — that a REST API includes in every response. On the next request, the client sends the ETag back in a If-None-Match header. If the resource has not changed, the server replies with 304 Not Modified and an empty body, saving bandwidth and time. In this guide you will learn how ETags work, implement them from scratch in a Spring Boot REST API, and apply conditional updates to prevent lost updates in concurrent systems.
Mastering Conversions Between Java LocalDate and ZonedDateTime
LocalDate stores only a calendar date — year, month, and day — with no time and no timezone. ZonedDateTime holds a fully resolved instant on the global timeline. Converting between the two is a surprisingly common requirement: form inputs, database date columns, and report parameters often arrive as plain dates that need to be combined with a time and a timezone before being stored or sent over an API. This guide covers every conversion direction with annotated code and a quick-reference table.
Java: Converting LocalDateTime to ZonedDateTime Correctly
A LocalDateTime knows the date and the time — for example, 2025-07-15T14:30:00 — but it has absolutely no concept of timezone or offset. A ZonedDateTime attaches a full IANA timezone (e.g. America/New_York) to that instant, making it globally unambiguous. Converting between the two is a common need whenever data arrives from a UI, database, or external API without timezone information attached. This guide covers every conversion scenario, explains why it matters, and shows the one-liner plus the explicit approach for each case.