@@ -170,22 +170,28 @@ private String itemContent(
170
170
.append (changedMediaType .isCompatible () ? "Backward compatible" : "Broken compatibility" )
171
171
.append (System .lineSeparator ());
172
172
if (!changedMediaType .isCompatible ()) {
173
- sb . append ( incompatibility (changedMediaType ) );
173
+ incompatibility (sb , changedMediaType , "" );
174
174
}
175
175
return sb .toString ();
176
176
}
177
177
178
- private String incompatibility (ComposedChanged changed ) {
178
+ private void incompatibility (
179
+ final StringBuilder output , final ComposedChanged changed , final String propPrefix ) {
179
180
if (changed .isCoreChanged () == DiffResult .INCOMPATIBLE ) {
180
181
if (changed instanceof ChangedSchema ) {
181
182
ChangedSchema cs = (ChangedSchema ) changed ;
182
183
183
- if (cs .getMissingProperties ().size () > 0 ) {
184
- return cs .getMissingProperties ().keySet ().stream ().collect (Collectors .joining ());
185
- }
184
+ cs .getMissingProperties ().keySet ().stream ()
185
+ .forEach (
186
+ (propName ) -> {
187
+ output
188
+ .append (StringUtils .repeat (' ' , 10 ))
189
+ .append ("Missing property: " )
190
+ .append (propPrefix )
191
+ .append (propName )
192
+ .append (System .lineSeparator ());
193
+ });
186
194
}
187
-
188
- return "" ;
189
195
} else {
190
196
if (changed instanceof ChangedSchema ) {
191
197
ChangedSchema cs = (ChangedSchema ) changed ;
@@ -196,30 +202,22 @@ private String incompatibility(ComposedChanged changed) {
196
202
} else if (cs .getItems () != null ) {
197
203
description = "[n]" ;
198
204
}
199
- return description
200
- + "."
201
- + cs . getChangedElements (). stream ()
202
- . map (
203
- ( c ) ->
204
- c != null && c instanceof ComposedChanged
205
- ? incompatibility (( ComposedChanged ) c )
206
- : "" )
207
- . collect ( Collectors . joining ()) ;
205
+ final String prefix = propPrefix + description + "." ;
206
+ cs . getChangedElements (). stream ()
207
+ . forEach (
208
+ ( c ) -> {
209
+ if ( c != null && c instanceof ComposedChanged ) {
210
+ incompatibility ( output , ( ComposedChanged ) c , prefix );
211
+ }
212
+ });
213
+ return ;
208
214
}
209
215
210
- StringBuilder sb = new StringBuilder ();
211
216
for (Changed child : changed .getChangedElements ()) {
212
217
if (child instanceof ComposedChanged ) {
213
- String childIncompatibility = incompatibility ((ComposedChanged ) child );
214
- if (!"" .equals (childIncompatibility )) {
215
- sb .append (StringUtils .repeat (' ' , 10 ))
216
- .append ("Missing property: " )
217
- .append (childIncompatibility )
218
- .append (System .lineSeparator ());
219
- }
218
+ incompatibility (output , (ComposedChanged ) child , "" );
220
219
}
221
220
}
222
- return sb .toString ();
223
221
}
224
222
}
225
223
0 commit comments