All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.deepdreams.worker.api.context.HourlySalaryContext Maven / Gradle / Ivy

There is a newer version: 0.1.1-RELEASE
Show newest version
package tech.deepdreams.worker.api.context;
import java.util.Map;
import java.util.ServiceLoader ;
import java.util.ServiceLoader.Provider;
import tech.deepdreams.worker.api.exceptions.ServiceNotFoundException;
import tech.deepdreams.worker.api.services.HourlySalaryService;

public class HourlySalaryContext {
	private HourlySalaryService hourlySalaryService ;
	
	public HourlySalaryContext(String countryCode, String code, int version){
		this.hourlySalaryService = ServiceLoader.load(HourlySalaryService.class)
					 .stream()
					 .map(Provider::get)
					 .filter(service -> service.country().equals(countryCode) &&  service.code().equals(code) && service.version() == version) 
					 .findAny()
					 .orElseThrow(() -> new ServiceNotFoundException()) ;
	}
	
	
	public Double calculate(Map params) {
		return hourlySalaryService.calculate(params) ;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy