The user can set a number of values (which are optional) for a search query that will be passed on to a REST api. So I create a POJO to hold all the set values like
class Search{ private String minPrice; private String maxPrice; private String category; // etc.pp. } When I construct the URL for the api call, i have to check wether that value is set all the time like
if (search.getMinPrice() != null){ url.append("&minprice=" + search.getMinPrice()); } Is there a more convenient/ elegant way to do this
- with pure Java, just a way to "do sth if sth is not null"
- or even a library/tool that lets you construct Urls from objects?