I dont understand what is happening in my application. I'm sending PUT request with updates from Angular project to java api. I have a method that validates query parameters from the put request, the method looks like this:
private JsonObject validateRequestBody(JsonElement requestBody) {
if (!(requestBody instanceof JsonObject)) {
throw new IllegalArgumentException("Request body cannot be case to JSON object");
}
JsonObject bodyObj = requestBody.getAsJsonObject();
System.out.println(bodyObj.get("entityIri").equals(null));
if (bodyObj.get("entityIri") == null) {
System.out.println("null");
throw new IllegalArgumentException("Request body must contain entity IRI");
}
return bodyObj;
}
As you can see, I'm just trying to check if the enityIri
paramter is equal to null. To test it, Im sending null
as entityIri
from Angular project. I tried to compare them with equal
method and with ==
, but in both cases the output is always false. Could someone explain me why they are not equal? Is it because I'm passing it to JsonObject
?
I attach a screenshot from debugging (I cut out irrelevant parts).