Add sealed module: modelling domains with sealed types and exhaustive switch
Payment model, permits and the three modifiers, default-branch trap, generic and recursive hierarchies, visitor comparison, run-time enforcement, modules. Transcripts from JDK 21, 25 and 27. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("loading Card: " + Class.forName("Card").getSimpleName());
|
||||
System.out.println("loading Hack...");
|
||||
System.out.println(Class.forName("Hack").getSimpleName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public final class Card implements Payment {}
|
||||
@@ -0,0 +1 @@
|
||||
public final class Hack implements Payment {}
|
||||
@@ -0,0 +1 @@
|
||||
public sealed interface Payment permits Card, Hack {}
|
||||
@@ -0,0 +1 @@
|
||||
public final class Card implements Payment {}
|
||||
@@ -0,0 +1 @@
|
||||
public sealed interface Payment permits Card {}
|
||||
Reference in New Issue
Block a user