package sk.yonban.aspectchanges;

public aspect TelephoneNumberFormatter {
	private pointcut getTelefonPointcut(): execution(String sk.yonban.model.command.PouzivatelInfoCommand.getTelefon());
	
	private String number;
	
	String around(): getTelefonPointcut() {
		number = proceed();
		processTelephoneNumber();
		return number;
	}
	
	private void processTelephoneNumber() {
		if (number.startsWith("+") || number.startsWith("00")) {
			return;
		}
		if (number.startsWith("0")) {
			number = number.substring(1);
			number = "+421" + number;
		}
	}
}
