com.almis.awe.developer.factory.TranslationServiceFactory Maven / Gradle / Ivy
The newest version!
package com.almis.awe.developer.factory;
import com.almis.awe.developer.translators.ITranslator;
import com.almis.awe.developer.translators.TranslationServiceEnum;
import jakarta.annotation.PostConstruct;
import java.util.List;
public class TranslationServiceFactory {
private final TranslationServiceEnum translationService;
private final List translators;
private ITranslator selectedTranslator;
/**
* Autowired constructor
*
* @param translators Translator list
* @param translationService Translation service
*/
public TranslationServiceFactory(List translators, TranslationServiceEnum translationService) {
this.translators = translators;
this.translationService = translationService;
}
public ITranslator getTranslator() {
return selectedTranslator;
}
@PostConstruct
public void selectTranslationService() {
selectedTranslator = translators.stream().filter(iTranslator -> iTranslator.getClass().getSimpleName().equalsIgnoreCase(translationService.toString())).findFirst().orElse(null);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy