Source:
<code>public void Initialize(SystemTreeItemModel systemTreeSelectedItem) { super.Initialize(systemTreeSelectedItem); AsyncDataProvider.GetDataCenterById(new AsyncQuery(getModel(), new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { UnitVmModel model = (UnitVmModel) target; if (returnValue != null) { storage_pool dataCenter = (storage_pool) returnValue; ArrayList<storage_pool> list = new ArrayList<storage_pool>(Arrays.asList(new storage_pool[] { dataCenter })); model.SetDataCenter(model, list); model.getDataCenter().setIsChangable(false); } else { ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) model.getBehavior(); VM currentVm = behavior.vm; VDSGroup tempVar = new VDSGroup(); tempVar.setId(currentVm.getVdsGroupId()); tempVar.setname(currentVm.getVdsGroupName()); tempVar.setcompatibility_version(currentVm.getVdsGroupCompatibilityVersion()); tempVar.setStoragePoolId(currentVm.getStoragePoolId()); VDSGroup cluster = tempVar; model.getCluster() .setItems(new ArrayList<VDSGroup>(Arrays.asList(new VDSGroup[] { cluster }))); model.getCluster().setSelectedItem(cluster); behavior.InitTemplate(); behavior.InitCdImage(); } } }, getModel().getHash()), vm.getStoragePoolId()); AsyncDataProvider.GetWatchdogByVmId(new AsyncQuery(this.getModel(), new INewAsyncCallback() { public void OnSuccess(Object target, Object returnValue) { UnitVmModel model = (UnitVmModel) target; VdcQueryReturnValue val = (VdcQueryReturnValue) returnValue; @SuppressWarnings("unchecked") <START> Collection<VmWatchdog> watchdogs = (Collection<VmWatchdog>) val.getReturnValue(); <END> for(VmWatchdog watchdog: watchdogs) { model.getWatchdogAction().setEntity(watchdog.getAction()); model.getWatchdogModel().setEntity(watchdog.getModel()); } } }), vm.getId()); }</code><technical_language>null check move casting logic converter AsyncDataProvider</technical_language>

Target:
public void Initialize(SystemTreeItemModel systemTreeSelectedItem) { super.Initialize(systemTreeSelectedItem); AsyncDataProvider.GetDataCenterById(new AsyncQuery(getModel(), new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { UnitVmModel model = (UnitVmModel) target; if (returnValue != null) { storage_pool dataCenter = (storage_pool) returnValue; ArrayList<storage_pool> list = new ArrayList<storage_pool>(Arrays.asList(new storage_pool[] { dataCenter })); model.SetDataCenter(model, list); model.getDataCenter().setIsChangable(false); } else { ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) model.getBehavior(); VM currentVm = behavior.vm; VDSGroup tempVar = new VDSGroup(); tempVar.setId(currentVm.getVdsGroupId()); tempVar.setname(currentVm.getVdsGroupName()); tempVar.setcompatibility_version(currentVm.getVdsGroupCompatibilityVersion()); tempVar.setStoragePoolId(currentVm.getStoragePoolId()); VDSGroup cluster = tempVar; model.getCluster() .setItems(new ArrayList<VDSGroup>(Arrays.asList(new VDSGroup[] { cluster }))); model.getCluster().setSelectedItem(cluster); behavior.InitTemplate(); behavior.InitCdImage(); } } }, getModel().getHash()), vm.getStoragePoolId()); AsyncDataProvider.GetWatchdogByVmId(new AsyncQuery(this.getModel(), new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { UnitVmModel model = (UnitVmModel) target; VdcQueryReturnValue val = (VdcQueryReturnValue) returnValue; @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = (Collection<VmWatchdog>) val.getReturnValue(); for(VmWatchdog watchdog: watchdogs) { model.getWatchdogAction().setEntity(watchdog.getAction()); model.getWatchdogModel().setEntity(watchdog.getModel()); } } }), vm.getId()); }