Skip to content

Commit

Permalink
implementing method to make some objects empty, if null
Browse files Browse the repository at this point in the history
  • Loading branch information
kowatsch committed May 16, 2018
1 parent 9af9484 commit f2371e7
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ else if (DbConnData.igniteDb == null)
this.showMetadata = false;
else if (showMetadata.equalsIgnoreCase("true") || showMetadata.equalsIgnoreCase("yes"))
this.showMetadata = true;
else if (showMetadata.equalsIgnoreCase("false") || showMetadata.equals("") || showMetadata.equalsIgnoreCase("no"))
else if (showMetadata.equalsIgnoreCase("false") || showMetadata.equals("")
|| showMetadata.equalsIgnoreCase("no"))
this.showMetadata = false;
else
throw new BadRequestException(
Expand Down Expand Up @@ -353,6 +354,29 @@ private String createEmptyStringIfNull(String toCheck) {
return toCheck;
}

/**
* Looks at specific objects within the RequestParameters object and makes them empty, if they are
* null. Needed for the /ratio computation using POST requests.
*/
public RequestParameters fillWithEmptyIfNull(RequestParameters rPs) {

String[] types = rPs.getTypes();
if (types == null)
types = new String[0];
String[] keys = rPs.getKeys();
if (keys == null)
keys = new String[0];
String[] values = rPs.getValues();
if (values == null)
values = new String[0];

RequestParameters rPs2 = new RequestParameters(rPs.isPost(), rPs.isSnapshot(), rPs.isDensity(),
rPs.getBboxes(), rPs.getBcircles(), rPs.getBpolys(), types, keys, values,
rPs.getUserids(), rPs.getTime(), rPs.getShowMetadata());

return rPs2;
}

/*
* Getters start here
*/
Expand Down

0 comments on commit f2371e7

Please sign in to comment.