package com.vtence.molecule.middlewares;

import com.vtence.molecule.Request;
import com.vtence.molecule.Response;
import com.vtence.molecule.http.AcceptLanguage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

public class Locales extends AbstractMiddleware {

    private final List<Locale> supported;

    public Locales(String... supportedLanguageTags) {
        this.supported = fromLanguageTags(supportedLanguageTags);
    }

    public Locales(Locale... supported) {
        this.supported = Arrays.asList(supported);
    }

    private static List<Locale> fromLanguageTags(String... languageTags) {
        List<Locale> locales = new ArrayList<Locale>();
        for (String tag : languageTags) {
            locales.add(Locale.forLanguageTag(tag));
        }
        return locales;
    }

    public void handle(Request request, Response response) throws Exception {
        AcceptLanguage acceptedLanguages = AcceptLanguage.of(request);
        Locale best = acceptedLanguages.selectBest(supported);
        request.attribute(Locale.class, best != null ? best : Locale.getDefault());
        forward(request, response);
    }
}
@@ -189,33 +189,8 @@
 st;%0A
-import java.util.Arrays;%0A
 impo
@@ -204,24 +204,24 @@
 .util.List;%0A
+
 import java.
@@ -366,28 +366,16 @@
 upported
-LanguageTags
 ) %7B%0A    
@@ -416,120 +416,8 @@
 ags(
-supportedLanguageTags);%0A    %7D%0A%0A    public Locales(Locale... supported) %7B%0A        this.supported = Arrays.asList(
 supp

Remove ambiguous constructor