Arik Hadas has uploaded a new change for review. Change subject: core: replace explicit field names with constants ......................................................................
core: replace explicit field names with constants In VdsUpdateRunTimeInfo we used to have explicit strings that represented the "appList" and "status" field names in VmDynamic. This patch changes that - new constants are declared in VmDynamic and they are used by VdsUpdateRunTimeInfo. In addition, places where we used to check the size of collections just to see if they are empty or not are replaced with calls to "isEmpty" method - it is better in terms of readability and for some data structure it is more efficient. Change-Id: I614fecc4238cfffbf152b1b39e3c7995974188c2 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java 2 files changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/23101/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java index 4ce3603..1ee4694 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java @@ -64,6 +64,9 @@ @UnchangeableByVdsm private String cpuName; + public static final String APPLICATIONS_LIST_FIELD_NAME = "appList"; + public static final String STATUS_FIELD_NAME = "status"; + @Override public int hashCode() { final int prime = 31; diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 8284f85..2594f0a 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -1052,7 +1052,7 @@ } } - if (vmsToUpdateFromVds.size() > 0) { + if (!vmsToUpdateFromVds.isEmpty()) { // If there are vms that require updating, // get the new info from VDSM in one call, and then update them all updateVmDevices(vmsToUpdateFromVds); @@ -1905,15 +1905,15 @@ props.removeAll(UNCHANGEABLE_FIELDS_BY_VDSM); if (vmNewDynamicData.getStatus() != VMStatus.Up) { - props.remove("appList"); + props.remove(VmDynamic.APPLICATIONS_LIST_FIELD_NAME); vmNewDynamicData.setAppList(vmToUpdate.argvalue.getAppList()); - } else if (props.contains("status") + } else if (props.contains(VmDynamic.STATUS_FIELD_NAME) && vmToUpdate.argvalue.getDynamicData().getStatus() == VMStatus.PreparingForHibernate) { vmNewDynamicData.setStatus(VMStatus.PreparingForHibernate); - props.remove("status"); + props.remove(VmDynamic.STATUS_FIELD_NAME); } // if anything else changed - if (props.size() > 0) { + if (!props.isEmpty()) { vmToUpdate.argvalue.updateRunTimeDynamicData(vmNewDynamicData, _vds.getId(), _vds.getName()); returnValue = true; } @@ -2039,7 +2039,7 @@ } private void addVmInterfaceStatisticsToList(List<VmNetworkInterface> list) { - if (list.size() <= 0) { + if (list.isEmpty()) { return; } _vmInterfaceStatisticsToSave.put(list.get(0).getVmId(), list); -- To view, visit http://gerrit.ovirt.org/23101 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I614fecc4238cfffbf152b1b39e3c7995974188c2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches