package com.nincraft.ninbot.components.config;

import lombok.val;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;

@Service
public class ConfigService {

    private ConfigDao configDao;

    public ConfigService(ConfigDao configDao) {
        this.configDao = configDao;
    }

    @Transactional
    public List<Config> getConfigByName(String serverId, String configName) {
        return configDao.getConfigByName(serverId, configName);
    }

    @Transactional
    public List<String> getValuesByName(java.lang.String serverId, java.lang.String configName) {
        return configDao.getValuesByName(serverId, configName);
    }

    public Optional<String> getSingleValueByName(String serverId, String configName) {
        val list = getValuesByName(serverId, configName);
        if (list.isEmpty()) {
            return Optional.empty();
        } else {
            return Optional.ofNullable(list.get(0));
        }
    }

    @Transactional
    public void removeConfig(Config config) {
        configDao.removeConfig(config);
    }

    @Transactional
    public void removeConfig(String serverId, String configName, String configValue) {
        configDao.removeConfig(serverId, configName, configValue);
    }

    @Transactional
    public boolean addConfig(Config config) {
        return configDao.addConfig(config);
    }

    @Transactional
    public boolean addConfig(String serverId, String configName, String configValue) {
        return configDao.addConfig(serverId, configName, configValue);
    }

    @Transactional
    public List<Config> getConfigsByServerId(String serverId) {
        return configDao.getAllObjectsByServerId(serverId);
    }
}

@@ -590,26 +590,16 @@
 sByName(
-java.lang.
 String s
@@ -611,18 +611,8 @@
 Id, 
-java.lang.
 Stri
@@ -695,24 +695,43 @@
 me);%0A    %7D%0A%0A
+    @Transactional%0A
     public O
@@ -797,32 +797,32 @@
 g configName) %7B%0A
-
         val list
@@ -824,16 +824,26 @@
  list = 
+configDao.
 getValue

Fix Sonar issue