Runnable sources, broken examples and captured transcripts for the ankurm.com JEP 513 article, including the JDK 25 vs 27 compiler wording differences. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
24 lines
729 B
Java
24 lines
729 B
Java
// The prologue rule applies to this(...) as well as super(...).
|
|
public class ThisChaining {
|
|
final String id;
|
|
final int retries;
|
|
|
|
ThisChaining(String id) {
|
|
String normalised = id.trim().toLowerCase();
|
|
int defaultRetries = normalised.startsWith("critical") ? 5 : 1;
|
|
this(normalised, defaultRetries);
|
|
}
|
|
|
|
ThisChaining(String id, int retries) {
|
|
this.id = id;
|
|
this.retries = retries;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
ThisChaining a = new ThisChaining(" CRITICAL-payment ");
|
|
ThisChaining b = new ThisChaining("Report-export");
|
|
IO.println(a.id + " retries=" + a.retries);
|
|
IO.println(b.id + " retries=" + b.retries);
|
|
}
|
|
}
|