Handle NPE in DRL Accumulate LHS

Kick Source

I am using drool accumulate function for calculation. The getAssetDetail() applied on $fin may be NULL due to which it is giving NPE. I want to execute accumulate function in case getAssetDetail() is not null else set value as 0.

    $fin            :       FinancialInfo();

    $assetDetail    :       Double() from accumulate(AssetSubDetl($qs: assetDetlRec,assetSubTyp == "Hello" ) from $fin.getAssetDetail().getAssetSubDetl(),
                                            init(double total = 0),
                                            action(for(Object q: $qs)
                                            total = total + Double.valueOf(((AssetDetlRec)q).getOnShore()) + Double.valueOf(((AssetDetlRec)q).getOffShore());),

Class FinancialInfo{
 private AssetDetail assetDetail;

Class AssetDetail{
private List<AssetSubDetl> assetSubDetl;

Class AssetSubDetl{
private List<AssetDetlRec> assetDetlRec;

Class AssetDetlRec{
private String onShore;
private String offShore;


comments powered by Disqus