package org.crunchytorch.coddy.language.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

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

@Service
public class LanguageService {


    private List<String> languages;

    @Autowired
    public LanguageService(@Value("${org.crunchytorch.coddy.languages:}") final String languages) {
        if(languages.isEmpty()) {
            this.languages = new ArrayList<>();
        } else {
            this.languages = Arrays.asList(languages.split(","));
        }
    }

    public List<String> getLanguages() {
        return this.languages;
    }

    public boolean isLanguageValid(String language) {
        return this.languages.contains(language);
    }
}

@@ -47,71 +47,8 @@
 e;%0A%0A
-import org.springframework.beans.factory.annotation.Autowired;%0A
 impo
@@ -171,197 +171,69 @@
 til.
-ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A@Service%0Apublic class LanguageService %7B%0A%0A%0A    private List%3CString%3E languages;%0A%0A    @Autowired%0A    public LanguageService(
+List;%0A%0A@Service%0Apublic class LanguageService %7B%0A%0A%0A    
 @Value(%22
 $%7Bor
@@ -228,16 +228,19 @@
 @Value(%22
+#%7B'
 $%7Borg.cr
@@ -270,218 +270,78 @@
 ges:
-%7D%22) final String languages) %7B%0A        if(languages.isEmpty()) %7B%0A            this.languages = new ArrayList%3C%3E();%0A        %7D else %7B%0A            this.languages = Arrays.asList(languages.split(%22,%22));%0A        %7D%0A    %7D
+java,c++,python,go%7D'.split(',')%7D%22)%0A    private List%3CString%3E languages;
 %0A%0A  

use default language as configuration