Skip to content
Advertisement

Tag: optional-parameters

Microservices communication with optional parameters requests

I have a room service which returns detail for rooms when requesting http://localhost:8082/room/search/byRoomChar Now I want to request this @GetMapping from the booking service since this is the application gateway that users are going to interact with using the http://localhost:8081/booking/search/byRoomChar. Room entity code: Room repository code: However, this does not work because when omitting parameters when calling the getmapping from

How do I use optional parameters in Java?

What specification supports optional parameters? Answer There are several ways to simulate optional parameters in Java: Method overloading. void foo(String a, Integer b) { //… } void foo(String a) { foo(a, 0); // here, 0 is a default value for b } foo(“a”, 2); foo(“a”); One of the limitations of this approach is that it doesn’t work if you have

Advertisement