/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.xpack.sql.analysis.analyzer;

import java.util.Collection;
import java.util.Locale;
import java.util.stream.Collectors;

import org.elasticsearch.xpack.sql.analysis.AnalysisException;
import org.elasticsearch.xpack.sql.analysis.analyzer.Verifier.Failure;
import org.elasticsearch.xpack.sql.util.StringUtils;

import static java.lang.String.format;

public class VerificationException extends AnalysisException {

    private final Collection<Failure> failures; 

    protected VerificationException(Collection<Failure> sources) {
        super(null, StringUtils.EMPTY);
        failures = sources;
    }
    
    @Override
    public String getMessage() {
        return failures.stream()
                .map(f -> format(Locale.ROOT, "line %s:%s: %s", f.source().location().getLineNumber(), f.source().location().getColumnNumber(), f.message()))
                .collect(Collectors.joining(StringUtils.NEW_LINE, "Found " + failures.size() + " problem(s)\n", StringUtils.EMPTY));
    }
}

@@ -324,33 +324,8 @@
 on;%0A
-import java.util.Locale;%0A
 impo
@@ -356,16 +356,16 @@
 ectors;%0A
+
 %0Aimport 
@@ -491,16 +491,66 @@
 ailure;%0A
+import org.elasticsearch.xpack.sql.tree.Location;%0A
 import o
@@ -599,47 +599,8 @@
 s;%0A%0A
-import static java.lang.String.format;%0A
 %0Apub
@@ -707,17 +707,16 @@
 ailures;
- 
 %0A%0A    pr
@@ -854,13 +854,9 @@
   %7D%0A
-    
 %0A
+
     
@@ -961,106 +961,130 @@
  -%3E 
-format(Locale.ROOT, %22line %25s:%25s: %25s%22, f.source().location().getLineNumber(), f.source().location()
+%7B%0A                    Location l = f.source().location();%0A                    return %22line %22 + l.getLineNumber() + %22:%22 + l
 .get
@@ -1097,17 +1097,25 @@
 Number()
-,
+ + %22: %22 +
  f.messa
@@ -1118,17 +1118,35 @@
 essage()
-)
+;%0A                %7D
 )%0A      

Fix checkstyle in VerificationException (elastic/x-pack-elasticsearch#3447)