AverageFailureAmount (@NotNull JsonSchemaAnnotatorChecker checker) { int lowPriorityCount = 0; boolean hasMedium = false; boolean hasMissing = false; boolean hasHard = false; Collection<JsonValidationError> values = checker.getErrors().values(); for (JsonValidationError value: values) { switch (value.getPriority()) { case LOW_PRIORITY -> lowPriorityCount++; case MISSING_PROPS -> hasMissing = true; case MEDIUM_PRIORITY -> hasMedium = true; case TYPE_MISMATCH -> hasHard = true; case NOT_SCHEMA -> { return AverageFailureAmount.NotSchema; } } } if (hasHard) { return AverageFailureAmount.Hard; } // missing props should win against other conditions if (hasMissing) { return AverageFailureAmount.MissingItems; } if (hasMedium) { return AverageFailureAmount.Medium; } return lowPriorityCount <= 3 ? AverageFailureAmount.Light : AverageFailureAmount.Medium; }