I am using ObjectUtils.isEmpty()
as generic to check for the null and empty fields.It was working fine for the term like:
MyClass class = new MyClass()
class.setName(null);
if (!ObjectUtils.isEmpty(class.getName)) {
return "Name";
}
But it is not working , when am trying it for the Object as below:
Object activatedDate = jsonObject.getJSONArray("records")
.getJSONObject(i).get("ActivatedDate");
return ObjectUtils.isEmpty(activatedDate) ? null : "hello";
and My json is:
[
{
"LastModifiedDate": "2018-05-23T10:58:18.000+0000",
"Order_Submission_Outcome__c": "test",
"Number_of_Orders__c": 0,
"Sales_Code__c": null,
"Opportunity__c": "FERERR",
"Contract_Type__c": "EZ Order Form",
"StatusCode": "Draft",
"CreatedDate": "2018-05-23T10:56:22.000+0000",
"Id": "FERERR",
"ActivatedDate": null,
"Contract_Status__c": "ACTIVE",
"Opportunity_Act_Total_Lines__c": 1
}
]
But it always returns hello
even though the object activatedDate
is null. What is the problem?