If the object doesn't have any discounts the line item object doesn't have a "hasDiscounts" boolean field nor the method returns false.
In order to avoid the issue, I use
lineItem.getDiscounts != null
where it could be :
if(lineItem.hasDiscounts){
//Logic
}
Is this the intended behavior or can this be considered into implementation?