PsiClass (PsiDirectory directory, String name) { JavaDirectoryService service = JavaDirectoryService.getInstance(); return switch (this) { case INTERFACE -> service.createInterface(directory, name); case CLASS -> service.createClass(directory, name); case ENUM -> service.createEnum(directory, name); case RECORD -> service.createRecord(directory, name); case ANNOTATION -> service.createAnnotationType(directory, name); }; }