auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected Locale getLocaleFromRequest(final HttpServletRequest request) { String localeString = getLocaleStringFromReferer(request); //Unable to determine locale string from referer (preferred way) if (null == localeString) { //Note this fails if the is something like /menu.css localeString = getLocaleStringFromPath(request.getPathInfo()); } //Validate that the locale string is valid. Locale locale = LocaleUtils.getLocaleFromString(localeString, true); return locale; }

Target:
protected Locale getLocaleFromRequest(final HttpServletRequest request) { String localeString = getLocaleStringFromReferer(request); //Unable to determine locale string from referer (preferred way) if (localeString == null) { //Note this fails if the is something like /menu.css localeString = getLocaleStringFromPath(request.getPathInfo()); } //Validate that the locale string is valid. Locale locale = LocaleUtils.getLocaleFromString(localeString, true); return locale; }
Source:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Locate the requested file: File file = ServletUtils.makeFileFromSanePath(request.getPathInfo(), base); file = checkForIndex(request, response, file, request.getPathInfo()); if (null == file) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { // Send the content of the file: // type is the default MIME type of the Servlet. ServletUtils.sendFile(request, response, file, type); } }

Target:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Locate the requested file: File file = ServletUtils.makeFileFromSanePath(request.getPathInfo(), base); file = checkForIndex(request, response, file, request.getPathInfo()); if (file == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { // Send the content of the file: // type is the default MIME type of the Servlet. ServletUtils.sendFile(request, response, file, type); } }
Source:
private boolean canDoSnapshot(VM vm) { //if version is 3.0 - live snapshot is not available, thus if vm is up snapshot is not possible so it needs to be //checked if it's up or not //if version is 3.1, there is no need to check if vm is up since in any case snapshot is possible boolean canSnapshot = true; if(!isLiveSnapshotEnabled() && !ImagesHandler.isVmDown(vm)) { //if there is no live snapshot and the vm is up - snapshot is not possible addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT); canSnapshot = false; } return canSnapshot; }

Target:
private boolean canDoSnapshot(VM vm) { // if live snapshot is not available, then if vm is up - snapshot is not possible so it needs to be // checked if vm up or not // if live snapshot is enabled, there is no need to check if vm is up since in any case snapshot is possible if (!isLiveSnapshotEnabled() && !ImagesHandler.isVmDown(vm)) { // if there is no live snapshot and the vm is up - snapshot is not possible addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT); return false; } return true; }
Source:
private boolean addMacToMap(Map<String, Integer> macMap, String mac) { boolean returnValue = false; if (!macMap.containsKey(mac)) { macMap.put(mac, 1); // First time this mac is used returnValue = true; } else if (allowDuplicate()) { incrementMacInMap(macMap, mac); returnValue = true; } return returnValue; }

Target:
private boolean addMacToMap(Map<String, Integer> macMap, String mac) { if (!macMap.containsKey(mac)) { macMap.put(mac, 1); return true; } else if (allowDuplicate()) { incrementMacInMap(macMap, mac); return true; } return false; }
Source:
protected void endVmCommand() { super.endVmCommand(); // if we got here, the target snapshot exists for sure getSnapshotDao().updateStatus(getParameters().getDstSnapshotId(), SnapshotStatus.OK); }

Target:
protected void endVmCommand() { // if we got here, the target snapshot exists for sure getSnapshotDao().updateStatus(getParameters().getDstSnapshotId(), SnapshotStatus.OK); super.endVmCommand(); }
Source:
public void dataCenterDoesntExist() throws Exception { doReturn(null).when(validator).getDataCenter(); // replace default mock data center with null data center assertEquals(new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST).getMessage(), validator.dataCenterExists().getMessage()); }

Target:
public void dataCenterDoesntExist() throws Exception { doReturn(null).when(validator).getDataCenter(); // replace default mock data center with null data center assertEquals(new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST), validator.dataCenterExists()); }
Source:
public SubTabProviderGeneralView(DetailModelProvider<ProviderListModel, ProviderGeneralModel> modelProvider) { super(modelProvider); // Init formPanel formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); // Build a form using the FormBuilder formBuilder = new FormBuilder(formPanel, 1, 1); formBuilder.addFormItem(new FormItem(constants.nameProvider(), name, 0, 0)); }

Target:
public SubTabProviderGeneralView(DetailModelProvider<ProviderListModel, ProviderGeneralModel> modelProvider) { super(modelProvider); // Init formPanel formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); driver.initialize(this); // Build a form using the FormBuilder formBuilder = new FormBuilder(formPanel, 1, 1); formBuilder.addFormItem(new FormItem(constants.nameProvider(), name, 0, 0)); }
Source:
public void setMainTabSelectedItem(Provider selectedItem) { Driver.driver.edit(getDetailModel()); formBuilder.update(getDetailModel()); }

Target:
public void setMainTabSelectedItem(Provider selectedItem) { driver.edit(getDetailModel()); formBuilder.update(getDetailModel()); }
Source:
public static synchronized void removeFromCache(String key){ if (attestationValues.containsKey(key)){ attestationValues.remove(key); } }

Target:
public static synchronized void removeFromCache(String key){ if (key != null){ attestationValues.remove(key); } }
Source:
protected boolean canDoAction() { boolean returnValue = super.canDoAction(); // the condition allows to get only user and password which are both set (even with empty string) or both aren't // set (null), the action will fail if only one of those parameters is null. if (returnValue && (getParameters().getSysPrepUserName() == null ^ getParameters().getSysPrepPassword() == null)) { addCanDoActionMessage(VdcBllMessages.VM_CANNOT_RUN_ONCE_WITH_ILLEGAL_SYSPREP_PARAM); returnValue = false; } // only administrator can specify destination host if(getParameters().getDestinationVdsId() != null && !getCurrentUser().isAdmin()) { addCanDoActionMessage(VdcBllMessages.VM_CANNOT_RUN_ONCE_NOT_ADMIN_FOR_DESTINATION_VDS_PARAM); returnValue = false; } return returnValue; }

Target:
protected boolean canDoAction() { boolean returnValue = super.canDoAction(); // the condition allows to get only user and password which are both set (even with empty string) or both aren't // set (null), the action will fail if only one of those parameters is null. if (returnValue && (getParameters().getSysPrepUserName() == null ^ getParameters().getSysPrepPassword() == null)) { addCanDoActionMessage(VdcBllMessages.VM_CANNOT_RUN_ONCE_WITH_ILLEGAL_SYSPREP_PARAM); returnValue = false; } return returnValue; }
Source:
protected storage_domains createStorageDomain(int availableSpace, Guid storageDomainId) { storage_domains sd = new storage_domains(); sd.setstorage_domain_type(StorageDomainType.Master); sd.setstatus(StorageDomainStatus.Active); sd.setavailable_disk_size(availableSpace); sd.setused_disk_size(USED_SPACE_GB); sd.setId(storageDomainId); return sd; }

Target:
private static storage_domains createStorageDomain(int availableSpace, Guid storageDomainId) { storage_domains sd = new storage_domains(); sd.setstorage_domain_type(StorageDomainType.Master); sd.setstatus(StorageDomainStatus.Active); sd.setavailable_disk_size(availableSpace); sd.setused_disk_size(USED_SPACE_GB); sd.setId(storageDomainId); return sd; }
Source:
public Hosts list() { // Filtered users are not allowed to view hosts if (isFiltered()) { throw new WebApplicationException(Response.Status.FORBIDDEN); } ApplicationMode appMode = getCurrent().get(ApplicationMode.class); if (appMode == ApplicationMode.GlusterOnly) { return listGlusterOnly(); } else { return listAll(); } }

Target:
public Hosts list() { ApplicationMode appMode = getCurrent().get(ApplicationMode.class); if (appMode == ApplicationMode.GlusterOnly) { return listGlusterOnly(); } else { return listAll(); } }
Source:
private boolean removeVm() { VM vm = getVm(); Guid vmId = getVmId(); hasImages = vm.getDiskList().size() > 0; if (getParameters().isRemoveDisks() && hasImages) { if (!removeVmImages(null)) { return false; // We get here if we got imageDoesNotExistsInDomain for all the VM disks from VDSM. } else if (getReturnValue().getTaskIdList().isEmpty()) { endCommandWithoutTasks(); } } else { endCommandWithoutTasks(); } return true; }

Target:
private boolean removeVm() { VM vm = getVm(); hasImages = vm.getDiskList().size() > 0; if (getParameters().isRemoveDisks() && hasImages) { if (!removeVmImages(null)) { return false; } } else { endCommandWithoutTasks(); } return true; }
Source:
public VDSReturnValue runVdsCommand(VDSCommandType commandType, VDSParametersBase parameters) throws VdcBLLException { VDSReturnValue returnValue = getBackendResourceManager().RunVdsCommand(commandType, parameters); if (!returnValue.getSucceeded()) { throw new VdcBLLException(returnValue.getVdsError().getCode(), returnValue.getVdsError() .getMessage()); } return returnValue; }

Target:
protected VDSReturnValue runVdsCommand(VDSCommandType commandType, VDSParametersBase parameters) throws VdcBLLException { VDSReturnValue returnValue = getBackendResourceManager().RunVdsCommand(commandType, parameters); if (!returnValue.getSucceeded()) { throw new VdcBLLException(returnValue.getVdsError().getCode(), returnValue.getVdsError() .getMessage()); } return returnValue; }
Source:
public String toString() { StringBuilder builder = new StringBuilder(50); builder.append("commandId: "); //$NON-NLS-1$ builder.append(getCommandId()); builder.append(", user: "); //$NON-NLS-1$ builder.append(getParametersCurrentUser().getUserName()); builder.append(", commandType: "); //$NON-NLS-1$ builder.append(getCommandType()); return builder.toString(); }

Target:
public String toString() { StringBuilder builder = new StringBuilder(50); builder.append("commandId: "); //$NON-NLS-1$ builder.append(getCommandId()); builder.append(", user: "); //$NON-NLS-1$ if(getParametersCurrentUser() != null) { builder.append(getParametersCurrentUser().getUserName()); } builder.append(", commandType: "); //$NON-NLS-1$ builder.append(getCommandType()); return builder.toString(); }
Source:
private void debugAction(VdcActionType actionType, VdcActionParametersBase params) { if(log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(50); builder.append("Action type: "); //$NON-NLS-1$ builder.append(actionType); builder.append(", Parameters: "); //$NON-NLS-1$ builder.append(params); } }

Target:
private void debugAction(VdcActionType actionType, VdcActionParametersBase params) { if(log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(50); builder.append("Action type: "); //$NON-NLS-1$ builder.append(actionType); builder.append(", Parameters: "); //$NON-NLS-1$ builder.append(params); log.debug(builder.toString()); } }
Source:
private Guid getQuotaIdForDisk(DiskImage diskImage) { // If the DiskInfoDestinationMap is available and contains information about the disk if (getParameters().getDiskInfoDestinationMap() != null && getParameters().getDiskInfoDestinationMap().get(diskImage.getId()) != null) { return getParameters().getDiskInfoDestinationMap().get(diskImage.getId()).getQuotaId(); } else { return diskImage.getQuotaId(); } }

Target:
private Guid getQuotaIdForDisk(DiskImage diskImage) { // If the DiskInfoDestinationMap is available and contains information about the disk if (getParameters().getDiskInfoDestinationMap() != null && getParameters().getDiskInfoDestinationMap().get(diskImage.getId()) != null) { return getParameters().getDiskInfoDestinationMap().get(diskImage.getId()).getQuotaId(); } return diskImage.getQuotaId(); }
Source:
protected Guid getUpServerId() { if (brick == null) { return super.getUpServerId(clusterId); } VDS brickServer = getVdsDao().get(brick.getServerId()); if (brickServer.getStatus() == VDSStatus.Up) { return brickServer.getId(); } // brick server is down return super.getUpServerId(clusterId); }

Target:
protected Guid getUpServerId() { if (brick == null) { return getUpServerId(clusterId); } VDS brickServer = getVdsDao().get(brick.getServerId()); if (brickServer.getStatus() == VDSStatus.Up) { return brickServer.getId(); } // brick server is down return super.getUpServerId(clusterId); }
Source:
protected void buildVmWatchdog() { throw new NotImplementedException("not implemented"); // Not supported in old code }

Target:
protected void buildVmWatchdog() { // Not supported in old code }
Source:
protected void executeCommand() { List<VmDevice> watchdogs = getWatchdogs(); VmDevice watchdogDevice = watchdogs.get(0); // there must be only one watchdogDevice.setSpecParams(getSpecParams()); getVmDeviceDao().update(watchdogDevice); setActionReturnValue(watchdogDevice); setSucceeded(true); }

Target:
protected void executeCommand() { List<VmDevice> watchdogs = getWatchdogs(); VmDevice watchdogDevice = watchdogs.get(0); // there must be only one watchdogDevice.setSpecParams(getSpecParams()); getVmDeviceDao().update(watchdogDevice); setSucceeded(true); }
Source:
protected <T> boolean matchEntity(VmWatchdog entity, T id) { //since there can be only one return true; }

Target:
protected <T> boolean matchEntity(VmWatchdog entity, T id) { return entity.getId().equals(id); }
Source:
private String getFullPath(final String path) { String result = null; if (ServletUtils.isSane(path)) { List<BrandingTheme> brandingPaths = brandingManager. getBrandingThemes(); for (BrandingTheme brandingTheme: brandingPaths) { if (path.startsWith(brandingTheme.getPath())) { result = brandingManager.getBrandingRootPath(). getAbsolutePath() + path; } } } else { log.error("The path \"" + path //$NON-NLS-1$ + "\" is not sane"); //$NON-NLS-1$ } return result; }

Target:
String getFullPath(final String path) { String result = null; if (ServletUtils.isSane(path)) { // Return a result relative to the branding root path. result = brandingManager.getBrandingRootPath().getAbsolutePath() + path; } else { log.error("The path \"" + path + "\" is not sane"); //$NON-NLS-1$ //$NON-NLS-2$ } return result; }
Source:
public void edit(final HostBondInterfaceModel object) { super.edit(object); // hide widgets info.setVisible(false); message.setVisible(false); checkConnectivity.setVisible(false); commitChanges.setVisible(false); // resize layoutPanel.remove(infoPanel); layoutPanel.setWidgetSize(mainPanel, 300); asPopupPanel().setPixelSize(400, 400); }

Target:
public void edit(final HostBondInterfaceModel object) { super.edit(object); // hide widgets info.setVisible(false); message.setVisible(false); // resize layoutPanel.remove(infoPanel); layoutPanel.setWidgetSize(mainPanel, 300); asPopupPanel().setPixelSize(400, 400); }
Source:
public void setLunId(String value) { if (!privateLunId.equals(value)) { privateLunId = value; onPropertyChanged(new PropertyChangedEventArgs("LUN ID")); //$NON-NLS-1$ } }

Target:
public void setLunId(String value) { if (privateLunId != null && !privateLunId.equals(value)) { privateLunId = value; onPropertyChanged(new PropertyChangedEventArgs("LUN ID")); //$NON-NLS-1$ } }
Source:
public BootSequence getSequence() { StringBuilder str = new StringBuilder(""); //$NON-NLS-1$ for (EntityModel a : getItems()) { if (a.getIsChangable()) { BootSequence bs = (BootSequence) a.getEntity(); str.append(bs.toString()); } } return !str.equals("") ? BootSequence.valueOf(str.toString()) : null; //$NON-NLS-1$ }

Target:
public BootSequence getSequence() { StringBuilder str = new StringBuilder(); for (EntityModel a : getItems()) { if (a.getIsChangable()) { BootSequence bs = (BootSequence) a.getEntity(); str.append(bs.toString()); } } return !str.equals("") ? BootSequence.valueOf(str.toString()) : null; //$NON-NLS-1$ }
Source:
protected void revertTask() { // Preventing rollback on VmReplicateDiskFinish success // (checks whether the disk moved successfully to the target storage domain) Guid targetStorageDomainId = getEnclosingCommand().getParameters().getTargetStorageDomainId(); Guid destinationImageId = getEnclosingCommand().getParameters().getDestinationImageId(); DiskImage diskImage = getDiskImageDao().get(destinationImageId); if (diskImage != null && diskImage.getStorageIds().get(0) == targetStorageDomainId) { getEnclosingCommand().getParameters().setExecutionIndex(0); } }

Target:
protected void revertTask() { // Preventing rollback on VmReplicateDiskFinish success // (checks whether the disk moved successfully to the target storage domain) Guid targetStorageDomainId = getEnclosingCommand().getParameters().getTargetStorageDomainId(); Guid destinationImageId = getEnclosingCommand().getParameters().getDestinationImageId(); DiskImage diskImage = getDiskImageDao().get(destinationImageId); if (diskImage != null && targetStorageDomainId.equals(diskImage.getStorageIds().get(0))) { getEnclosingCommand().getParameters().setExecutionIndex(0); } }
Source:
public BootSequence getSequence() { StringBuilder str = new StringBuilder(); for (EntityModel a : getItems()) { if (a.getIsChangable()) { BootSequence bs = (BootSequence) a.getEntity(); str.append(bs.toString()); } } String bootStr = str.toString(); if (!bootStr.equals("")) { //$NON-NLS-1$ return BootSequence.valueOf(bootStr); } return null; }

Target:
public BootSequence getSequence() { StringBuilder str = new StringBuilder(); for (EntityModel a : getItems()) { if (a.getIsChangable()) { BootSequence bs = (BootSequence) a.getEntity(); str.append(bs.toString()); } } return !str.toString().equals("") ? BootSequence.valueOf(str.toString()) : null; //$NON-NLS-1$ }
Source:
private void cleanConnection(StorageServerConnections connection, Guid hostId) { // if create connection command was the one to fail and didn't create a connection // then the id of connection will be empty, and there's nothing to delete. if (connection.getid()!=null && !connection.getid().equalsIgnoreCase("")) { Frontend.RunAction(VdcActionType.RemoveStorageServerConnection, new StorageServerConnectionParametersBase(connection, hostId), null, this); } }

Target:
private void cleanConnection(StorageServerConnections connection, Guid hostId) { // if create connection command was the one to fail and didn't create a connection // then the id of connection will be empty, and there's nothing to delete. if (connection.getid() != null && !connection.getid().equals("")) { //$NON-NLS-1$ Frontend.RunAction(VdcActionType.RemoveStorageServerConnection, new StorageServerConnectionParametersBase(connection, hostId), null, this); } }
Source:
protected VDSCommandType getRevertVDSCommandType() { return VDSCommandType.DeleteImageGroup; }

Target:
protected VDSCommandType getRevertVDSCommandType() { return null; // nothing to do }
Source:
protected VDSParametersBase getRevertVDSParameters() { DeleteImageGroupVDSCommandParameters parameters = new DeleteImageGroupVDSCommandParameters(); parameters.setStoragePoolId(getEnclosingCommand().getParameters().getStoragePoolId()); parameters.setStorageDomainId(getEnclosingCommand().getParameters().getStorageDomainId()); parameters.setImageGroupId(getEnclosingCommand().getParameters().getImageGroupID()); return parameters; }

Target:
protected VDSParametersBase getRevertVDSParameters() { return null; // nothing to do }
Source:
public boolean isWebSocketProxyDefined() { String wsConfig = (String) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.WebSocketProxy); return wsConfig != null && !"".equals(wsConfig) && !"Off".equals(wsConfig); //$NON-NLS-1$ $NON-NLS-2$ }

Target:
public boolean isWebSocketProxyDefined() { String wsConfig = (String) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.WebSocketProxy); return wsConfig != null && !"".equals(wsConfig) && !"Off".equalsIgnoreCase(wsConfig); //$NON-NLS-1$ $NON-NLS-2$ }
Source:
public boolean shouldVdsBeFenced() { boolean result = false; switch (vds.getStatus()) { case Down: case InstallFailed: case Maintenance: case NonOperational: case NonResponsive: result = true; break; default: break; } return result; }

Target:
public boolean shouldVdsBeFenced() { boolean result = false; // Not using exists() here in order not to add canDoAction message if (vds == null) { return false; } switch (vds.getStatus()) { case Down: case InstallFailed: case Maintenance: case NonOperational: case NonResponsive: result = true; break; default: break; } return result; }
Source:
public String getCascadedResource(String resourceName) { List<BrandingTheme> brandingThemes = getBrandingThemes(); // assume these are sorted 00, 01, 02, etc. for (int i = brandingThemes.size() - 1; i >= 0; i--) { String resourcePath = brandingThemes.get(i).getResourcePath(resourceName); if (resourcePath != null) { return resourcePath; } } return null; }

Target:
public String getCascadedResource(String resourceName) { if (resourceName != null) { List<BrandingTheme> brandingThemes = getBrandingThemes(); // assume these are sorted 00, 01, 02, etc. for (int i = brandingThemes.size() - 1; i >= 0; i--) { String resourcePath = brandingThemes.get(i).getResourcePath(resourceName); if (resourcePath != null) { return resourcePath; } } } return null; }
Source:
void forceRefresh(M model) { if (model instanceof SearchableListModel) { UICommand lastExecutedCommand = model.getLastExecutedCommand(); if (lastExecutedCommand != null && !lastExecutedCommand.getIsCancel()) { // Refresh the grid using ForceRefresh command SearchableListModel searchableList = (SearchableListModel) model; searchableList.getForceRefreshCommand().execute(); } } }

Target:
void forceRefresh(M model) { if (model instanceof SearchableListModel) { UICommand lastExecutedCommand = model.getLastExecutedCommand(); if (lastExecutedCommand != null && !lastExecutedCommand.getIsCancel()) { // Refresh grid after invoking non-cancel command SearchableListModel searchableList = (SearchableListModel) model; searchableList.forceRefresh(); } } }
Source:
protected BaseEditVmInterfaceModel(VmBase vm, VMStatus vmStatus, Guid dcId, Version clusterCompatibilityVersion, ArrayList<VmNetworkInterface> vmNicList, VmNetworkInterface nic, EntityModel sourceModel) { super(vm, dcId, clusterCompatibilityVersion, vmNicList, sourceModel, new EditProfileBehavior()); this.nic = nic; this.vmStatus = vmStatus; setTitle(ConstantsManager.getInstance().getConstants().editNetworkInterfaceTitle()); setHashName("edit_network_interface_vms"); //$NON-NLS-1$ }

Target:
protected BaseEditVmInterfaceModel(VmBase vm, VMStatus vmStatus, Guid dcId, Version clusterCompatibilityVersion, ArrayList<VmNetworkInterface> vmNicList, VmNetworkInterface nic, EntityModel sourceModel) { super(vm, vmStatus, dcId, clusterCompatibilityVersion, vmNicList, sourceModel, new EditProfileBehavior()); this.nic = nic; setTitle(ConstantsManager.getInstance().getConstants().editNetworkInterfaceTitle()); setHashName("edit_network_interface_vms"); //$NON-NLS-1$ }
Source:
public Disk getDisk() { if (disk == null) { disk = getDiskDao().get(getParameters().getDiskId()); } return disk; }

Target:
protected Disk getDisk() { if (disk == null) { disk = getDiskDao().get(getParameters().getDiskId()); } return disk; }
Source:
private static long retrieveIsoFileSize(Map.Entry<String, Map<String, String>> isoFileWithMetadata) { // old VDSM versions don't provide the metadata for iso files therefore engine marks size as not available String sizeValue = isoFileWithMetadata.getValue().get("size"); if (sizeValue == null) { return SIZE_IS_NOT_AVAILABLE; } try { return Long.valueOf(sizeValue); } catch (NumberFormatException e) { // illegal number is treated as not available, treating exception in UI will be more complicate log.errorFormat("File's '{0}' size is illegal number", isoFileWithMetadata.getKey(), e); return SIZE_IS_NOT_AVAILABLE; } }

Target:
private static long retrieveIsoFileSize(Map.Entry<String, Map<String, String>> isoFileWithMetadata) { String sizeValue = isoFileWithMetadata.getValue().get("size"); try { return Long.valueOf(sizeValue); } catch (NumberFormatException e) { // Illegal number or null are treated as not available, handling // exception in UI will be more complicate log.errorFormat("File's '{0}' size is illegal number", isoFileWithMetadata.getKey(), e); return SIZE_IS_NOT_AVAILABLE; } }
Source:
protected void entityPropertyChanged(Object sender, PropertyChangedEventArgs e) { super.entityPropertyChanged(sender, e); if (e.PropertyName.equals("status")) //$NON-NLS-1$ { getSearchCommand().execute(); } }

Target:
protected void entityPropertyChanged(Object sender, PropertyChangedEventArgs e) { super.entityPropertyChanged(sender, e); getSearchCommand().execute(); }
Source:
private void handleTitlePanel(String eventType, Element parent) { if (title == "") { //$NON-NLS-1$ // no need to show/hide title return; } titlePanel.setWidget(new Label(title)); if (BrowserEvents.MOUSEOVER.equals(eventType)) { titlePanel.showRelativeTo(parent); } else if (BrowserEvents.MOUSEOUT.equals(eventType)) { titlePanel.hide(); } }

Target:
private void handleTitlePanel(String eventType, Element parent) { if (title.isEmpty()) { // no need to show/hide title return; } titlePanel.setWidget(new Label(title)); if (BrowserEvents.MOUSEOVER.equals(eventType)) { titlePanel.showRelativeTo(parent); } else if (BrowserEvents.MOUSEOUT.equals(eventType)) { titlePanel.hide(); } }
Source:
public String getRelativePath() { String path = getPath(); if (path.startsWith("/")) { //$NON-NLS-1$ path = path.substring(1); } return path; }

Target:
public String getRelativePath() { String path = getPath(); return path.startsWith("/") ? path.substring(1) : path; //$NON-NLS-1$ }
Source:
public GlusterBricks list() { boolean flag = QueryHelper.hasMatrixParam(getUriInfo(), "force"); List<GlusterBrickEntity> bricks = getBackendCollection(VdcQueryType.GetGlusterVolumeBricks, new IdQueryParameters(asGuid(getVolumeId()))); GlusterBricks bricksModel = mapCollection(bricks); return addActions(bricksModel); }

Target:
public GlusterBricks list() { List<GlusterBrickEntity> bricks = getBackendCollection(VdcQueryType.GetGlusterVolumeBricks, new IdQueryParameters(asGuid(getVolumeId()))); GlusterBricks bricksModel = mapCollection(bricks); return addActions(bricksModel); }
Source:
public void unregisterHandlers() { for (HandlerRegistration reg: handlerRegistrations) { reg.removeHandler(); // can't call unregisterHandler(reg) as that would modify the list during iteration } handlerRegistrations.clear(); }

Target:
public final void unregisterHandlers() { for (HandlerRegistration reg: handlerRegistrations) { reg.removeHandler(); // can't call unregisterHandler(reg) as that would modify the list during iteration } handlerRegistrations.clear(); }
Source:
protected void syncSearch() { if (getEntity() == null) { return; } if (getEntity() != null) { GlusterVolumeEntity glusterVolumeEntity = (GlusterVolumeEntity) getEntity(); // If the items are same, just fire the item changed event to make sure that items are displayed if (getItems() == glusterVolumeEntity.getBricks()) { getItemsChangedEvent().raise(this, EventArgs.Empty); } else { setItems(glusterVolumeEntity.getBricks()); } } else { setItems(null); } }

Target:
protected void syncSearch() { if (getEntity() != null) { GlusterVolumeEntity glusterVolumeEntity = (GlusterVolumeEntity) getEntity(); // If the items are same, just fire the item changed event to make sure that items are displayed if (getItems() == glusterVolumeEntity.getBricks()) { getItemsChangedEvent().raise(this, EventArgs.Empty); } else { setItems(glusterVolumeEntity.getBricks()); } } else { setItems(null); } }
Source:
public NetworkModification(T parameters) { super(parameters); this.setStoragePoolId(getNetwork().getDataCenterId()); }

Target:
public NetworkModification(T parameters) { super(parameters); setStoragePoolId(getNetwork().getDataCenterId()); }
Source:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getRemoveCommand()) { remove(); } else if ("Cancel".equals(command.getName())) { //$NON-NLS-1$ cancel(); } }

Target:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getRemoveCommand()) { remove(); } }
Source:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getNewCommand()) { newSubnet(); } else if (command == getRemoveCommand()) { remove(); } else if ("Cancel".equals(command.getName())) { //$NON-NLS-1$ cancel(); } }

Target:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getNewCommand()) { newSubnet(); } else if (command == getRemoveCommand()) { remove(); } }
Source:
protected void initLineModel(KeyValueLineModel keyValueLineModel, String key) { keyValueLineModel.getValue().setIsAvailable(false); keyValueLineModel.getValues().setIsAvailable(false); }

Target:
protected void initLineModel(KeyValueLineModel keyValueLineModel, String key) { // no implementation }
Source:
public void setRefreshRate(int interval) { if (getRefreshRate() == interval) { return; } reset(); logger.fine("GridTimer[" + name + "]: Refresh Rate set to: " + interval); //$NON-NLS-1$ //$NON-NLS-2$ // set the NORMAL interval normalInterval = interval; ValueChangeEvent.fire(this, String.valueOf(getRefreshRate())); }

Target:
public void setRefreshRate(int interval) { if (getRefreshRate() == interval) { return; } reset(); logger.fine("GridTimer[" + name + "]: Refresh Rate set to: " + interval); //$NON-NLS-1$ //$NON-NLS-2$ // set the NORMAL interval normalInterval = interval; ValueChangeEvent.fire(this, getRefreshRate()); }
Source:
public void testDoGet_NotFound_MissingFile() throws IOException, ServletException { final IConfigUtilsInterface configUtils = Mockito.mock(IConfigUtilsInterface.class); Config.setConfigUtils(configUtils); // The file should not exist, and thus return a 404. testServlet.doGet(mockRequest, mockResponse); verify(mockResponse).sendError(HttpServletResponse.SC_NOT_FOUND); }

Target:
public void testDoGet_NotFound_MissingFile() throws IOException, ServletException { // The file should not exist, and thus return a 404. testServlet.doGet(mockRequest, mockResponse); verify(mockResponse).sendError(HttpServletResponse.SC_NOT_FOUND); }
Source:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Locate the requested file: File file = ServletUtils.makeFileFromSanePath(request.getPathInfo(), base); file = checkForIndex(request, response, file, request.getPathInfo()); // Send the content of the file: // type is the default MIME type of the Servlet. ServletUtils.sendFile(request, response, file, type, cache, file == base && required); }

Target:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Locate the requested file: File file = ServletUtils.makeFileFromSanePath(request.getPathInfo(), base); file = checkForIndex(request, response, file, request.getPathInfo()); // Send the content of the file: // type is the default MIME type of the Servlet. ServletUtils.sendFile(request, response, file, type, cache, required); }
Source:
void onWindowFocusChange(boolean inFocus) { GridTimer modelTimer = getModelTimer(); // Change refresh rate only when the model timer is currently active and not paused if (modelTimer.isActive() && !modelTimer.isPaused()) { if (inFocus) { modelTimer.stop(); modelTimer.setRefreshRate(readRefreshRate()); } else { modelTimer.stop(); modelTimer.setRefreshRate(OUT_OF_FOCUS_REFRESH_RATE); } modelTimer.start(); } }

Target:
void onWindowFocusChange(boolean inFocus) { GridTimer modelTimer = getModelTimer(); // Change refresh rate only when the model timer is currently active and not paused if (modelTimer.isActive() && !modelTimer.isPaused()) { modelTimer.stop(); if (inFocus) { modelTimer.setRefreshRate(readRefreshRate()); } else { modelTimer.setRefreshRate(OUT_OF_FOCUS_REFRESH_RATE); } modelTimer.start(); } }
Source:
public void setComment(String value) { if (value == null) { this.comment = ""; } else { this.comment = value; } }

Target:
public void setComment(String value) { this.comment = (value == null) ? "" : value; }
Source:
protected void updateOriginalTemplate(VmStatic vmStatic) { vmStatic.setOriginalTemplateGuid(getParameters().getVmStaticData().getOriginalTemplateGuid()); vmStatic.setOriginalTemplateName(getParameters().getVmStaticData().getOriginalTemplateName()); }

Target:
protected void updateOriginalTemplate(VmStatic vmStatic) { // do not update it - it is already correctly configured from the snapshot }
Source:
static private List<DiskImage> generateDisksList(int size) { List<DiskImage> disksList = new ArrayList<>(); for (int i = 0; i < size; ++i) { DiskImage diskImage = new DiskImage(); diskImage.setImageId(Guid.newGuid()); disksList.add(diskImage); } return disksList; }

Target:
private static List<DiskImage> generateDisksList(int size) { List<DiskImage> disksList = new ArrayList<>(); for (int i = 0; i < size; ++i) { DiskImage diskImage = new DiskImage(); diskImage.setImageId(Guid.newGuid()); disksList.add(diskImage); } return disksList; }
Source:
protected void mockGetAllSnapshots(AddVmFromTemplateCommand<AddVmFromTemplateParameters> command) { doAnswer(new Answer<List<DiskImage>>() { @Override public List<DiskImage> answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); DiskImage arg = (DiskImage) args[0]; List<DiskImage> list = createDiskSnapshot(arg.getId(), 3); return list; } }).when(command).getAllImageSnapshots(any(DiskImage.class)); }

Target:
private void mockGetAllSnapshots(AddVmFromTemplateCommand<AddVmFromTemplateParameters> command) { doAnswer(new Answer<List<DiskImage>>() { @Override public List<DiskImage> answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); DiskImage arg = (DiskImage) args[0]; List<DiskImage> list = createDiskSnapshot(arg.getId(), 3); return list; } }).when(command).getAllImageSnapshots(any(DiskImage.class)); }
Source:
public void testInitCanBeCalledTwice() throws Exception { MacPoolPerDc pool = new MacPoolPerDc(); pool.initialize(); Mockito.verify(dbFacadeMock).getMacPoolDao(); Mockito.verify(macPoolDaoMock).getAll(); Mockito.verifyNoMoreInteractions(storagePoolDaoMock, vmNicDaoMock, macPoolDaoMock, dbFacadeMock); pool.initialize(); //should not fail. }

Target:
public void testInitCanBeCalledTwice() throws Exception { MacPoolPerDc pool = new MacPoolPerDc(); pool.initialize(); Mockito.verify(dbFacadeMock).getMacPoolDao(); Mockito.verify(macPoolDaoMock).getAll(); pool.initialize(); Mockito.verifyNoMoreInteractions(storagePoolDaoMock, vmNicDaoMock, macPoolDaoMock, dbFacadeMock); }
Source:
public void setMainTabSelectedItem(VDS selectedItem) { // TODO(vszocs) possible performance optimization: don't create HostInterfaceForm upon each selection hostInterfaceForm = new HostInterfaceForm(getDetailModel()); contentPanel.remove(contentPanel.getWidgetCount() - 1); contentPanel.add(hostInterfaceForm); contentPanel.getParent().getElement().getStyle().setOverflowX(Overflow.AUTO); }

Target:
public void setMainTabSelectedItem(VDS selectedItem) { // TODO(vszocs) possible performance optimization: don't create HostInterfaceForm upon each selection hostInterfaceForm = new HostInterfaceForm(getDetailModel()); contentPanel.remove(contentPanel.getWidgetCount() - 1); contentPanel.add(hostInterfaceForm); if (contentPanel.getParent() != null) { contentPanel.getParent().getElement().getStyle().setOverflowX(Overflow.AUTO); } }
Source:
protected void executeCommand() { // add user session setActionReturnValue(getCurrentUser()); getReturnValue().setLoginResult(LoginResult.Autheticated); getReturnValue().setSessionId(engineSessionId); // Permissions for this user might been changed since last login so // update his isAdmin flag accordingly updateUserData(); ApplicationMode appMode = ApplicationMode.from(Config.<Integer> getValue(ConfigValues.ApplicationMode)); SessionDataContainer.getInstance().setData("app_mode", appMode); setSucceeded(true); }

Target:
protected void executeCommand() { setActionReturnValue(getCurrentUser()); getReturnValue().setLoginResult(LoginResult.Autheticated); getReturnValue().setSessionId(engineSessionId); // Permissions for this user might been changed since last login so // update his isAdmin flag accordingly updateUserData(); setSucceeded(true); }
Source:
public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain chain) throws IOException, ServletException { // If there are no authentication profiles supporting negotiation then we don't do anything, as there is no // authentication to perform: findNegotiatingProfiles(req); if (!profiles.isEmpty()) { // Perform the authentication: doAuth((HttpServletRequest) req, (HttpServletResponse) rsp, chain); } chain.doFilter(req, rsp); }

Target:
public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain chain) throws IOException, ServletException { // If there are no authentication profiles supporting negotiation then we don't do anything, as there is no // authentication to perform: findNegotiatingProfiles(req); if (!profiles.isEmpty()) { // Perform the authentication: doAuth((HttpServletRequest) req, (HttpServletResponse) rsp, chain); } else { chain.doFilter(req, rsp); } }
Source:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(false); if ((req.getHeader("Authorization") != null)) { // No need to pass credentials again - if passed, login should be called if (session != null) { session.invalidate(); session = null; } } chain.doFilter(request, response); }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; if ((req.getHeader("Authorization") != null)) { // No need to pass credentials again - if passed, login should be called HttpSession session = req.getSession(false); if (session != null) { session.invalidate(); session = null; } } chain.doFilter(request, response); }
Source:
public boolean equalValues(QosBase other) { // no extra values return true; }

Target:
public boolean equalValues(QosBase other) { // no extra values, should be called for the derivative classes. return false; }
Source:
protected void updateDiskProfile(DiskImage diskImage) { if (isDiskImage()) { DiskImage oldDisk = (DiskImage) getOldDisk(); if (!Objects.equals(oldDisk.getDiskProfileId(), diskImage.getDiskProfileId())) { getImageStorageDomainMapDao().updateDiskProfileByImageGroupId(diskImage.getId(), diskImage.getStorageIds().get(0), diskImage.getDiskProfileIds().get(0)); } } }

Target:
protected void updateDiskProfile(DiskImage diskImage) { if (isDiskImage()) { DiskImage oldDisk = (DiskImage) getOldDisk(); if (!Objects.equals(oldDisk.getDiskProfileId(), diskImage.getDiskProfileId())) { getImageStorageDomainMapDao().updateDiskProfileByImageGroupId(diskImage.getId(), diskImage.getStorageIds().get(0), diskImage.getDiskProfileId()); } } }
Source:
public void testChangeDiskProfileForDisk() { // fetch image image_storage_domain_map image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // test that the current disk profile doesn't equal with the new disk profile assertThat("Same source and dest disk profile id, cannot perform test", image_storage_domain_map.getDiskProfileId(), not(equalTo(Guid.newGuid()))); // change to newDiskProfileId dao.updateDiskProfileByImageGroupId(EXISTING_DISK_ID, EXISTING_DOMAIN_ID, FixturesTool.DISK_PROFILE_2); // fetch the image again image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // check that the new disk profile is the inserted one assertEquals("disk profile wasn't changed", image_storage_domain_map.getDiskProfileId(), FixturesTool.DISK_PROFILE_2); }

Target:
public void testChangeDiskProfileForDisk() { // fetch image image_storage_domain_map image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // test that the current disk profile doesn't equal with the new disk profile assertThat("Same source and dest disk profile id, cannot perform test", image_storage_domain_map.getDiskProfileId(), not(equalTo(FixturesTool.DISK_PROFILE_2))); // change to newDiskProfileId dao.updateDiskProfileByImageGroupId(EXISTING_DISK_ID, EXISTING_DOMAIN_ID, FixturesTool.DISK_PROFILE_2); // fetch the image again image_storage_domain_map = dao.getAllByImageId(EXISTING_IMAGE_ID).get(0); // check that the new disk profile is the inserted one assertEquals("disk profile wasn't changed", image_storage_domain_map.getDiskProfileId(), FixturesTool.DISK_PROFILE_2); }
Source:
protected void addCommands() { UICommand tempVar2 = new UICommand("OnSave", this); //$NON-NLS-1$ tempVar2.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar2.setIsDefault(true); getCommands().add(tempVar2); UICommand tempVar3 = new UICommand("Cancel", this); //$NON-NLS-1$ tempVar3.setTitle(ConstantsManager.getInstance().getConstants().cancel()); tempVar3.setIsCancel(true); getCommands().add(tempVar3); }

Target:
protected void addCommands() { getCommands().add(new UICommand("OnSave", this).setTitle(ConstantsManager.getInstance().getConstants().ok()) //$NON-NLS-1$ .setIsDefault(true)); getCommands().add(new UICommand("Cancel", this).setTitle(ConstantsManager.getInstance().getConstants().cancel()) //$NON-NLS-1$ .setIsCancel(true)); }
Source:
static String getResourceBundleName() { return "bundles/AuditLogMessages"; }

Target:
private static String getResourceBundleName() { return "bundles/AuditLogMessages"; }
Source:
protected ImportVmParameters createParametersWhenImagesExistOnTargetStorageDomain() { ImportVmParameters params = new ImportVmParameters(); params.setContainerId(vmId); params.setStorageDomainId(storageDomainId); params.setVdsGroupId(clusterId); params.setImagesExistOnTargetStorageDomain(true); return params; }

Target:
private static ImportVmParameters createParametersWhenImagesExistOnTargetStorageDomain() { ImportVmParameters params = new ImportVmParameters(); params.setContainerId(vmId); params.setStorageDomainId(storageDomainId); params.setVdsGroupId(clusterId); params.setImagesExistOnTargetStorageDomain(true); return params; }
Source:
protected void executeQueryCommand() { // Get the list of authentication profile names: List<ExtensionProxy> extensions = getExtensionsManager().getExtensionsByService(Authz.class.getName()); List<String> names = new ArrayList<>(extensions.size()); for (ExtensionProxy extension : extensions) { names.add(AuthzUtils.getName(extension)); } if (getParameters().getFilterInternalDomain()) { names.remove(INTERNAL); } sort(names); // Return the sorted list: getQueryReturnValue().setReturnValue(names); }

Target:
protected void executeQueryCommand() { // Get the list of authentication profile names: List<ExtensionProxy> extensions = getExtensionsManager().getExtensionsByService(Authz.class.getName()); List<String> names = new ArrayList<>(extensions.size()); for (ExtensionProxy extension : extensions) { names.add(AuthzUtils.getName(extension)); } sort(names); // Return the sorted list: getQueryReturnValue().setReturnValue(names); }
Source:
protected void findGroups(String searchString, AsyncQuery query) { Frontend.getInstance() .runQuery(VdcQueryType.Search, new DirectorySearchParameters("ADGROUP@" + ((ProfileEntry) getProfile().getSelectedItem()).getAuthz() + ": " + searchString, SearchType.DirectoryGroup, (String) getNamespace().getSelectedItem()), query); //$NON-NLS-1$ //$NON-NLS-2$ }

Target:
protected void findGroups(String searchString, AsyncQuery query) { Frontend.getInstance() .runQuery(VdcQueryType.Search, new DirectorySearchParameters("ADGROUP@" + ((ProfileEntry) getProfile().getSelectedItem()).getAuthz() + ": " + searchString, SearchType.DirectoryGroup, getNamespace().getSelectedItem()), query); //$NON-NLS-1$ //$NON-NLS-2$ }
Source:
public List getEmulatedMachinesList() { // List resultList = lst(); List resultList = lst(); resultList.add("vdsmfake"); resultList.add("host25-rack06.scale.openstack.engineering.redhat.com"); resultList.add("pc-0.12"); resultList.add("pc-0.13"); resultList.add("pc-0.14"); resultList.add("pc-0.15"); resultList.add("pc-1.0"); resultList.add("pc-1.0"); resultList.add("rhel6.4.0"); resultList.add("pc"); resultList.add("isapc"); return resultList; }

Target:
public List getEmulatedMachinesList() { // List resultList = lst(); List resultList = lst(); resultList.add("vdsmfake"); resultList.add("pc-0.12"); resultList.add("pc-0.13"); resultList.add("pc-0.14"); resultList.add("pc-0.15"); resultList.add("pc-1.0"); resultList.add("pc-1.0"); resultList.add("rhel6.4.0"); resultList.add("pc"); resultList.add("isapc"); return resultList; }
Source:
public void onLogout() { AsyncQuery query = new AsyncQuery(); query.setHandleFailure(true); query.setModel(this); query.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { Window.Location.reload(); } }; frontend.logoffAsync(frontend.getLoggedInUser(), query); }

Target:
public void onLogout() { AsyncQuery query = new AsyncQuery(); query.setHandleFailure(true); query.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { // Reload entire application after the user has logged out successfully on backend. Window.Location.reload(); } }; frontend.logoffAsync(frontend.getLoggedInUser(), query); }
Source:
private String generateTokenValueResponse() { byte[] tokenBytes; HttpSession session = getThreadLocalRequest().getSession(); synchronized (session) { if (session.getAttribute(XSRF_TOKEN) == null) { tokenBytes = new byte[TOKEN_SIZE]; //nextBytes is thread safe. random.nextBytes(tokenBytes); session.setAttribute(XSRF_TOKEN, tokenBytes); } else { tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN); } } return StringUtils.toHexString(tokenBytes); }

Target:
private String generateTokenValueResponse() { byte[] tokenBytes; HttpSession session = getThreadLocalRequest().getSession(); synchronized (session) { tokenBytes = (byte[]) session.getAttribute(XSRF_TOKEN); if (session.getAttribute(XSRF_TOKEN) == null) { tokenBytes = new byte[TOKEN_SIZE]; //nextBytes is thread safe. random.nextBytes(tokenBytes); session.setAttribute(XSRF_TOKEN, tokenBytes); } } return StringUtils.toHexString(tokenBytes); }
Source:
boolean isBalloonEnabled() { Boolean balloonEnabled = getParameters().isBalloonEnabled(); return balloonEnabled != null ? balloonEnabled : VmDeviceUtils.isBalloonEnabled(getVmId()); }

Target:
protected boolean isBalloonEnabled() { Boolean balloonEnabled = getParameters().isBalloonEnabled(); return balloonEnabled != null ? balloonEnabled : VmDeviceUtils.isBalloonEnabled(getVmId()); }
Source:
public ValidationResult validate(Object value) { assert value instanceof String; String cidr = (String) value; ValidationResult result = new ValidationResult(); if (!CidrValidator.isCidrFormatValid(cidr)) { return failWith(result, getThisFieldMustContainCidrInFormatMsg()); } else if (!CidrValidator.isCidrNetworkAddressValid(cidr)) { return failWith(result, getCidrNotNetworkAddress()); } else { result.setSuccess(true); return result; } }

Target:
public ValidationResult validate(Object value) { //This validation must be applied to a String assert value==null ||value instanceof String; String cidr = (String) value; ValidationResult result = new ValidationResult(); result.setSuccess(true); if (!CidrValidator.isCidrFormatValid(cidr)) { failWith(result, getThisFieldMustContainCidrInFormatMsg()); } else if (!CidrValidator.isCidrNetworkAddressValid(cidr)) { failWith(result, getCidrNotNetworkAddress()); } return result; }