@eamtalu, you can use the feature "Pattern Matching for instanceof" (JEP 394) here, so you won't need to make the casting, following the example and documentation:
if (eventDto instanceof AccountOpenedDto accountOpenedDto) {
System.out.println(accountOpenedDto);
}
doc: https://docs.oracle.com/en/java/javase/17/language/pattern-matching-instanceof-operator.html
_Originally posted by @JoaoCipriano in https://github.com/valentinacupac/banking-kata-java/pull/117#discussion_r1227434137_