My service calls a downstream service, which returns a ResponseEntity<MyBodyClass> response. My service needs to react differently based on different properties of response
For example if response.getStatusCode() == HttpStatus.BAD_REQUEST and response.getBody().code == 1, the service should do some action "A", but if for the same status code the response.getBody().id == 1, then it should do "B". Another example is if response.getStatusCode() == HttpStatus.OK and response.getBody() != null, service should do "C".
I know this can be done with a bunch of if statements, but is there a better design pattern?
Aucun commentaire:
Enregistrer un commentaire