Code cleanup and formatting. Migrated to java 1.8.
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / network / LocaleConfiguration.java
index 2bb15e2..7e5ee06 100755 (executable)
@@ -9,51 +9,49 @@
 
 package eu.svjatoslav.commons.network;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.servlet.http.HttpServletRequest;
-
 public class LocaleConfiguration {
 
-       String defaultLocale;
-
-       private final List<String> allowedLocales = new ArrayList<String>();
+    final String defaultLocale;
+    private final List<String> allowedLocales = new ArrayList<>();
 
-       public LocaleConfiguration(final String defaultLocale,
-                       final String... allowedLocales) {
+    public LocaleConfiguration(final String defaultLocale,
+                               final String... allowedLocales) {
 
-               this.defaultLocale = defaultLocale;
+        this.defaultLocale = defaultLocale;
 
-               for (final String locale : allowedLocales)
-                       getAllowedLocales().add(locale);
-       }
+        for (final String locale : allowedLocales)
+            getAllowedLocales().add(locale);
+    }
 
-       public String detectCurrentLocale(final HttpServletRequest request) {
+    public String detectCurrentLocale(final HttpServletRequest request) {
 
-               final String sessionLocaleString = (String) request.getSession()
-                               .getAttribute("locale");
+        final String sessionLocaleString = (String) request.getSession()
+                .getAttribute("locale");
 
-               String result = defaultLocale;
-               if (isAllowedLocale(sessionLocaleString))
-                       result = sessionLocaleString;
+        String result = defaultLocale;
+        if (isAllowedLocale(sessionLocaleString))
+            result = sessionLocaleString;
 
-               final String requestLocale = request.getParameter("locale");
+        final String requestLocale = request.getParameter("locale");
 
-               if (isAllowedLocale(requestLocale))
-                       result = requestLocale;
+        if (isAllowedLocale(requestLocale))
+            result = requestLocale;
 
-               request.getSession().setAttribute("locale", result);
+        request.getSession().setAttribute("locale", result);
 
-               return result;
-       }
+        return result;
+    }
 
-       public List<String> getAllowedLocales() {
-               return allowedLocales;
-       }
+    public List<String> getAllowedLocales() {
+        return allowedLocales;
+    }
 
-       public boolean isAllowedLocale(final String locale) {
-               return allowedLocales.contains(locale);
-       }
+    public boolean isAllowedLocale(final String locale) {
+        return allowedLocales.contains(locale);
+    }
 
 }