auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private PreparedStatement insertSessionStatement(Session session) throws SQLException { PreparedStatement insertStatement = connection.prepareStatement("insert into " + tableName + " values(?,?)"); insertStatement.setString(1, sessionUri(session.getId()) + separator + session.getUri().toString()); insertStatement.setString(2, JSON.toJson(session.getCapabilities())); return insertStatement; }

Target:
private PreparedStatement insertSessionStatement(Session session) throws SQLException { PreparedStatement insertStatement = connection.prepareStatement(String.format("insert into %1$s (%2$s, %3$s, %4$s) values (?, ?, ?)", TABLE_NAME, SESSION_ID_COL, SESSION_URI_COL, SESSION_CAPS_COL)); insertStatement.setString(1, session.getId().toString()); insertStatement.setString(2, session.getUri().toString()); insertStatement.setString(3, JSON.toJson(session.getCapabilities())); return insertStatement; }
Source:
public void connect() { if (connected_ || connecting_) return; connecting_ = true; setNewTerminal(getHandle() == null); server_.startTerminal(80, 25, getHandle(), getTitle(), getSequence(), new ServerRequestCallback<ConsoleProcess>() { @Override public void onResponseReceived(ConsoleProcess consoleProcess) { consoleProcess_ = consoleProcess; if (getInteractionMode() != ConsoleProcessInfo.INTERACTION_ALWAYS) { writeError("Unsupported ConsoleProcess interaction mode"); disconnect(); return; } if (consoleProcess_ != null) { addHandlerRegistration(consoleProcess_.addConsoleOutputHandler(TerminalSession.this)); addHandlerRegistration(consoleProcess_.addProcessExitHandler(TerminalSession.this)); addHandlerRegistration(addResizeTerminalHandler(TerminalSession.this)); addHandlerRegistration(addTerminalTitleHandler(TerminalSession.this)); addHandlerRegistration(eventBus_.addHandler(SessionSerializationEvent.TYPE, TerminalSession.this)); if (terminalInputHandler_ == null) terminalInputHandler_ = addTerminalDataInputHandler(TerminalSession.this); consoleProcess.start(new ServerRequestCallback<Void>() { @Override public void onResponseReceived(Void response) { connected_ = true; connecting_ = false; flushQueuedInput(); eventBus_.fireEvent(new TerminalSessionStartedEvent(TerminalSession.this)); } @Override public void onError(ServerError error) { disconnect(); writeError(error.getUserMessage()); } }); } } @Override public void onError(ServerError error) { disconnect(); writeError(error.getUserMessage()); } }); }

Target:
public void connect() { if (connected_ || connecting_) return; connecting_ = true; setNewTerminal(getHandle() == null); server_.startTerminal(80, 25, getHandle(), getTitle(), getSequence(), new ServerRequestCallback<ConsoleProcess>() { @Override public void onResponseReceived(ConsoleProcess consoleProcess) { consoleProcess_ = consoleProcess; if (consoleProcess_ == null) { writeError("No ConsoleProcess received from server"); disconnect(); return; } if (getInteractionMode() != ConsoleProcessInfo.INTERACTION_ALWAYS) { writeError("Unsupported ConsoleProcess interaction mode"); disconnect(); return; } addHandlerRegistration(consoleProcess_.addConsoleOutputHandler(TerminalSession.this)); addHandlerRegistration(consoleProcess_.addProcessExitHandler(TerminalSession.this)); addHandlerRegistration(addResizeTerminalHandler(TerminalSession.this)); addHandlerRegistration(addTerminalTitleHandler(TerminalSession.this)); addHandlerRegistration(eventBus_.addHandler(SessionSerializationEvent.TYPE, TerminalSession.this)); if (terminalInputHandler_ == null) terminalInputHandler_ = addTerminalDataInputHandler(TerminalSession.this); consoleProcess.start(new ServerRequestCallback<Void>() { @Override public void onResponseReceived(Void response) { connected_ = true; connecting_ = false; flushQueuedInput(); eventBus_.fireEvent(new TerminalSessionStartedEvent(TerminalSession.this)); } @Override public void onError(ServerError error) { disconnect(); writeError(error.getUserMessage()); } }); } @Override public void onError(ServerError error) { disconnect(); writeError(error.getUserMessage()); } }); }
Source:
public int getWidth() { return recipeWidth; }

Target:
public int getWidth() { return this.recipeWidth; }
Source:
private boolean isSamePrefix(String a, String b) { int as = a.lastIndexOf('/'); int bs = b.lastIndexOf('/'); return a.substring(0, as + 1).equals(b.substring(0, bs + 1)); }

Target:
private static boolean isSamePrefix(String a, String b) { int as = a.lastIndexOf('/'); int bs = b.lastIndexOf('/'); return a.substring(0, as + 1).equals(b.substring(0, bs + 1)); }
Source:
public void TestDate() { ColumnDef d = build("date", true); assertThat(d, instanceOf(DateColumnDef.class)); assertTrue(d.matchesMysqlType(MySQLConstants.TYPE_DATE)); Date date = new GregorianCalendar(1979, 10, 1).getTime(); assertThat(d.toSQL(date), is("''1979-11-01''")); }

Target:
public void TestDate() { ColumnDef d = build("date", true); assertThat(d, instanceOf(DateColumnDef.class)); assertTrue(d.matchesMysqlType(MySQLConstants.TYPE_DATE)); Date date = new GregorianCalendar(1979, 10, 1).getTime(); assertThat(d.toSQL(date), is("'1979-11-01'")); }
Source:
private synchronized void loadImpl(Properties props, File confFile) { ExtensionEntry entry = new ExtensionEntry(props, confFile); ExtensionEntry alreadyLoadedEntry = loadedEntries.get(entry.getName()); if (alreadyLoadedEntry != null) { throw new ConfigurationException(String.format( "Could not load the configuration '%1$s' from file %2$s. A configuration with the same name was already loaded from file %3$s", entry.getName(), getFileName(entry.file), getFileName(alreadyLoadedEntry.file)) ); } loadedEntries.put(entry.getName(), entry); boolean enabled = EngineLocalConfig.getInstance().getBoolean(ENGINE_EXTENSION_ENABLED + entry.getName(), entry.enabled); if (enabled && entry.extension == null) { try { entry.extension = (Extension) lookupService( Extension.class, entry.getConfig().getProperty(CLASS), entry.getConfig().getProperty(MODULE) ).newInstance(); entry.extension.setContext(entry.context); entry.extension.init(); entry.activated = true; activatedEntries.put(entry.getName(), entry); for (String provides : entry.getProvides()) { MultiValueMapUtils.addToMap(provides, entry, providesEntries); } } catch (Exception ex) { log.error( String.format( "Error in activating extension %1$s. Exception message is %2$s", entry.getName(), ex.getMessage() ) ); if (log.isDebugEnabled()) { log.error("", ex); } } } }

Target:
private synchronized void loadImpl(Properties props, File confFile) { ExtensionEntry entry = new ExtensionEntry(props, confFile); ExtensionEntry alreadyLoadedEntry = loadedEntries.get(entry.getName()); if (alreadyLoadedEntry != null) { throw new ConfigurationException(String.format( "Could not load the configuration '%1$s' from file %2$s. A configuration with the same name was already loaded from file %3$s", entry.getName(), getFileName(entry.file), getFileName(alreadyLoadedEntry.file)) ); } loadedEntries.put(entry.getName(), entry); boolean enabled = EngineLocalConfig.getInstance().getBoolean(ENGINE_EXTENSION_ENABLED + entry.getName(), entry.enabled); if (enabled && entry.extension == null) { try { entry.extension = (Extension) lookupService( Extension.class, entry.getConfig().getProperty(CLASS), entry.getConfig().getProperty(MODULE) ).newInstance(); entry.extension.setContext(entry.context); entry.extension.init(); entry.activated = true; for (String provides : entry.getProvides()) { MultiValueMapUtils.addToMap(provides, entry, providesEntries); } } catch (Exception ex) { log.error( String.format( "Error in activating extension %1$s. Exception message is %2$s", entry.getName(), ex.getMessage() ) ); if (log.isDebugEnabled()) { log.error("", ex); } } } }
Source:
public CommitCommand commit() { return (new CommitCommand(this)); }

Target:
public CommitCommand commit() { return new CommitCommand(this); }
Source:
public void placeNewOrder(Market m, String symbol, int volume, double price, OrderType orderType) throws StockMarketExpection { Stock stock = m.getStockForSymbol(symbol); if (stock != null){ for (int i = 0; i < ordersPlaced.size(); i++) { if (ordersPlaced.get(i).getStockSymbol() == symbol){ throw new StockMarketExpection("Cannot place multiple orders for the same Stock: " + symbol); } } if (orderType.equals(OrderType.BUY)) { if (stock.getPrice() * volume > cashInHand) { throw new StockMarketExpection("Cannot place order for stock: " + symbol + " since there is not enough money. Trader: " + name); } BuyOrder order = new BuyOrder(symbol, volume, price, this); this.ordersPlaced.add(order); m.addOrder(order); } else { Order tmpOrder = null; for (int i = 0; i < position.size(); i++) { if (position.get(i).getStockSymbol() == symbol){ tmpOrder = position.get(i); } } if (!OrderUtility.owns(position, symbol)) { throw new StockMarketExpection("Cannot sell stock you do not own. Stock: " + symbol); } else if (tmpOrder.getSize() < volume) { throw new StockMarketExpection("Cannot sell more stock than you own. Stock: " + symbol + "Owned: " + volume); } else { SellOrder order = new SellOrder(symbol, volume, price, this); this.ordersPlaced.add(order); m.addOrder(order); } } } }

Target:
public void placeNewOrder(Market m, String symbol, int volume, double price, OrderType orderType) throws StockMarketExpection { Stock stock = m.getStockForSymbol(symbol); if (stock != null){ for (int i = 0; i < ordersPlaced.size(); i++) { if (ordersPlaced.get(i).getStockSymbol() == symbol){ throw new StockMarketExpection("Cannot place multiple orders for the same Stock: " + symbol); } } if (orderType.equals(OrderType.BUY)) { if (stock.getPrice() * volume > cashInHand) { throw new StockMarketExpection("Cannot place order for stock: " + symbol + " since there is not enough money. Trader: " + name); } BuyOrder order = new BuyOrder(symbol, volume, price, this); this.ordersPlaced.add(order); m.addOrder(order); } else { Order tmpOrder = null; for (int i = 0; i < position.size(); i++) { if (position.get(i).getStockSymbol() == symbol){ tmpOrder = position.get(i); } } if (!OrderUtility.owns(position, symbol)) { throw new StockMarketExpection("Cannot sell stock you do not own. Stock: " + symbol); } else if (tmpOrder.getSize() < volume) { throw new StockMarketExpection("Cannot sell more stock than you own. Stock: " + symbol + "Owned: " + volume); } else { SellOrder order = new SellOrder(symbol, volume, price, this); this.ordersPlaced.add(order); m.addOrder(order); } } } else { throw new StockMarketExpection("Invalid Stock: " + symbol); } }
Source:
private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) { boolean connectSucceeded = true; for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) { StorageType connectionsType = connectionToType.getKey(); List<StorageServerConnections> connections = connectionToType.getValue(); connectSucceeded = connectSucceeded && connectStorageServersByType(connectionsType, connections); } log.infoFormat("Host {0} storage connection was {1} ", getVds().getName(), connectSucceeded ? "succeeded" : "failed"); return connectSucceeded; }

Target:
private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) { boolean connectSucceeded = true; for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) { StorageType connectionsType = connectionToType.getKey(); List<StorageServerConnections> connections = connectionToType.getValue(); connectSucceeded = connectStorageServersByType(connectionsType, connections) && connectSucceeded; } log.infoFormat("Host {0} storage connection was {1} ", getVds().getName(), connectSucceeded ? "succeeded" : "failed"); return connectSucceeded; }
Source:
public static Color getPillColorByAccountRegistrationOrder(final int orderIndex){ final ArrayList<Color> pillColors = new ArrayList<>(); pillColors.add(new Color(0xFE, 0x00, 0x00)); pillColors.add(new Color(0x00, 0x00, 0xFE)); pillColors.add(new Color(0x00, 0xFE, 0xFE)); pillColors.add(new Color(0xFE, 0xFE, 0x00)); return pillColors.get(orderIndex % pillColors.size()); }

Target:
public static Color getPillColorByAccountRegistrationOrder(final int orderIndex){ final ArrayList<Color> pillColors = new ArrayList<>(); pillColors.add(new Color(0x00, 0x00, 0xFE)); pillColors.add(new Color(0xFE, 0x00, 0x00)); pillColors.add(new Color(0x00, 0xFE, 0xFE)); pillColors.add(new Color(0xFE, 0xFE, 0x00)); return pillColors.get(orderIndex % pillColors.size()); }
Source:
private Object serializeResultToString(final ResponseMessage msg) { if (msg.getResult() == null) return "null"; if (msg.getResult().getData() == null) return "null"; final Object o = msg.getResult().getData(); if (o instanceof Collection) { return ((Collection) o).stream().map(d -> null == d ? "null" : d.toString()).collect(Collectors.toList()); } else if (o instanceof byte[]) { return o; } else { return o.toString(); } }

Target:
private Object serializeResultToString(final ResponseMessage msg) { if (msg.getResult() == null) return "null"; if (msg.getResult().getData() == null) return "null"; final Object o = msg.getResult().getData(); if (o instanceof Collection) { return ((Collection) o).stream().map(d -> null == d ? "null" : d.toString()).collect(Collectors.toList()); } else { return o.toString(); } }
Source:
public View getView(int position, View convertView, ViewGroup parent) { if(actionEnabled && position == actionPosition) { MenuGridEntryView tiav =(MenuGridEntryView)convertView; if(tiav == null) { tiav = new MenuGridEntryView(context); } tiav.setDisplay(detail.getCustomAction().getDisplay()); tiav.setBackgroundResource(R.drawable.list_bottom_tab); int padding = (int) context.getResources().getDimension(R.dimen.entity_padding); tiav.setPadding(padding, padding, padding, padding); return tiav; } Entity<TreeReference> entity = current.get(position); if(usesGridView){ GridEntityView emv =(GridEntityView)convertView; if(emv == null) { emv = new GridEntityView(context, detail, entity, currentSearchTerms, mImageLoader, controller); } else{ emv.setViews(context, detail, entity); } return emv; } else{ EntityView emv =(EntityView)convertView; if (emv == null) { emv = new EntityView(context, detail, entity, tts, currentSearchTerms, controller, position, mFuzzySearchEnabled); } else { emv.setSearchTerms(currentSearchTerms); emv.refreshViewsForNewEntity(entity, entity.getElement().equals(selected), position); } return emv; } }

Target:
public View getView(int position, View convertView, ViewGroup parent) { if(actionEnabled && position == actionPosition) { HorizontalMediaView tiav =(HorizontalMediaView)convertView; if(tiav == null) { tiav = new HorizontalMediaView(context); } tiav.setDisplay(detail.getCustomAction().getDisplay()); tiav.setBackgroundResource(R.drawable.list_bottom_tab); int padding = (int) context.getResources().getDimension(R.dimen.entity_padding); tiav.setPadding(padding, padding, padding, padding); return tiav; } Entity<TreeReference> entity = current.get(position); if(usesGridView){ GridEntityView emv =(GridEntityView)convertView; if(emv == null) { emv = new GridEntityView(context, detail, entity, currentSearchTerms, mImageLoader, controller, mFuzzySearchEnabled); } else{ emv.setSearchTerms(currentSearchTerms); emv.setViews(context, detail, entity); } return emv; } else{ EntityView emv =(EntityView)convertView; if (emv == null) { emv = new EntityView(context, detail, entity, tts, currentSearchTerms, controller, position, mFuzzySearchEnabled); } else { emv.setSearchTerms(currentSearchTerms); emv.refreshViewsForNewEntity(entity, entity.getElement().equals(selected), position); } return emv; } }
Source:
private static void cacheColors(Display display) { BG_COLOR_RGB= JFaceColors.getInformationViewerBackgroundColor(display).getRGB(); FG_COLOR_RGB= JFaceColors.getInformationViewerForegroundColor(display).getRGB(); Color hyperlinkText= JFaceColors.getHyperlinkText(display); Color activeHyperlinkText= JFaceColors.getActiveHyperlinkText(display); if (hyperlinkText != null) { LINK_COLOR_RGB= hyperlinkText.getRGB(); } if (activeHyperlinkText != null) { ACTIVE_LINK_COLOR_RGB= activeHyperlinkText.getRGB(); } }

Target:
private static void cacheColors(Display display) { BG_COLOR_RGB= JFaceColors.getInformationViewerBackgroundColor(display).getRGB(); FG_COLOR_RGB= JFaceColors.getInformationViewerForegroundColor(display).getRGB(); Color hyperlinkText= JFaceColors.getHyperlinkText(display); if (hyperlinkText != null) { LINK_COLOR_RGB= hyperlinkText.getRGB(); } Color activeHyperlinkText= JFaceColors.getActiveHyperlinkText(display); if (activeHyperlinkText != null) { ACTIVE_LINK_COLOR_RGB= activeHyperlinkText.getRGB(); } }
Source:
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IWorkbenchPage activePage = window.getActivePage(); ISelection selection = activePage.getSelection(); IFile iFile = getSysMLIFileFromWorkspace(selection); File baseSysMLModelFile = iFile.getRawLocation().makeAbsolute().toFile(); FileDialog dlg = new FileDialog(window.getShell(), SWT.SINGLE); dlg.setFilterExtensions(new String[] { "*.uml"}); IPath path = new Path(dlg.open()); File externalSysMLModelFile = path.toFile(); if (baseSysMLModelFile.canRead() && externalSysMLModelFile.canRead()) { PlasticReImport pri = new PlasticReImport(); boolean success = pri.reImport(externalSysMLModelFile, baseSysMLModelFile,window, I_RI.DELETE_FROM_BASE); if (success) {MessageDialog.openInformation(window.getShell(), I_RI.TOOL_TITLE, I_RI.TOOL_SUCCESS +externalSysMLModelFile+" in \n"+baseSysMLModelFile); } else {MessageDialog.openError(window.getShell(),I_RI.TOOL_TITLE, I_RI.TOOL_FAIL + externalSysMLModelFile+" in \n"+baseSysMLModelFile);} } else { MessageDialog.openError(window.getShell(), I_RI.TOOL_TITLE, "Not Readable files"); } return null; }

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil .getActiveWorkbenchWindowChecked(event); ISelection selection = HandlerUtil.getCurrentSelection(event); IFile iFile = getSysMLIFileFromWorkspace(selection); File baseSysMLModelFile = iFile.getRawLocation().makeAbsolute() .toFile(); FileDialog dlg = new FileDialog(window.getShell(), SWT.SINGLE); dlg.setFilterExtensions(new String[] { "*.uml" }); dlg.setFilterPath(baseSysMLModelFile.getParent()); IPath path = new Path(dlg.open()); File externalSysMLModelFile = path.toFile(); if (baseSysMLModelFile.canRead() && externalSysMLModelFile.canRead()) { PlasticReImport pri = new PlasticReImport(); boolean reImportSuccess = pri.reImport(window, baseSysMLModelFile, externalSysMLModelFile, I_RI.REQ_ID_ATT, null, !I_RI.CHECK_PACKAGE_NAME, I_RI.COPY_All_PROPERTY_VALUES, I_RI.DELETE_FROM_BASE); if (reImportSuccess) { MessageDialog.openInformation(window.getShell(), I_RI.TOOL_TITLE, I_RI.TOOL_SUCCESS); } else { MessageDialog.openError(window.getShell(), I_RI.TOOL_TITLE, I_RI.TOOL_FAIL); } } else { MessageDialog.openError(window.getShell(), I_RI.TOOL_TITLE, I_RI.TOOL_ERR_FILE_READ); } return null; }
Source:
private void dispatchAction(String action) { if(Intent.ACTION_CALL.equals(action) ) { tManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE); Intent call = new Intent(Intent.ACTION_CALL); call.setData(Uri.parse("tel:" + number)); if(call.resolveActivity(getPackageManager()) != null){ startActivity(call); } else { Toast.makeText(getApplicationContext(), Localization.get("callout.failure.dialer"), Toast.LENGTH_SHORT).show(); } } else { Intent sms = new Intent(Intent.ACTION_SENDTO); sms.setData(Uri.parse("smsto:" + number)); if(sms.resolveActivity(getPackageManager()) != null){ startActivityForResult(sms, SMS_RESULT); } else { Toast.makeText(getApplicationContext(), Localization.get("callout.failure.sms"), Toast.LENGTH_SHORT).show(); } } }

Target:
private void dispatchAction(String action) { if(Intent.ACTION_CALL.equals(action) ) { tManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE); Intent call = new Intent(Intent.ACTION_CALL); call.setData(Uri.parse("tel:" + number)); if(call.resolveActivity(getPackageManager()) != null){ startActivity(call); } else { Toast.makeText(this, Localization.get("callout.failure.dialer"), Toast.LENGTH_SHORT).show(); finish(); } } else { Intent sms = new Intent(Intent.ACTION_SENDTO); sms.setData(Uri.parse("smsto:" + number)); if(sms.resolveActivity(getPackageManager()) != null){ startActivityForResult(sms, SMS_RESULT); } else { Toast.makeText(this, Localization.get("callout.failure.sms"), Toast.LENGTH_SHORT).show(); finish(); } } }
Source:
private String getAwsRegion() throws IOException { String region = getEnv("AWS_REGION"); if (region != null) { return region; } AwsCredentialSource awsCredentialSource = (AwsCredentialSource) this.credentialSource; if (awsCredentialSource.regionUrl == null || awsCredentialSource.regionUrl.isEmpty()) { throw new IOException( "Unable to determine the AWS region. The credential source does not contain the region url."); } region = retrieveResource(awsCredentialSource.regionUrl, "region"); return region.substring(0, region.length() - 1); }

Target:
private String getAwsRegion() throws IOException { String region = getEnv("AWS_REGION"); if (region != null) { return region; } AwsCredentialSource awsCredentialSource = (AwsCredentialSource) this.credentialSource; if (awsCredentialSource.regionUrl == null || awsCredentialSource.regionUrl.isEmpty()) { throw new IOException( "Unable to determine the AWS region. The credential source does not contain the region URL."); } region = retrieveResource(awsCredentialSource.regionUrl, "region"); return region.substring(0, region.length() - 1); }
Source:
public GanttDialogPerson(CustomPropertyManager customPropertyManager, TaskManager taskManager, UIFacade uiFacade, HumanResource person) { myCustomPropertyManager = customPropertyManager; myTaskManager = taskManager; myUIFacade = uiFacade; this.person = person; Role[] enabledRoles = RoleManager.Access.getInstance().getEnabledRoles(); String[] roleFieldValues = new String[enabledRoles.length]; for (int i = 0; i < enabledRoles.length; i++) { roleFieldValues[i] = enabledRoles[i].getName(); } myRoleField = new DefaultEnumerationOption<Object>("colRole", roleFieldValues); myGroup = new GPOptionGroup("", new GPOption[]{myNameField, myPhoneField, myMailField, myRoleField}); myGroup.setTitled(false); ((GPAbstractOption)myTotalCostField).setWritable(false); myRateGroup = new GPOptionGroup("resourceRate", new GPOption[] {myStandardRateField, myTotalCostField}); myRate2Group = new GPOptionGroup("resourceRate", new GPOption[] {myStandardRate2Field, myTotalCost2Field}); }

Target:
public GanttDialogPerson(CustomPropertyManager customPropertyManager, TaskManager taskManager, UIFacade uiFacade, HumanResource person) { myCustomPropertyManager = customPropertyManager; myTaskManager = taskManager; myUIFacade = uiFacade; this.person = person; Role[] enabledRoles = RoleManager.Access.getInstance().getEnabledRoles(); String[] roleFieldValues = new String[enabledRoles.length]; for (int i = 0; i < enabledRoles.length; i++) { roleFieldValues[i] = enabledRoles[i].getName(); } myRoleField = new DefaultEnumerationOption<Object>("colRole", roleFieldValues); myGroup = new GPOptionGroup("", new GPOption[]{myNameField, myPhoneField, myMailField, myRoleField}); myGroup.setTitled(false); ((GPAbstractOption)myTotalCostField).setWritable(false); myRateGroup = new GPOptionGroup("resourceRate", new GPOption[] {myStandardRateField, myTotalCostField}); myRate2Group = new GPOptionGroup("resourceRate2", new GPOption[] {myStandardRate2Field, myTotalCost2Field}); }
Source:
protected boolean canDoAction() { VDSGroup cluster = getVdsGroup(); if (!cluster.supportsGlusterService() || !GlusterFeatureSupported.glusterBrickProvisioning(cluster.getCompatibilityVersion())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER); } VdsValidator validator = new VdsValidator(getVds()); if (!validate(validator.isUp())) { return false; } String deviceType; if (getParameters().getDisks().size() == 0) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DEVICE_REQUIRED); return false; } else { deviceType = getParameters().getDisks().get(0).getDevType(); } for (StorageDevice device : getParameters().getDisks()) { if (!ObjectUtils.objectsEqual(deviceType, device.getDevType())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DIFFERENT_STORAGE_DEVICE_TYPES_SELECTED); return false; } if (!device.getCanCreateBrick()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DEVICE_IS_ALREADY_IN_USE); addCanDoActionMessageVariable("storageDevice", device.getName()); return false; } } return true; }

Target:
protected boolean canDoAction() { VDSGroup cluster = getVdsGroup(); if (!cluster.supportsGlusterService() || !GlusterFeatureSupported.glusterBrickProvisioning(cluster.getCompatibilityVersion())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_PROVISIONING_NOT_SUPPORTED_BY_CLUSTER); } VdsValidator validator = new VdsValidator(getVds()); if (!validate(validator.isUp())) { return false; } String deviceType; if (getParameters().getDisks().isEmpty()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DEVICE_REQUIRED); return false; } else { deviceType = getParameters().getDisks().get(0).getDevType(); } for (StorageDevice device : getParameters().getDisks()) { if (!ObjectUtils.objectsEqual(deviceType, device.getDevType())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DIFFERENT_STORAGE_DEVICE_TYPES_SELECTED); return false; } if (!device.getCanCreateBrick()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DEVICE_IS_ALREADY_IN_USE); addCanDoActionMessageVariable("storageDevice", device.getName()); return false; } } return true; }
Source:
public void deleteWorkspaceMaterialFileFieldAnswerFile(WorkspaceMaterialFileFieldAnswerFile fieldAnswerFile) { if (fileAnswerUtils.isFileSystemStorageEnabled()) { Long userEntityId = fieldAnswerFile.getFieldAnswer().getReply().getUserEntityId(); fileAnswerUtils.removeFileFromFileSystem(userEntityId, fieldAnswerFile.getFileId()); } workspaceMaterialFileFieldAnswerFileDAO.delete(fieldAnswerFile); }

Target:
public void deleteWorkspaceMaterialFileFieldAnswerFile(WorkspaceMaterialFileFieldAnswerFile fieldAnswerFile) throws IOException { if (fileAnswerUtils.isFileSystemStorageEnabled()) { Long userEntityId = fieldAnswerFile.getFieldAnswer().getReply().getUserEntityId(); if (fileAnswerUtils.isFileInFileSystem(userEntityId, fieldAnswerFile.getFileId())) { fileAnswerUtils.removeFileFromFileSystem(userEntityId, fieldAnswerFile.getFileId()); } } workspaceMaterialFileFieldAnswerFileDAO.delete(fieldAnswerFile); }
Source:
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { model = (JSLibModel)newInput; try { viewer.refresh(); } catch (Exception e) }

Target:
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { model = (JSLibModel)newInput; if(viewer != null && model != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } }
Source:
public Map<FingerprintIdDetails, Fingerprint> fingerprintFiles(final Collection<File> files, final int threads, final int waitTime, final TimeUnit waitTimeUnit) { final AtomicInteger filesRead = new AtomicInteger(0); final ExecutorService executor = Executors.newFixedThreadPool(threads, new ThreadFactoryBuilder().setDaemon(true).build()); final IntervalList intervals = this.haplotypes.getIntervalList(); final Map<FingerprintIdDetails, Fingerprint> retval = new ConcurrentHashMap<>(); final Map<Future<?>, File> futures = new HashMap<>(files.size()); for (final File f : files) { futures.put(executor.submit(() -> { try { if (CheckFingerprint.isBamOrSamFile(f)) { retval.putAll(fingerprintSamFile(f, intervals)); } else { retval.putAll(fingerprintVcf(f)); } synchronized (log) { log.debug("Processed file: " + f.getAbsolutePath() + " (" + filesRead.get() + ")"); } if (filesRead.incrementAndGet() % 100 == 0) { synchronized (log) { log.info("Processed " + filesRead.get() + " out of " + files.size()); } } } catch(final Exception e) { log.warn("Exception thrown in thread:" + e.getMessage()); throw e; } }), f); } executor.shutdown(); try { executor.awaitTermination(waitTime, waitTimeUnit); } catch (final InterruptedException ie) { log.warn(ie, "Interrupted while waiting for executor to terminate."); } for (final Map.Entry<Future<?>, File> futureFileEntry : futures.entrySet()) { try { futureFileEntry.getKey().get(); } catch (InterruptedException | ExecutionException e) { log.error("Failed to fingerprint on file: " + futureFileEntry.getValue()); throw new RuntimeException(e); } } return retval; }

Target:
public Map<FingerprintIdDetails, Fingerprint> fingerprintFiles(final Collection<File> files, final int threads, final int waitTime, final TimeUnit waitTimeUnit) { final AtomicInteger filesRead = new AtomicInteger(0); final ExecutorService executor = Executors.newFixedThreadPool(threads, new ThreadFactoryBuilder().setDaemon(true).build()); final IntervalList intervals = this.haplotypes.getIntervalList(); final Map<FingerprintIdDetails, Fingerprint> retval = new ConcurrentHashMap<>(); final Map<Future<?>, File> futures = new HashMap<>(files.size()); for (final File f : files) { futures.put(executor.submit(() -> { try { if (CheckFingerprint.isBamOrSamFile(f)) { retval.putAll(fingerprintSamFile(f, intervals)); } else { retval.putAll(fingerprintVcf(f)); } log.debug("Processed file: " + f.getAbsolutePath() + " (" + filesRead.get() + ")"); if (filesRead.incrementAndGet() % 100 == 0) { log.info("Processed " + filesRead.get() + " out of " + files.size()); } } catch (final Exception e) { log.warn("Exception thrown in thread:" + e.getMessage()); throw e; } }), f); } executor.shutdown(); try { executor.awaitTermination(waitTime, waitTimeUnit); } catch (final InterruptedException ie) { log.warn(ie, "Interrupted while waiting for executor to terminate."); } for (final Map.Entry<Future<?>, File> futureFileEntry : futures.entrySet()) { try { futureFileEntry.getKey().get(); } catch (InterruptedException | ExecutionException e) { log.error("Failed to fingerprint on file: " + futureFileEntry.getValue()); throw new RuntimeException(e); } } return retval; }
Source:
public void downloadFile(String uri, File target) { Matcher m = parseURI(uri); if (m.matches()) { try { InputStream s = minioClient.getObject(m.group("bucket"), m.group("path")); FileUtils.copyInputStreamToFile(s, target); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } }

Target:
protected void downloadFile(String uri, File target) { Matcher m = parseURI(uri); if (m.matches()) { try (InputStream s = minioClient.getObject(m.group("bucket"), m.group("path"))) { FileUtils.copyInputStreamToFile(s, target); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } }
Source:
public static void getCPUList(AsyncQuery aQuery, Version version) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { return source != null ? (ArrayList<ServerCpu>) source : new ArrayList<ServerCpu>(); } }; VdcQueryParametersBase params = new VdcQueryParametersBase(); params.addParameter(GenericVdcParameter.Version, version); Frontend.RunQuery(VdcQueryType.GetAllServerCpuList, params, aQuery); }

Target:
public static void getCPUList(AsyncQuery aQuery, Version version) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { return source != null ? (ArrayList<ServerCpu>) source : new ArrayList<ServerCpu>(); } }; Frontend.RunQuery(VdcQueryType.GetAllServerCpuList, new VdcQueryParametersBase().addParameter(GenericVdcParameter.Version, version), aQuery); }
Source:
public static String capitalizeFirstLetter(String text) { if(text == null) return null; if(text.length() == 0) return ""; if(text.length() == 1) return text.toUpperCase(); return text.substring(0, 1).toUpperCase() + text.substring(1); }

Target:
public static String capitalizeFirstLetter(String text) { if(text == null) { return null; } else if(text.length() == 0) { return ""; } else if(text.length() == 1) { return text.toUpperCase(); } return text.substring(0, 1).toUpperCase() + text.substring(1); }
Source:
private void initialize() { initializeFields(); for (String[] element : fSyntaxColorListModel) { fHighlightingColorList.add(new HighlightingColorListItem(element[0], element[1], element[1] + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, element[1] + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); } fHighlightingColorListViewer.setInput(fHighlightingColorList); fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); }

Target:
private void initialize() { initializeFields(); for (String[] colorModel : fSyntaxColorListModel) { fHighlightingColorList.add(new HighlightingColorListItem(colorModel[0], colorModel[1], colorModel[1] + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, colorModel[1] + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); } fHighlightingColorListViewer.setInput(fHighlightingColorList); fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); }
Source:
public AuditLogType getAuditLogTypeValue() { return AuditLogType.VM_SET_TICKET; }

Target:
public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? AuditLogType.VM_SET_TICKET : AuditLogType.VM_SET_TICKET_FAILED; }
Source:
public void complete(CompleteOperation op) { String buffer = op.getBuffer(); List<String> candidates = op.getCompletionCandidates().stream().map(TerminalString::toString).collect(Collectors.toList()); if(buffer.isEmpty()) { for(String name : context.getCommandRegistry().getCommandNames()) { Command command = context.getCommandRegistry().getCommand(name); if(command.isAvailable(context)) { candidates.add(name); } } } else { ProcessedCommand procCmd = new ProcessedCommand(buffer, op.getCursor()); if(!procCmd.isCommandComplete()) { for(String name : context.getCommandRegistry().getCommandNames()) { Command command = context.getCommandRegistry().getCommand(name); if(command.isAvailable(context) && name.startsWith(procCmd.getCommand())) { candidates.add(name); } } } else { Command command = context.getCommandRegistry().getCommand(procCmd.getCommand()); if(command.isAvailable(context)) { op.setOffset(op.getCursor()); for(Argument arg : procCmd.getArguments()) { if(arg.getOffset()<op.getCursor()) { op.setOffset(arg.getOffset()); } else { break; } } addPrefixMatches(procCmd.getCurrentArgument(), command.getOptions(), candidates); command.complete(context, procCmd, candidates); } } } Collections.sort(candidates); op.setCompletionCandidates(candidates); }

Target:
public void complete(CompleteOperation op) { String buffer = op.getBuffer(); if(buffer.isEmpty()) { for(String name : context.getCommandRegistry().getCommandNames()) { Command command = context.getCommandRegistry().getCommand(name); if(command.isAvailable(context)) { op.addCompletionCandidate(name); } } } else { ProcessedCommand procCmd = new ProcessedCommand(buffer, op.getCursor()); if(!procCmd.isCommandComplete()) { for(String name : context.getCommandRegistry().getCommandNames()) { Command command = context.getCommandRegistry().getCommand(name); if(command.isAvailable(context) && name.startsWith(procCmd.getCommand())) { op.addCompletionCandidate(name); } } } else { Command command = context.getCommandRegistry().getCommand(procCmd.getCommand()); if(command.isAvailable(context)) { op.setOffset(op.getCursor()); for(Argument arg : procCmd.getArguments()) { if(arg.getOffset()<op.getCursor()) { op.setOffset(arg.getOffset()); } else { break; } } List<String> candidates = new ArrayList<>(); addPrefixMatches(procCmd.getCurrentArgument(), command.getOptions(), candidates); command.complete(context, procCmd, candidates); op.addCompletionCandidates(candidates); } } } }
Source:
public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException { List<Notification> notifications = event.getNotifications(); DRepresentationDescriptor representationDescriptor = null; Iterator<Notification> notifIterator = notifications.iterator(); while (notifIterator.hasNext() && representationDescriptor == null) { Notification notification = notifIterator.next(); Object notifier = notification.getNotifier(); boolean isRelatedToRepresentation = notifier instanceof DRepresentationElement || notifier instanceof DRepresentation; final DRepresentation representation; if (!isRelatedToRepresentation && notifier instanceof EObject) { representation = getDRepresentation((EObject) notifier); } else { representation = null; } if (isRelatedToRepresentation || representation != null) { RecordingCommand changeIdRecordingCommand = new RecordingCommand(transactionalEditingDomain) { @Override protected void doExecute() { if (notifier instanceof DRepresentationElement) { SiriusHelper.updateChangeId((DRepresentationElement) notifier); } else if (notifier instanceof DRepresentation) { SiriusHelper.updateChangeId((DRepresentation) notifier); } else { SiriusHelper.updateChangeId(representation); } } }; return changeIdRecordingCommand; } } return null; }

Target:
public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException { List<Notification> notifications = event.getNotifications(); notifierWithoutRepresentationDescriptors = new HashSet<>(); Iterator<Notification> notifIterator = notifications.iterator(); while (notifIterator.hasNext()) { Notification notification = notifIterator.next(); Object notifier = notification.getNotifier(); final DRepresentationDescriptor representationDescriptor = getDRepresentationDescriptor((EObject) notifier); if (representationDescriptor != null) { RecordingCommand changeIdRecordingCommand = new RecordingCommand(transactionalEditingDomain) { @Override protected void doExecute() { RepresentationHelper.updateChangeId(representationDescriptor); } }; return changeIdRecordingCommand; } } return null; }
Source:
protected void write(Object o, Encoder encoder) throws IOException { if (o == null || ((Map<String, Serializable>) o).isEmpty()) { encoder.writeIndex(NULL_SCHEMA_INDEX); encoder.writeNull(); } else { encoder.writeIndex(STRING_SCHEMA_INDEX); String mapAsJson = new ObjectMapper().writeValueAsString(o); encoder.writeString(mapAsJson); } }

Target:
protected void write(Object o, Encoder encoder) throws IOException { if (o == null || ((Map<String, Serializable>) o).isEmpty()) { encoder.writeIndex(NULL_SCHEMA_INDEX); encoder.writeNull(); } else { encoder.writeIndex(STRING_SCHEMA_INDEX); String mapAsJson = MAPPER.writeValueAsString(o); encoder.writeString(mapAsJson); } }
Source:
private InternalKeys() { throw new AssertionError("InternalKeys is a constant container. Should not be instantiated"); }

Target:
private InternalKeys() { throw new AssertionError("No instances."); }
Source:
public JobConfig generateConfig(String executionPlanJson) { Map<String, String> configs = new HashMap<>(); configs.put(JobConfig.JOB_NAME(), jobName); List<String> inputs = inEdges.stream().map(edge -> edge.getFormattedSystemStream()).collect(Collectors.toList()); configs.put(TaskConfig.INPUT_STREAMS(), Joiner.on(',').join(inputs)); log.info("Job has generated configs {}", jobName, configs); configs.put(CONFIG_EXECUTION_PLAN, executionPlanJson); String configPrefix = String.format(CONFIG_JOB_PREFIX, jobName); return new JobConfig(Util.rewriteConfig(extractScopedConfig(config, new MapConfig(configs), configPrefix))); }

Target:
public JobConfig generateConfig(String executionPlanJson) { Map<String, String> configs = new HashMap<>(); configs.put(JobConfig.JOB_NAME(), jobName); List<String> inputs = inEdges.stream().map(edge -> edge.getFormattedSystemStream()).collect(Collectors.toList()); configs.put(TaskConfig.INPUT_STREAMS(), Joiner.on(',').join(inputs)); log.info("Job has generated configs {}", jobName, configs); configs.put(CONFIG_INTERNAL_EXECUTION_PLAN, executionPlanJson); String configPrefix = String.format(CONFIG_JOB_PREFIX, jobName); return new JobConfig(Util.rewriteConfig(extractScopedConfig(config, new MapConfig(configs), configPrefix))); }
Source:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { CoordinatorStats stats = new CoordinatorStats(); Set<DataSegment> availableSegments = params.getAvailableSegments(); DruidCluster cluster = params.getDruidCluster(); if (!availableSegments.isEmpty()) { for (NavigableSet<ServerHolder> serverHolders : cluster.getSortedHistoricalsByTier()) { for (ServerHolder serverHolder : serverHolders) { ImmutableDruidServer server = serverHolder.getServer(); for (ImmutableDruidDataSource dataSource : server.getDataSources()) { for (DataSegment segment : dataSource.getSegments()) { if (!availableSegments.contains(segment)) { LoadQueuePeon queuePeon = params.getLoadManagementPeons().get(server.getName()); if (!queuePeon.getSegmentsToDrop().contains(segment)) { queuePeon.dropSegment( segment, new LoadPeonCallback() { @Override public void execute() { } } ); stats.addToTieredStat("unneededCount", server.getTier(), 1); } } } } } } } else { log.info( "Found 0 availableSegments, skipping the cleanup of segments from historicals. This is done to prevent a race condition in which the coordinator would drop all segments if it started running cleanup before it finished polling the metadata storage for available segments for the first time." ); } return params.buildFromExisting() .withCoordinatorStats(stats) .build(); }

Target:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { CoordinatorStats stats = new CoordinatorStats(); Set<DataSegment> availableSegments = params.getAvailableSegments(); DruidCluster cluster = params.getDruidCluster(); if (!availableSegments.isEmpty()) { for (SortedSet<ServerHolder> serverHolders : cluster.getSortedHistoricalsByTier()) { for (ServerHolder serverHolder : serverHolders) { ImmutableDruidServer server = serverHolder.getServer(); for (ImmutableDruidDataSource dataSource : server.getDataSources()) { for (DataSegment segment : dataSource.getSegments()) { if (!availableSegments.contains(segment)) { LoadQueuePeon queuePeon = params.getLoadManagementPeons().get(server.getName()); if (!queuePeon.getSegmentsToDrop().contains(segment)) { queuePeon.dropSegment( segment, new LoadPeonCallback() { @Override public void execute() { } } ); stats.addToTieredStat("unneededCount", server.getTier(), 1); } } } } } } } else { log.info( "Found 0 availableSegments, skipping the cleanup of segments from historicals. This is done to prevent a race condition in which the coordinator would drop all segments if it started running cleanup before it finished polling the metadata storage for available segments for the first time." ); } return params.buildFromExisting() .withCoordinatorStats(stats) .build(); }
Source:
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Constants.INTENT_REQUEST_CODE_SPEECH && resultCode == RESULT_OK) { List<String> results = data.getStringArrayListExtra( RecognizerIntent.EXTRA_RESULTS); String spokenText = results.get(0); getSearchFragment().searchAndUpdateText(spokenText); } else if (requestCode == Constants.INTENT_REQUEST_CODE_CONVERT && resultCode == RESULT_OK) { if (!data.hasExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA)) { super.onActivityResult(requestCode, resultCode, data); return; } final ScratchProgramData projectData = data.getParcelableExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA); final List<ScratchProgramData> projectList = new ArrayList<>(); projectList.add(projectData); convertProjects(projectList); } super.onActivityResult(requestCode, resultCode, data); }

Target:
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Constants.INTENT_REQUEST_CODE_SPEECH && resultCode == RESULT_OK) { String spokenText = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).get(0); getSearchFragment().searchAndUpdateText(spokenText); } else if (requestCode == Constants.INTENT_REQUEST_CODE_CONVERT && resultCode == RESULT_OK) { if (!data.hasExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA)) { super.onActivityResult(requestCode, resultCode, data); return; } final ScratchProgramData projectData = data.getParcelableExtra(Constants.INTENT_SCRATCH_PROGRAM_DATA); final List<ScratchProgramData> projectList = new ArrayList<>(); projectList.add(projectData); convertProjects(projectList); } super.onActivityResult(requestCode, resultCode, data); }
Source:
public int defaultTimeoutSeconds() { return 600000; }

Target:
public int defaultTimeoutSeconds() { return 60; }
Source:
private void pushWhenFinished(Job commitJob) { commitJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { if (event.getResult().getSeverity() == IStatus.ERROR) { return; } RemoteConfig config = SimpleConfigurePushDialog .getConfiguredRemote(repo); if (config == null) { Display.getDefault().syncExec(new Runnable() { public void run() { try { WizardDialog wizardDialog = new WizardDialog(shell, new PushWizard(repo)); wizardDialog.setHelpAvailable(true); wizardDialog.open(); } catch (URISyntaxException e) { Activator.handleError(NLS.bind(UIText.CommitUI_pushFailedMessage, e), e, true); } } }); } else { int timeout = Activator.getDefault().getPreferenceStore() .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT); PushOperationUI op = new PushOperationUI(repo, config.getName(), timeout, false); op.start(); } }}); }

Target:
private void pushWhenFinished(Job commitJob) { commitJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { if (event.getResult().getSeverity() == IStatus.ERROR) return; RemoteConfig config = SimpleConfigurePushDialog .getConfiguredRemote(repo); if (config == null) { Display.getDefault().syncExec(new Runnable() { public void run() { try { WizardDialog wizardDialog = new WizardDialog( shell, new PushWizard(repo)); wizardDialog.setHelpAvailable(true); wizardDialog.open(); } catch (URISyntaxException e) { Activator.handleError(NLS.bind( UIText.CommitUI_pushFailedMessage, e), e, true); } } }); } else { int timeout = Activator.getDefault().getPreferenceStore() .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT); PushOperationUI op = new PushOperationUI(repo, config .getName(), timeout, false); op.start(); } } }); }
Source:
public static boolean matchSubjectDnsName(X509Certificate certificate, String dnsName) { try { final Collection<List<?>> sans = certificate.getSubjectAlternativeNames(); if (sans != null) { for (final List<?> san : sans) { int generalName = (Integer) san.get(0); if (generalName == GeneralName.DNS_NAME.value) { String value = (String) san.get(1); if (dnsNameMatch(value, dnsName)) { return true; } } } } String cn = getPrincipalField(certificate.getSubjectX500Principal(), "CN"); if (dnsNameMatch(cn, dnsName)) { return true; } } catch (CertificateParsingException e) { } return false; }

Target:
public static boolean matchSubjectDnsName(X509Certificate certificate, String dnsName) { try { Collection<List<?>> sans = certificate.getSubjectAlternativeNames(); if (sans != null) { for (List<?> san : sans) { int generalName = (Integer) san.get(0); if (generalName == GeneralName.DNS_NAME.value) { String value = (String) san.get(1); if (dnsNameMatch(value, dnsName)) { return true; } } } } String cn = getPrincipalField(certificate.getSubjectX500Principal(), "CN"); if (dnsNameMatch(cn, dnsName)) { return true; } } catch (CertificateParsingException e) { } return false; }
Source:
public Iterator<MergeChunk> iterator() { return new Iterator<MergeChunk>() { int idx; public boolean hasNext() { return (idx < chunks.size()); } public MergeChunk next() { ConflictState state = ConflictState.NO_CONFLICT; switch (chunks.get(idx++)) { case 0: state = ConflictState.NO_CONFLICT; break; case 1: state = ConflictState.FIRST_CONFLICTING_RANGE; break; case 2: state = ConflictState.NEXT_CONFLICTING_RANGE; break; } int srcIdx = chunks.get(idx++); int begin = chunks.get(idx++); int end = chunks.get(idx++); return new MergeChunk(srcIdx, begin, end, state); } public void remove() { throw new UnsupportedOperationException(); } }; }

Target:
public Iterator<MergeChunk> iterator() { return new Iterator<MergeChunk>() { int idx; public boolean hasNext() { return (idx < chunks.size()); } public MergeChunk next() { ConflictState state = states[chunks.get(idx++)]; int srcIdx = chunks.get(idx++); int begin = chunks.get(idx++); int end = chunks.get(idx++); return new MergeChunk(srcIdx, begin, end, state); } public void remove() { throw new UnsupportedOperationException(); } }; }