22
22
import java .util .stream .Stream ;
23
23
24
24
import org .apache .commons .logging .LogFactory ;
25
- import org .neo4j .driver .NotificationClassification ;
25
+ import org .neo4j .driver .NotificationCategory ;
26
26
import org .neo4j .driver .NotificationSeverity ;
27
27
import org .neo4j .driver .summary .InputPosition ;
28
28
import org .neo4j .driver .summary .Notification ;
@@ -75,18 +75,20 @@ private static void logNotifications(ResultSummary resultSummary) {
75
75
Predicate <Notification > isDeprecationWarningForId ;
76
76
try {
77
77
isDeprecationWarningForId = notification -> supressIdDeprecations
78
- && notification .classification ().orElse (NotificationClassification .UNRECOGNIZED )
79
- == NotificationClassification .DEPRECATION && DEPRECATED_ID_PATTERN .matcher (notification .description ())
80
- .matches ();
78
+ && notification .category ()
79
+ .orElse (NotificationCategory .UNRECOGNIZED )
80
+ .equals (NotificationCategory .DEPRECATION )
81
+ && DEPRECATED_ID_PATTERN .matcher (notification .description ()).matches ();
81
82
} finally {
82
83
Neo4jClient .SUPPRESS_ID_DEPRECATIONS .setRelease (supressIdDeprecations );
83
84
}
84
85
85
86
String query = resultSummary .query ().text ();
86
87
resultSummary .notifications ()
87
- .stream ().filter (Predicate .not (isDeprecationWarningForId ))
88
- .forEach (notification -> notification .severityLevel ().ifPresent (severityLevel -> {
89
- var category = notification .classification ().orElse (null );
88
+ .stream ()
89
+ .filter (Predicate .not (isDeprecationWarningForId ))
90
+ .forEach (notification -> notification .severityLevel ().ifPresent (severityLevel -> {
91
+ var category = notification .category ().orElse (null );
90
92
91
93
var logger = getLogAccessor (category );
92
94
Consumer <String > logFunction ;
@@ -105,21 +107,35 @@ private static void logNotifications(ResultSummary resultSummary) {
105
107
}));
106
108
}
107
109
108
- private static LogAccessor getLogAccessor (@ Nullable NotificationClassification category ) {
110
+ private static LogAccessor getLogAccessor (@ Nullable NotificationCategory category ) {
109
111
if (category == null ) {
110
112
return Neo4jClient .cypherLog ;
111
113
}
112
- return switch (category ) {
113
- case HINT -> cypherHintNotificationLog ;
114
- case DEPRECATION -> cypherDeprecationNotificationLog ;
115
- case PERFORMANCE -> cypherPerformanceNotificationLog ;
116
- case GENERIC -> cypherGenericNotificationLog ;
117
- case UNSUPPORTED -> cypherUnsupportedNotificationLog ;
118
- case UNRECOGNIZED -> cypherUnrecognizedNotificationLog ;
119
- case SECURITY -> cypherSecurityNotificationLog ;
120
- case TOPOLOGY -> cypherTopologyNotificationLog ;
121
- default -> Neo4jClient .cypherLog ;
122
- };
114
+ if (category .equals (NotificationCategory .HINT )) {
115
+ return cypherHintNotificationLog ;
116
+ }
117
+ if (category .equals (NotificationCategory .DEPRECATION )) {
118
+ return cypherDeprecationNotificationLog ;
119
+ }
120
+ if (category .equals (NotificationCategory .PERFORMANCE )) {
121
+ return cypherPerformanceNotificationLog ;
122
+ }
123
+ if (category .equals (NotificationCategory .GENERIC )) {
124
+ return cypherGenericNotificationLog ;
125
+ }
126
+ if (category .equals (NotificationCategory .UNSUPPORTED )) {
127
+ return cypherUnsupportedNotificationLog ;
128
+ }
129
+ if (category .equals (NotificationCategory .UNRECOGNIZED )) {
130
+ return cypherUnrecognizedNotificationLog ;
131
+ }
132
+ if (category .equals (NotificationCategory .SECURITY )) {
133
+ return cypherSecurityNotificationLog ;
134
+ }
135
+ if (category .equals (NotificationCategory .TOPOLOGY )) {
136
+ return cypherTopologyNotificationLog ;
137
+ }
138
+ return Neo4jClient .cypherLog ;
123
139
}
124
140
125
141
/**
@@ -180,6 +196,4 @@ private static void printPlan(Consumer<String> log, Plan plan, int level) {
180
196
}
181
197
}
182
198
183
- private ResultSummaries () {
184
- }
185
199
}
0 commit comments