class SymbolService {

	public Symbol addSymbol(String code, String name, String countryFlag, String currencyCode) {
		requireNonNull(code, "code is null");
		requireNonNull(name, "name is null");
		
		if(symbolRepo.existsById(code)) {
			throw SymbolException.alreadyExists(code);
		}

		SymbolEntity se = new SymbolEntity(code);
		se.setName(name);
		se.setCountryFlag(countryFlag);
		
		if(currencyCode != null) {
			se.setCurrency(new SymbolEntity(currencyCode));
		}

		return symbolMapper.mapToSymbol(symbolRepo.save(se));
	}

}