Created
December 7, 2015 17:09
-
-
Save thaniaclair/d8c680ad52c571695a53 to your computer and use it in GitHub Desktop.
Renfe Logic for Availability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isTariffApproved() { | |
String currentTariffAvailability = tarifa.getDisponibilidad(); | |
if (Strings.isNullOrEmpty(currentTariffAvailability)) { | |
return false; | |
} | |
if (HIGH_AVAILABILITY.equals(currentTariffAvailability)) { | |
return true; | |
} | |
Integer currentTariffAvailableSeats = Ints.tryParse(currentTariffAvailability); | |
if (currentTariffAvailableSeats < numberOfTravellers) { | |
return false; | |
} | |
int minimumSeats = getMinimumSeats(); | |
if (currentTariffAvailableSeats >= minimumSeats) { | |
return true; | |
} | |
String standardTariffAvailability = getStandardTariffAvailability(); | |
if (Strings.isNullOrEmpty(standardTariffAvailability) || HIGH_AVAILABILITY.equals(standardTariffAvailability)) { | |
return true; | |
} | |
Integer standardTariffAvailableSeats = Ints.tryParse(currentTariffAvailability); | |
return (standardTariffAvailableSeats - currentTariffAvailableSeats) > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The rest of the logic is ok.