René's URL Explorer Experiment
Title: Compact canonical constructor | java.evolved
Open Graph Title: Compact canonical constructor | java.evolved
X Title: Compact canonical constructor | java.evolved
Description: Validate and normalize record fields without repeating parameter lists.
Open Graph Description: Validate and normalize record fields without repeating parameter lists.
X Description: Validate and normalize record fields without repeating parameter lists.
Opengraph URL: https://javaevolved.github.io/language/compact-canonical-constructor.html
direct link
Domain: javaevolved.github.io
Hey, it has json ld scripts:
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Compact canonical constructor",
"description": "Validate and normalize record fields without repeating parameter lists.",
"url": "https://javaevolved.github.io/compact-canonical-constructor.html",
"publisher": {
"@type": "Organization",
"name": "java.evolved",
"url": "https://javaevolved.github.io"
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://javaevolved.github.io/compact-canonical-constructor.html"
}
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://javaevolved.github.io/"
},
{
"@type": "ListItem",
"position": 2,
"name": "Language",
"item": "https://javaevolved.github.io/#language"
},
{
"@type": "ListItem",
"position": 3,
"name": "Compact canonical constructor"
}
]
}
| theme-color | #f97316 |
| mobile-web-app-capable | yes |
| apple-mobile-web-app-status-bar-style | black-translucent |
| apple-mobile-web-app-title | java.evolved |
| og:type | article |
| og:site_name | java.evolved |
| og:locale | en |
| og:image | https://javaevolved.github.io/og/language/compact-canonical-constructor.png |
| og:image:width | 1200 |
| og:image:height | 630 |
| og:image:type | image/png |
| twitter:card | summary_large_image |
| twitter:image | https://javaevolved.github.io/og/language/compact-canonical-constructor.png |
Links:
| java.evolved | https://javaevolved.github.io/ |
|
| https://github.com/javaevolved/javaevolved.github.io |
| ← All patterns | https://javaevolved.github.io/ |
| ← | https://javaevolved.github.io/language/static-members-in-inner-classes.html |
| → | https://javaevolved.github.io/language/call-c-from-java.html |
| Home | https://javaevolved.github.io/ |
| Language | https://javaevolved.github.io/#language |
| 🐛 Report a code issue | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=code-issue.yml&title=%5BCode%20Issue%5D%20Compact%20canonical%20constructor&category=language&slug=compact-canonical-constructor |
| 🌐 Report a translation issue | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=translation-issue.yml&title=%5BTranslation%5D%20Compact%20canonical%20constructor%20%28English%29&locale=en&pattern=compact-canonical-constructor&area=Pattern%20content |
| 💡 Suggest a new pattern | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=new-pattern.yml |
| 𝕏 | https://x.com/intent/tweet?url=https%3A%2F%2Fjavaevolved.github.io%2Flanguage%2Fcompact-canonical-constructor.html&text=Compact%20canonical%20constructor%20%E2%80%93%20java.evolved |
| 🦋 | https://bsky.app/intent/compose?text=Compact%20canonical%20constructor%20%E2%80%93%20java.evolved%20https%3A%2F%2Fjavaevolved.github.io%2Flanguage%2Fcompact-canonical-constructor.html |
| in | https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fjavaevolved.github.io%2Flanguage%2Fcompact-canonical-constructor.html |
| ⬡ | https://www.reddit.com/submit?url=https%3A%2F%2Fjavaevolved.github.io%2Flanguage%2Fcompact-canonical-constructor.html&title=Compact%20canonical%20constructor%20%E2%80%93%20java.evolved |
| Let us know. | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=code-issue.yml&title=%5BCode%20Issue%5D%20Compact%20canonical%20constructor&category=language&slug=compact-canonical-constructor |
| Record (Java 21) ↗ | https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Record.html |
| JEP 395: Records ↗ | https://openjdk.org/jeps/395 |
| View proof source ↗ | https://github.com/javaevolved/javaevolved.github.io/blob/main/proof/language/CompactCanonicalConstructor.java |
|
Language
Beginner
Records for data classes
Java 8
public class Point {
private final int x, y;
public Point(int x, int y) { ... }
public int getX() { return x; }
public int getY() { return y; }
// equals, hashCode, toString
}
Java 16+
public record Point(int x, int y) {}
Hover to see modern ➜
JDK 16+
→
| https://javaevolved.github.io/language/records-for-data-classes.html |
|
Language
Intermediate
Flexible constructor bodies
Java 8
class Square extends Shape {
Square(double side) {
super(side, side);
// can't validate BEFORE super!
if (side <= 0)
throw new IAE("bad");
}
}
Java 25+
class Square extends Shape {
Square(double side) {
if (side <= 0)
throw new IAE("bad");
super(side, side);
}
}
Hover to see modern ➜
JDK 25+
→
| https://javaevolved.github.io/language/flexible-constructor-bodies.html |
|
Errors
Intermediate
Record-based error responses
Java 8
// Verbose error class
public class ErrorResponse {
private final int code;
private final String message;
// constructor, getters, equals,
// hashCode, toString...
}
Java 16+
public record ApiError(
int code,
String message,
Instant timestamp
) {
public ApiError(int code, String msg) {
this(code, msg, Instant.now());
}
}
Hover to see modern ➜
JDK 16+
→
| https://javaevolved.github.io/errors/record-based-errors.html |
| java.evolved | https://javaevolved.github.io/ |
| Bruno Borges | https://github.com/brunoborges |
| GitHub Copilot | https://github.com/features/copilot |
| modern-css.com | https://modern-css.com |
| View on GitHub | https://github.com/javaevolved/javaevolved.github.io |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow
URLs of crawlers that visited me.