auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean canFindVdsToRunOn(List<String> messages, boolean isMigrate) { boolean returnValue = false; if (getDestinationVdsId() != null) { returnValue = canRunOnDestinationVds(messages, isMigrate); } if (!returnValue) { if (privateVm.getMigrationSupport() == MigrationSupport.PINNED_TO_HOST) { messages.add(0, VdcBllMessages.VM_PINNED_TO_HOST_CANNOT_RUN_ON_THE_DEFAULT_VDS.toString()); String hostName = getDestinationVdsId() != null ? DbFacade.getInstance() .getVdsDao() .get(getDestinationVdsId()) .getName() : null; if (hostName != null) { messages.add(1, String.format("$VdsName %1$s", hostName)); } else { messages.add(1, VdcBllMessages.HOST_NAME_NOT_AVAILABLE.toString()); } return false; } returnValue = canFindAnyVds(messages, isMigrate); } return returnValue; }

Target:
public boolean canFindVdsToRunOn(List<String> messages, boolean isMigrate) { boolean returnValue = false; if (getDestinationVdsId() != null) { returnValue = canRunOnDestinationVds(messages, isMigrate); } if (!returnValue) { if (privateVm.getMigrationSupport() == MigrationSupport.PINNED_TO_HOST) { messages.add(0, VdcBllMessages.VM_PINNED_TO_HOST_CANNOT_RUN_ON_THE_DEFAULT_VDS.toString()); VDS host = getDestinationVdsId() == null ? null : DbFacade.getInstance() .getVdsDao() .get(getDestinationVdsId()); String hostName = host == null ? null : host.getName(); messages.add(1, host == null ? VdcBllMessages.HOST_NAME_NOT_AVAILABLE.toString() : String.format("$VdsName %1$s", hostName)); return false; } returnValue = canFindAnyVds(messages, isMigrate); } return returnValue; }
Source:
public static ValidationReport fromGraph(Graph graph, Node node) { boolean conforms = G.contains(graph, node, SHACL.conforms, C.TRUE); List<Node> results = G.listSP(graph, node, SHACL.result); if ( conforms && ! results.isEmpty() ) if ( conforms ) return ValidationReport.create().build(); List<ReportEntry> entries = new ArrayList<>(); Set<Triple> paths = new HashSet<>(); for ( Node r : results ) { Node pn = get(graph, r, SHACL.resultPath); Path path = ( pn != null ) ? ShaclPaths.parsePath(graph, pn) : null ; ReportEntry e = ReportEntry.create() .focusNode( get(graph, r, SHACL.focusNode) ) .resultPath( path ) .message( get(graph, r, SHACL.resultMessage) ) .severity( get(graph, r, SHACL.resultSeverity) ) .source( get(graph, r, SHACL.sourceShape) ) .sourceConstraint( get(graph, r, SHACL.sourceConstraint) ) .sourceConstraintComponent( get(graph, r, SHACL.sourceConstraintComponent) ) .detail( get(graph, r, SHACL.detail) ) .value( get(graph, r, SHACL.value) ) ; entries.add(e); } return new ValidationReport(paths, entries); }

Target:
public static ValidationReport fromGraph(Graph graph, Node node) { boolean conforms = G.contains(graph, node, SHACL.conforms, C.TRUE); List<Node> results = G.listSP(graph, node, SHACL.result); if ( conforms ) return ValidationReport.create().build(); List<ReportEntry> entries = new ArrayList<>(); Set<Triple> paths = new HashSet<>(); for ( Node r : results ) { Node pn = get(graph, r, SHACL.resultPath); Path path = ( pn != null ) ? ShaclPaths.parsePath(graph, pn) : null ; ReportEntry e = ReportEntry.create() .focusNode( get(graph, r, SHACL.focusNode) ) .resultPath( path ) .message( get(graph, r, SHACL.resultMessage) ) .severity( get(graph, r, SHACL.resultSeverity) ) .source( get(graph, r, SHACL.sourceShape) ) .sourceConstraint( get(graph, r, SHACL.sourceConstraint) ) .sourceConstraintComponent( get(graph, r, SHACL.sourceConstraintComponent) ) .detail( get(graph, r, SHACL.detail) ) .value( get(graph, r, SHACL.value) ) ; entries.add(e); } return new ValidationReport(paths, entries, graph.getPrefixMapping()); }
Source:
public List<Expression> getExpressions() { List<Expression> result = new ArrayList<Expression>(groupByAttributes); result.add(expression); return result; }

Target:
public List<Expression> getExpressions() { List<Expression> result = new ArrayList<>(groupByAttributes); result.add(expression); return result; }
Source:
public static void afterClass() { if (DELETE_AFTER_TEST) { try { FileUtils.deleteDirectory(new File("TestCameraTrapData")); } catch (IOException ex) { LOG.error(null, ex); } } }

Target:
public static void afterClass() throws IOException { if (DELETE_AFTER_TEST) { FileUtils.deleteDirectory(new File("TestCameraTrapData")); } }
Source:
private static void addModuleToCodePath(@NotNull GeneralCommandLine commandLine, @NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException{ File outputDirectory = getBuildOutputDirectory(module, forTests, context); commandLine.addParameters("-pa", outputDirectory.getPath()); for(String rootUrl : module.getContentRootsList().getUrls()){ try{ String path = new URL(rootUrl).getPath(); commandLine.addParameters("-pa", path); }catch (MalformedURLException e){ context.processMessage(new CompilerMessage(ElIXIRC_NAME, BuildMessage.Kind.ERROR, "Failed to find content root for module: " + module.getName())); } } }

Target:
private static void addModuleToCodePath(@NotNull GeneralCommandLine commandLine, @NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException{ File outputDirectory = getBuildOutputDirectory(module, forTests, context); commandLine.addParameters(ADD_PATH_TO_FRONT_OF_CODE_PATH, outputDirectory.getPath()); for(String rootUrl : module.getContentRootsList().getUrls()){ try{ String path = new URL(rootUrl).getPath(); commandLine.addParameters(ADD_PATH_TO_FRONT_OF_CODE_PATH, path); }catch (MalformedURLException e){ context.processMessage(new CompilerMessage(ElIXIRC_NAME, BuildMessage.Kind.ERROR, "Failed to find content root for module: " + module.getName())); } } }
Source:
public void addResourceRole(PerunSession sess, User user, Role role, Resource resource) throws InternalErrorException, AlreadyAdminException { if (!role.equals(Role.RESOURCESELFSERVICE)) { throw new InternalErrorException("Role '" + role + "' cannot be set on resource."); } try { jdbc.update("insert into authz (user_id, role_id, resource_id) values (?, (select id from roles where name=?), ?)", user.getId(), role.getRoleName(), resource.getId()); } catch (DataIntegrityViolationException e) { throw new AlreadyAdminException("User id=" + user.getId() + " is already "+role+" in resource " + resource, e, user, resource, role); } catch (RuntimeException e) { throw new InternalErrorException(e); } }

Target:
public void addResourceRole(PerunSession sess, User user, Role role, Resource resource) throws InternalErrorException, AlreadyAdminException { if (!role.equals(Role.RESOURCESELFSERVICE)) { throw new InternalErrorException("Role " + role + " cannot be set on resource."); } try { jdbc.update("insert into authz (user_id, role_id, resource_id) values (?, (select id from roles where name=?), ?)", user.getId(), role.getRoleName(), resource.getId()); } catch (DataIntegrityViolationException e) { throw new AlreadyAdminException("User id=" + user.getId() + " is already "+role+" in resource " + resource, e, user, resource, role); } catch (RuntimeException e) { throw new InternalErrorException(e); } }
Source:
public final String pushState(@Parameter(description = "The destination site name", name = "SiteName") String siteName) { String status = bringSiteOnline(siteName); if (!SUCCESS.equals(status)) { return String.format("Unable to pushState to '%s'. %s", siteName, status); } try { stateTransferManager.startPushState(siteName); } catch (Throwable throwable) { log.errorf(throwable, "Unable to pushState to '%s'.", siteName); return String.format("Unable to pushState to '%s'. %s", siteName, throwable.getLocalizedMessage()); } return SUCCESS; }

Target:
public final String pushState(@Parameter(description = "The destination site name", name = "SiteName") String siteName) { try { String status = bringSiteOnline(siteName); if (!SUCCESS.equals(status)) { return String.format("Unable to pushState to '%s'. %s", siteName, status); } stateTransferManager.startPushState(siteName); } catch (Throwable throwable) { log.xsiteAdminOperationError("pushState", siteName, throwable); return String.format("Unable to pushState to '%s'. %s", siteName, throwable.getLocalizedMessage()); } return SUCCESS; }
Source:
public void afterDownloadingXForm_cancelling_throwsInterruptedExceptionAndDoesNotSaveAnything() throws Exception { String xform = createXForm("id", "version"); ServerFormDetails serverFormDetails = new ServerFormDetails( "Form", "http://downloadUrl", "http://manifestUrl", "id", "version", "md5:" + FileUtils.getMd5Hash(new ByteArrayInputStream(xform.getBytes())), true, false, null); CancelAfterFormDownloadFormListApi formListApi = new CancelAfterFormDownloadFormListApi(xform); ServerFormDownloader downloader = new ServerFormDownloader(formListApi, formsRepository, cacheDir, formsDir.getAbsolutePath()); try { downloader.downloadForm(serverFormDetails, null, formListApi); fail("Excepted exception"); } catch (InterruptedException e) { assertThat(formsRepository.getAll(), is(empty())); assertThat(asList(new File(getCacheFilesPath()).listFiles()), is(empty())); assertThat(asList(new File(getFormFilesPath()).listFiles()), is(empty())); } }

Target:
public void afterDownloadingXForm_cancelling_throwsInterruptedExceptionAndDoesNotSaveAnything() throws Exception { String xform = createXForm("id", "version"); ServerFormDetails serverFormDetails = new ServerFormDetails( "Form", "http://downloadUrl", "http://manifestUrl", "id", "version", "md5:" + FileUtils.getMd5Hash(new ByteArrayInputStream(xform.getBytes())), true, false, null); CancelAfterFormDownloadFormSource formListApi = new CancelAfterFormDownloadFormSource(xform); ServerFormDownloader downloader = new ServerFormDownloader(formListApi, formsRepository, cacheDir, formsDir.getAbsolutePath(), new FormMetadataParser(ReferenceManager.instance())); try { downloader.downloadForm(serverFormDetails, null, formListApi); fail("Expected exception"); } catch (InterruptedException e) { assertThat(formsRepository.getAll(), is(empty())); assertThat(asList(new File(getCacheFilesPath()).listFiles()), is(empty())); assertThat(asList(new File(getFormFilesPath()).listFiles()), is(empty())); } }
Source:
public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable cause) { markGlobalFailure(); if (context == null) { logger.debug("Encountered null metric context likely due to exception in preInvocation: {}", UnsafeArg.of("exception", cause), cause); return; } String failuresMetricName = InstrumentationUtils.getFailuresMetricName(context, serviceName); Map<String, String> tags = tagFunction.map(f -> f.apply(context)).orElse(ImmutableMap.of()); taggedMetricRegistry.meter(MetricName.builder() .safeName(failuresMetricName) .safeTags(tags) .build()) .mark(); taggedMetricRegistry.meter(MetricName.builder() .safeName(MetricRegistry.name(failuresMetricName, cause.getClass().getName())) .safeTags(tags) .build()) .mark(); }

Target:
public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable cause) { markGlobalFailure(); if (context == null) { logger.debug("Encountered null metric context likely due to exception in preInvocation: {}", UnsafeArg.of("exception", cause), cause); return; } String failuresMetricName = InstrumentationUtils.getFailuresMetricName(context, serviceName); Map<String, String> tags = tagFunction.map(f -> f.apply(context)).orElseGet(ImmutableMap::of); taggedMetricRegistry.meter(MetricName.builder() .safeName(failuresMetricName) .safeTags(tags) .build()) .mark(); taggedMetricRegistry.meter(MetricName.builder() .safeName(MetricRegistry.name(failuresMetricName, cause.getClass().getName())) .safeTags(tags) .build()) .mark(); }
Source:
private double getMatchingPrice(ArrayList<Order> sortedBuyOrderBook, ArrayList<Order> sortedSellOrderBook) { double matchingPrice; int obSize; if (sortedBuyOrderBook.size() > sortedSellOrderBook.size()) { obSize = sortedBuyOrderBook.size(); }else{ obSize = sortedSellOrderBook.size(); } int[] cumulativeSell = new int[obSize]; int[] cumulativeBuy = new int[obSize]; int[] totalTrades = new int[obSize]; double[] tradePrices = new double[obSize]; int individualBuy = 0; int individualSell = 0; for (int i = 0; i < obSize; i++) { Order so; Order bo; if (i < sortedSellOrderBook.size()) { so = sortedSellOrderBook.get(i); individualSell = so.getSize(); cumulativeSell[i] = (i > 0) ? cumulativeSell[i-1] + individualSell : individualSell; } tradePrices[i] = sortedSellOrderBook.get(i).getPrice(); if (i < sortedBuyOrderBook.size()) { bo = sortedBuyOrderBook.get(i); individualBuy = bo.getSize(); cumulativeBuy[i] = (i > 0) ? cumulativeBuy[i-1] + individualBuy : individualBuy; } } for (int i = 0; i < obSize; i++){ totalTrades[i] = cumulativeBuy[i] + cumulativeSell[i]; } matchingPrice = tradePrices[0]; for (int i = 0; i < totalTrades.length; i++) { if (totalTrades[i] > matchingPrice) { matchingPrice = tradePrices[i]; } } return matchingPrice; }

Target:
private double getMatchingPrice(ArrayList<Order> sortedBuyOrderBook, ArrayList<Order> sortedSellOrderBook) { double matchingPrice; int obSize; if (sortedBuyOrderBook.size() > sortedSellOrderBook.size()) { obSize = sortedBuyOrderBook.size(); }else{ obSize = sortedSellOrderBook.size(); } int[] cumulativeSell = new int[obSize]; int[] cumulativeBuy = new int[obSize]; int[] totalTrades = new int[obSize]; double[] tradePrices = new double[obSize]; int individualBuy = 0; int individualSell = 0; for (int i = 0; i < obSize; i++) { Order sellord; Order buyord; if (i < sortedSellOrderBook.size()) { sellord = sortedSellOrderBook.get(i); individualSell = sellord.getSize(); cumulativeSell[i] = (i > 0) ? cumulativeSell[i-1] + individualSell : individualSell; } tradePrices[i] = sortedSellOrderBook.get(i).getPrice(); if (i < sortedBuyOrderBook.size()) { buyord = sortedBuyOrderBook.get(i); individualBuy = buyord.getSize(); cumulativeBuy[i] = (i > 0) ? cumulativeBuy[i-1] + individualBuy : individualBuy; } } for (int i = 0; i < obSize; i++){ totalTrades[i] = cumulativeBuy[i] + cumulativeSell[i]; } matchingPrice = tradePrices[0]; for (int i = 0; i < totalTrades.length; i++) { if (totalTrades[i] > matchingPrice) { matchingPrice = tradePrices[i]; } } return matchingPrice; }
Source:
public DDFCache(DDFManager manager) { mDDFManager = manager; Long maxNumberOfDDFs = Long.valueOf(Config.getGlobalValue(Config.ConfigConstant.MAX_NUMBER_OF_DDFS_IN_CACHE)); Long timeToIdle = Long.valueOf(Config.getGlobalValue(Config.ConfigConstant.DDF_TIME_TO_IDLE_SECONDS)); mLog.info(String.format("Maximum number of ddfs in cache %s", maxNumberOfDDFs)); mLog.info(String.format("DDF's time to idle = %s seconds", timeToIdle)); mDDFCache = CacheBuilder.newBuilder(). maximumSize(maxNumberOfDDFs).expireAfterAccess(timeToIdle, TimeUnit.SECONDS). recordStats().removalListener(new DDFRemovalListener()) .build(new CacheLoader<UUID, DDF>() { @Override public DDF load(UUID uuid) throws Exception { try { mLog.info(String.format("restoring ddf %s", uuid)); return mDDFManager.restoreDDF(uuid); } catch (Exception e) { mLog.error(String.format("Error restoring DDF %s, error = %s", uuid, ExceptionUtils.getStackTrace(e))); throw new DDFException(String.format("DDF with uuid %s does not exist", uuid)); } } }); }

Target:
public DDFCache(DDFManager manager) { mDDFManager = manager; Long maxNumberOfDDFs = Long.valueOf(Config.getGlobalValue(Config.ConfigConstant.MAX_NUMBER_OF_DDFS_IN_CACHE)); Long maxNumberOfDDFsWName = Long .valueOf(Config.getGlobalValue(Config.ConfigConstant.MAX_NUMBER_OF_DDFS_WITH_NAME_IN_CACHE)); Long timeToIdle = Long.valueOf(Config.getGlobalValue(Config.ConfigConstant.DDF_TIME_TO_IDLE_SECONDS)); mLog.info(String.format("Maximum number of ddfs in cache %s", maxNumberOfDDFs)); mLog.info(String.format("DDF's time to idle = %s seconds", timeToIdle)); mDDFCache = CacheBuilder.newBuilder(). maximumSize(maxNumberOfDDFs).expireAfterAccess(timeToIdle, TimeUnit.SECONDS). recordStats().removalListener(new DDFRemovalListener()).build(); mDDFwithNameCache = CacheBuilder.newBuilder(). maximumSize(maxNumberOfDDFsWName).recordStats().removalListener(new DDFRemovalListener()).build(); }
Source:
private Set<String> getKeysFromDeps(List<Dependency> deps) { Set<String> depsMap = new HashSet<>(deps.size()); for (Dependency dep : deps) { StringBuilder sb = new StringBuilder(); sb.append(dep.getGroupId()).append(DELIMITER).append(dep.getArtifactId()).append(DELIMITER).append(dep.getVersion()); depsMap.add(sb.toString()); } return depsMap; }

Target:
private Map<String, String> getKeysFromDeps(List<Dependency> deps) { Map<String, String> depsMap = new HashMap(deps.size()); for (Dependency dep : deps) { StringBuilder sb = new StringBuilder(); sb.append(dep.getGroupId()).append(DELIMITER).append(dep.getArtifactId()); depsMap.put(sb.toString(), dep.getVersion()); } return depsMap; }
Source:
public CounterChartViewer(Composite parent) { super(parent, null, null, null); Chart chart = getSwtChart(); chart.getLegend().setPosition(SWT.BOTTOM); chart.getLegend().setVisible(true); chart.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); }

Target:
public CounterChartViewer(Composite parent) { super(parent, null, null, null); Chart chart = getSwtChart(); chart.getLegend().setPosition(SWT.BOTTOM); chart.getLegend().setVisible(true); chart.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); }
Source:
private BlockLease flattenDictionaryBlock(DictionaryBlock dictionaryBlock) { Block dictionary = dictionaryBlock.getDictionary(); int positionCount = dictionaryBlock.getPositionCount(); int[] currentRemappedIds = (int[]) dictionaryBlock.getIds().getArray(); int[] newRemappedIds = null; while (true) { if (dictionary instanceof DictionaryBlock) { dictionaryBlock = (DictionaryBlock) dictionary; int[] ids = (int[]) dictionaryBlock.getIds().getArray(); if (newRemappedIds == null) { newRemappedIds = allocator.borrowIntArray(positionCount); } for (int i = 0; i < positionCount; ++i) { newRemappedIds[i] = ids[currentRemappedIds[i] + dictionaryBlock.getOffsetBase()]; } currentRemappedIds = newRemappedIds; dictionary = dictionaryBlock.getDictionary(); } else if (dictionary instanceof RunLengthEncodedBlock) { RunLengthEncodedBlock rle = (RunLengthEncodedBlock) dictionary; if (newRemappedIds == null) { newRemappedIds = allocator.borrowIntArray(positionCount); } Arrays.fill(newRemappedIds, 0, positionCount, 0); currentRemappedIds = newRemappedIds; dictionary = rle.getValue(); } else { break; } } if (newRemappedIds == null) { return newLease(dictionaryBlock); } dictionary = new DictionaryBlock(positionCount, dictionary, currentRemappedIds); int[] leasedMapToReturn = newRemappedIds; return newLease(dictionary, () -> allocator.returnArray(leasedMapToReturn)); }

Target:
private BlockLease flattenDictionaryBlock(DictionaryBlock dictionaryBlock) { Block dictionary = dictionaryBlock.getDictionary(); int positionCount = dictionaryBlock.getPositionCount(); int[] currentRemappedIds = dictionaryBlock.getRawIds(); int[] newRemappedIds = null; while (true) { if (dictionary instanceof DictionaryBlock) { dictionaryBlock = (DictionaryBlock) dictionary; int[] ids = dictionaryBlock.getRawIds(); if (newRemappedIds == null) { newRemappedIds = allocator.borrowIntArray(positionCount); } for (int i = 0; i < positionCount; ++i) { newRemappedIds[i] = ids[currentRemappedIds[i] + dictionaryBlock.getOffsetBase()]; } currentRemappedIds = newRemappedIds; dictionary = dictionaryBlock.getDictionary(); } else if (dictionary instanceof RunLengthEncodedBlock) { RunLengthEncodedBlock rle = (RunLengthEncodedBlock) dictionary; if (newRemappedIds == null) { newRemappedIds = allocator.borrowIntArray(positionCount); } Arrays.fill(newRemappedIds, 0, positionCount, 0); currentRemappedIds = newRemappedIds; dictionary = rle.getValue(); } else { break; } } if (newRemappedIds == null) { return newLease(dictionaryBlock); } dictionary = new DictionaryBlock(positionCount, dictionary, currentRemappedIds); int[] leasedMapToReturn = newRemappedIds; return newLease(dictionary, () -> allocator.returnArray(leasedMapToReturn)); }
Source:
private List<String> readAsList(InputTextField field) { if (field.getText().isEmpty()) { return new ArrayList<>(); } else { return Arrays.asList(StringUtils.deleteWhitespace(field.getText()).split(",")); } }

Target:
private List<String> readAsList(InputTextField field) { if (field.getText().isEmpty()) { return Collections.emptyList(); } else { return Arrays.asList(StringUtils.deleteWhitespace(field.getText()).split(",")); } }
Source:
public RedisJedisManager(String host, int port, int database, String password) { JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxTotal(maxTotal); jedisPoolConfig.setMaxIdle(maxIdle); jedisPoolConfig.setMinIdle(minIdle); this.host = host; this.port = port; this.database = database; this.password = password; this.jedisPoolConfig = jedisPoolConfig; this.jedisPoolCache = CacheBuilder.newBuilder().build(CacheLoader.from(this::createConsumer)); }

Target:
public RedisJedisManager(String host, int port, int database, String password) { JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxTotal(maxTotal); jedisPoolConfig.setMaxIdle(maxIdle); jedisPoolConfig.setMinIdle(minIdle); this.host = host; this.port = port; this.database = database; this.password = password; this.jedisPoolConfig = jedisPoolConfig; this.jedisPoolCache = CacheBuilder.newBuilder() .removalListener(new JedisPoolRemovalListener()) .build(CacheLoader.from(this::createConsumer)); }
Source:
private boolean validateNewColumnRequest() { if (!userPrefs_.allowSourceColumns().getValue()) { pGlobalDisplay_.get().showMessage(GlobalDisplay.MSG_INFO, "Cannot Add Column", "Allow Source Columns preference is disabled."); return false; } else if (additionalSourceCount_ >= MAX_COLUMN_COUNT) { pGlobalDisplay_.get().showMessage(GlobalDisplay.MSG_INFO, "Cannot Add Column", "You can't add more than " + MAX_COLUMN_COUNT + " columns."); return false; } return true; }

Target:
private boolean validateNewColumnRequest() { if (additionalSourceCount_ >= MAX_COLUMN_COUNT) { pGlobalDisplay_.get().showMessage(GlobalDisplay.MSG_INFO, "Cannot Add Column", "You can't add more than " + MAX_COLUMN_COUNT + " columns."); return false; } return true; }
Source:
public void testRequestUriEnabled(Scenario scenario) throws Exception { start(false); RewriteRegexRule rule = new RewriteRegexRule(); reset(); _request.setHttpURI(HttpURI.build(_request.getHttpURI()).asImmutable()); rule.setRegex(scenario.regex); rule.setReplacement(scenario.replacement); _request.setHttpURI(HttpURI.build(_request.getHttpURI(), scenario.uriPathQuery, null, scenario.queryString).asImmutable()); String result = rule.matchAndApply(scenario.uriPathQuery, _request, _response); assertEquals(scenario.expectedRequestURI, result); rule.applyURI(_request, scenario.uriPathQuery, result); if (result != null) { assertEquals(scenario.expectedRequestURI, _request.getRequestURI()); assertEquals(scenario.expectedQueryString, _request.getQueryString()); } if (scenario.expectedQueryString != null) { MultiMap<String> params = new MultiMap<String>(); UrlEncoded.decodeTo(scenario.expectedQueryString, params, StandardCharsets.UTF_8); for (String n : params.keySet()) { assertEquals(params.getString(n), _request.getParameter(n)); } } }

Target:
public void testRequestUriEnabled(Scenario scenario) throws Exception { start(false); RewriteRegexRule rule = new RewriteRegexRule(); reset(); _request.setHttpURI(HttpURI.build(_request.getHttpURI())); rule.setRegex(scenario.regex); rule.setReplacement(scenario.replacement); _request.setHttpURI(HttpURI.build(_request.getHttpURI(), scenario.uriPathQuery, null, scenario.queryString)); String result = rule.matchAndApply(scenario.uriPathQuery, _request, _response); assertEquals(scenario.expectedRequestURI, result); rule.applyURI(_request, scenario.uriPathQuery, result); if (result != null) { assertEquals(scenario.expectedRequestURI, _request.getRequestURI()); assertEquals(scenario.expectedQueryString, _request.getQueryString()); } if (scenario.expectedQueryString != null) { MultiMap<String> params = new MultiMap<String>(); UrlEncoded.decodeTo(scenario.expectedQueryString, params, StandardCharsets.UTF_8); for (String n : params.keySet()) { assertEquals(params.getString(n), _request.getParameter(n)); } } }
Source:
public void setUp() throws Exception { this.workspaceName = generate("workspace", 5); dashboard.open(); createWorkspaceHelper.createAndEditWorkspaceFromStack( Devfile.JAVA_MAVEN, workspaceName, Collections.emptyList(), null); }

Target:
public void setUp() throws Exception { dashboard.open(); createWorkspaceHelper.createAndEditWorkspaceFromStack( Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); }
Source:
public LiuWestFilter(Model model, Properties properties) { super(model, properties); String rhoStr = properties.getProperty("rho", "1"); try { rho = Double.parseDouble(rhoStr); System.out.println("perturbation amount: " + rho); } catch (NumberFormatException e) { Util.fatalErrorWithoutStack("Invalid rho parameter: " + rhoStr); } funcNamesToPerturb = new ArrayList<String>(); for (Function func : model.getFunctions()) { if (func instanceof NonRandomFunction) { continue; } if (func.isTimeIndexed()) { continue; } if (func.getRetType() != BuiltInTypes.REAL) { continue; } if (func.getArgTypes().length > 0) { continue; } funcNamesToPerturb.add(func.getName()); } System.out.println("funcNamesToPerturb: " + funcNamesToPerturb); }

Target:
public LiuWestFilter(Model model, Properties properties) { super(model, properties); String rhoStr = properties.getProperty("rho", "0.97"); try { rho = Double.parseDouble(rhoStr); System.out.println("perturbation amount: " + rho); } catch (NumberFormatException e) { Util.fatalErrorWithoutStack("Invalid rho parameter: " + rhoStr); } funcNamesToPerturb = new ArrayList<String>(); for (Function func : model.getFunctions()) { if (func instanceof NonRandomFunction) { continue; } if (func.isTimeIndexed()) { continue; } if (func.getRetType() != BuiltInTypes.REAL) { continue; } if (func.getArgTypes().length > 0) { continue; } funcNamesToPerturb.add(func.getName()); } System.out.println("funcNamesToPerturb: " + funcNamesToPerturb); }
Source:
public GroupedExecutionProperties visitTableScan(TableScanNode node, Void context) { Optional<TablePartitioning> tablePartitioning = metadata.getLayout(session, node.getTable()).getTablePartitioning(); if (!tablePartitioning.isPresent()) { return GroupedExecutionProperties.notCapable(); } List<ConnectorPartitionHandle> partitionHandles = nodePartitioningManager.listPartitionHandles(session, tablePartitioning.get().getPartitioningHandle()); if (ImmutableList.of(NOT_PARTITIONED).equals(partitionHandles)) { return new GroupedExecutionProperties(false, false, ImmutableList.of(), partitionHandles.size()); } else { return new GroupedExecutionProperties(true, false, ImmutableList.of(node.getId()), partitionHandles.size()); } }

Target:
public GroupedExecutionProperties visitTableScan(TableScanNode node, Void context) { Optional<TablePartitioning> tablePartitioning = metadata.getLayout(session, node.getTable()).getTablePartitioning(); if (!tablePartitioning.isPresent()) { return GroupedExecutionProperties.notCapable(); } List<ConnectorPartitionHandle> partitionHandles = nodePartitioningManager.listPartitionHandles(session, tablePartitioning.get().getPartitioningHandle()); if (ImmutableList.of(NOT_PARTITIONED).equals(partitionHandles)) { return new GroupedExecutionProperties(false, false, ImmutableList.of(), 1); } else { return new GroupedExecutionProperties(true, false, ImmutableList.of(node.getId()), partitionHandles.size()); } }
Source:
ZoneIdentifierInfo(AbstractFile zoneFile) throws FileNotFoundException, IOException { String line; try (BufferedReader reader = new BufferedReader(new InputStreamReader(new ReadContentInputStream(zoneFile)))) { while ((line = reader.readLine()) != null) { String[] tokens = line.split("="); if (tokens.length < 2) { continue; } dataMap.put(tokens[0].trim().toLowerCase(), tokens[1].trim()); } } }

Target:
ZoneIdentifierInfo(AbstractFile zoneFile) throws IOException { properties.load(new ReadContentInputStream(zoneFile)); }
Source:
public static int calcHeatNeutralHSRequirement(Entity entity) { int heat = 0; for (Mounted m : entity.getWeaponList()) { WeaponType wt = (WeaponType) m.getType(); if ((wt.hasFlag(WeaponType.F_LASER) && (wt.getAmmoType() == AmmoType.T_NA)) || wt.hasFlag(WeaponType.F_PPC) || wt.hasFlag(WeaponType.F_PLASMA) || wt.hasFlag(WeaponType.F_PLASMA_MFUK) || (wt.hasFlag(WeaponType.F_FLAMER) && (wt.getAmmoType() == AmmoType.T_NA))) { heat += wt.getHeat(); } if (wt.hasFlag(WeaponType.F_LASER) && (m.getLinkedBy() != null) && !m.getLinkedBy().isInoperable() && m.getLinkedBy().getType().hasFlag(MiscType.F_LASER_INSULATOR)) { heat -= 1; if (heat == 0) { heat++; } } if ((m.getLinkedBy() != null) && (m.getLinkedBy().getType() instanceof MiscType) && m.getLinkedBy().getType(). hasFlag(MiscType.F_PPC_CAPACITOR)) { heat += 5; } } for (Mounted m : entity.getMisc()) { if (m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_SPOT_WELDER) && entity.hasEngine() && (entity.getEngine().isFusion() || entity.getEngine().getEngineType() == Engine.FISSION)) { continue; } heat += m.getType().getHeat(); } if (entity.hasStealth()) { heat += 10; } return heat; }

Target:
public static int calcHeatNeutralHSRequirement(Entity entity) { int heat = 0; for (Mounted m : entity.getWeaponList()) { WeaponType wt = (WeaponType) m.getType(); if ((wt.hasFlag(WeaponType.F_LASER) && (wt.getAmmoType() == AmmoType.T_NA)) || wt.hasFlag(WeaponType.F_PPC) || wt.hasFlag(WeaponType.F_PLASMA) || wt.hasFlag(WeaponType.F_PLASMA_MFUK) || (wt.hasFlag(WeaponType.F_FLAMER) && (wt.getAmmoType() == AmmoType.T_NA))) { heat += wt.getHeat(); } if (wt.hasFlag(WeaponType.F_LASER) && (m.getLinkedBy() != null) && !m.getLinkedBy().isInoperable() && m.getLinkedBy().getType().hasFlag(MiscType.F_LASER_INSULATOR)) { heat -= 1; if (heat == 0) { heat++; } } if ((m.getLinkedBy() != null) && (m.getLinkedBy().getType() instanceof MiscType) && m.getLinkedBy().getType(). hasFlag(MiscType.F_PPC_CAPACITOR)) { heat += 5; } } for (Mounted m : entity.getMisc()) { if (m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_SPOT_WELDER) && entity.hasEngine() && (entity.getEngine().isFusion() || (entity.getEngine().getEngineType() == Engine.FISSION))) { continue; } heat += m.getType().getHeat(); } if (entity.hasStealth()) { heat += 10; } return heat; }
Source:
public int hashCode() { int certsHashCode = 0; Collection<CertificateDTO> certificateDTOs = this.getCertificates(); if (certificateDTOs != null) { for (CertificateDTO dto : certificateDTOs) { certsHashCode = 31 * certsHashCode + (dto != null ? dto.hashCode() : 0); } } HashCodeBuilder builder = new HashCodeBuilder(37, 7) .append(super.hashCode()) .append(this.getId()) .append(this.getOwner() != null ? this.getOwner().getId() : null) .append(this.getPool() != null ? this.getPool().getId() : null) .append(this.getConsumer() != null ? this.getConsumer().getUuid() : null) .append(this.getQuantity()) .append(this.isDeletedFromPool()) .append(this.getEndDate()) .append(this.getStartDate()) .append(certsHashCode); return builder.toHashCode(); }

Target:
public int hashCode() { int certsHashCode = 0; Collection<CertificateDTO> certificateDTOs = this.getCertificates(); if (certificateDTOs != null) { for (CertificateDTO dto : certificateDTOs) { certsHashCode = 31 * certsHashCode + (dto != null && dto.getId() != null ? dto.getId().hashCode() : 0); } } HashCodeBuilder builder = new HashCodeBuilder(37, 7) .append(super.hashCode()) .append(this.getId()) .append(this.getOwner() != null ? this.getOwner().getId() : null) .append(this.getPool() != null ? this.getPool().getId() : null) .append(this.getConsumer() != null ? this.getConsumer().getUuid() : null) .append(this.getQuantity()) .append(this.isDeletedFromPool()) .append(this.getEndDate()) .append(this.getStartDate()) .append(certsHashCode); return builder.toHashCode(); }
Source:
public void updated(Provider<E> provider, E oldElement, E element) { Collection<E> elements = elementMap.get(provider); if (elements != null && elements.contains(oldElement) && oldElement.getUID().equals(element.getUID())) { try { E existingElement = get(oldElement.getUID()); if (existingElement != null) { beforeUpdateElement(existingElement); } onUpdateElement(oldElement, element); if (existingElement != null) { elements.remove(existingElement); } elements.add(element); notifyListenersAboutUpdatedElement(oldElement, element); } catch (Exception ex) { logger.warn("Could not update element: {}", ex.getMessage(), ex); } } }

Target:
public void updated(Provider<E> provider, E oldElement, E element) { Collection<E> elements = elementMap.get(provider); if (elements != null && elements.contains(oldElement) && oldElement.getUID().equals(element.getUID())) { try { E existingElement = get(oldElement.getUID()); if (existingElement != null) { beforeUpdateElement(existingElement); } else { logger.debug("{} with key '{}' could not be updated for provider because it does not exist!", element.getClass().getSimpleName(), element.getUID(), provider.getClass().getSimpleName()); } onUpdateElement(oldElement, element); if (existingElement != null) { elements.remove(existingElement); } elements.add(element); notifyListenersAboutUpdatedElement(oldElement, element); } catch (Exception ex) { logger.warn("Could not update element: {}", ex.getMessage(), ex); } } }
Source:
public StreamSpec streamFromConfig(String streamId) { StreamConfig streamConfig = new StreamConfig(config); String defaultPhysicalName = String.format("%s-%s-%s", config.get(JobConfig.JOB_NAME()), config.get(JobConfig.JOB_ID(), "1"), streamId); String physicalName = streamConfig.getPhysicalName(streamId, defaultPhysicalName); return streamFromConfig(streamId, physicalName); }

Target:
public StreamSpec streamFromConfig(String streamId) { StreamConfig streamConfig = new StreamConfig(config); String physicalName = streamConfig.getPhysicalName(streamId); return streamFromConfig(streamId, physicalName); }
Source:
public StompSubframeDecoder(int maxLineLength, int maxChunkSize, boolean validateHeaders) { super(State.SKIP_CONTROL_CHARACTERS); checkPositive(maxLineLength, "maxLineLength"); checkPositive(maxChunkSize, "maxChunkSize"); this.maxChunkSize = maxChunkSize; commandParser = new Utf8LineParser(new AppendableCharSequence(16), maxLineLength); headerParser = new HeaderParser(new AppendableCharSequence(123), maxLineLength, validateHeaders); }

Target:
public StompSubframeDecoder(int maxLineLength, int maxChunkSize, boolean validateHeaders) { super(State.SKIP_CONTROL_CHARACTERS); checkPositive(maxLineLength, "maxLineLength"); checkPositive(maxChunkSize, "maxChunkSize"); this.maxChunkSize = maxChunkSize; commandParser = new Utf8LineParser(new AppendableCharSequence(16), maxLineLength); headerParser = new HeaderParser(new AppendableCharSequence(128), maxLineLength, validateHeaders); }
Source:
public SagaResult getResult() { return !finished ? SagaResult.PROGRESS : forward ? SagaResult.FINISHED : SagaResult.ROLLBACKED; }

Target:
public SagaResult getResult() { if (finished) { return forward ? SagaResult.FINISHED : SagaResult.ROLLBACKED; } return SagaResult.PROGRESS; }
Source:
private Expectations asyncGetExpectation( KeyValueService kvMock, Cell cell, long transactionTs, LockService lockMock) throws Exception { return new Expectations() {{ oneOf(kvMock).getAsync(TABLE, ImmutableMap.of(cell, transactionTs)); will(returnValue(Futures.immediateFailedFuture(new RuntimeException()))); never(lockMock).lockWithFullLockResponse(with(LockClient.ANONYMOUS), with(any(LockRequest.class))); }}; }

Target:
private Expectations asyncGetExpectation( KeyValueService kvMock, Cell cell, long transactionTs, LockService lockMock) { return new Expectations() {{ oneOf(kvMock).getAsync(TABLE, ImmutableMap.of(cell, transactionTs)); will(returnValue(Futures.immediateFailedFuture(new RuntimeException()))); }}; }
Source:
public static void mergeIteratorConfig(List<IterInfo> destList, Map<String,Map<String,String>> destOpts, List<IterInfo> tableIters, Map<String,Map<String,String>> tableOpts, List<IterInfo> ssi, Map<String,Map<String,String>> ssio) { destList.addAll(tableIters); destList.addAll(ssi); Collections.sort(destList, IterConfigUtil.ITER_INFO_COMPARATOR); Set<Map.Entry<String,Map<String,String>>> es = tableOpts.entrySet(); for (Map.Entry<String,Map<String,String>> entry : es) { if (entry.getValue() == null) { destOpts.put(entry.getKey(), null); } else { destOpts.put(entry.getKey(), new HashMap<>(entry.getValue())); } } mergeOptions(ssio, destOpts); }

Target:
public static void mergeIteratorConfig(List<IterInfo> destList, Map<String,Map<String,String>> destOpts, List<IterInfo> tableIters, Map<String,Map<String,String>> tableOpts, List<IterInfo> ssi, Map<String,Map<String,String>> ssio) { destList.addAll(tableIters); destList.addAll(ssi); Collections.sort(destList, ITER_INFO_COMPARATOR); Set<Entry<String,Map<String,String>>> es = tableOpts.entrySet(); for (Entry<String,Map<String,String>> entry : es) { if (entry.getValue() == null) { destOpts.put(entry.getKey(), null); } else { destOpts.put(entry.getKey(), new HashMap<>(entry.getValue())); } } mergeOptions(ssio, destOpts); }
Source:
public void testPopulateFieldInfo() { TestOutputOperator outputOperator = setupForOutputOperatorTest(); outputOperator.input.setup(tpc); outputOperator.setup(context); outputOperator.activate(context); List<TestPojo> events = Lists.newArrayList(); for (int i = 0; i < 3; i++) { Set<Integer> set = new HashSet<Integer>(); set.add(i); List<Integer> list = new ArrayList<Integer>(); list.add(i); Map<String, Integer> map = new HashMap<String, Integer>(); map.put("key" + i, i); events.add(new TestPojo(UUID.randomUUID(), i, "abclast", true, i, 2.0, set, list, map, new Date(System.currentTimeMillis()))); } outputOperator.beginWindow(0); for (TestPojo event : events) { outputOperator.input.process(event); } outputOperator.endWindow(); Assert.assertEquals("rows in db", 3, outputOperator.getNumOfEventsInStore()); outputOperator.getEventsInStore(); }

Target:
public void testPopulateFieldInfo() { TestOutputOperator outputOperator = setupForOutputOperatorTest(); outputOperator.setup(context); outputOperator.input.setup(tpc); outputOperator.activate(context); List<TestPojo> events = Lists.newArrayList(); for (int i = 0; i < 3; i++) { Set<Integer> set = new HashSet<Integer>(); set.add(i); List<Integer> list = new ArrayList<Integer>(); list.add(i); Map<String, Integer> map = new HashMap<String, Integer>(); map.put("key" + i, i); events.add(new TestPojo(UUID.randomUUID(), i, "abclast", true, i, 2.0, set, list, map, new Date(System.currentTimeMillis()))); } outputOperator.beginWindow(0); for (TestPojo event : events) { outputOperator.input.process(event); } outputOperator.endWindow(); Assert.assertEquals("rows in db", 3, outputOperator.getNumOfEventsInStore()); outputOperator.getEventsInStore(); }
Source:
public FunctionPollConfig<S, T> supplier(final Supplier<? extends S> val) { checkNotNull(val, "supplier"); this.callable = new Callable<S>() { @Override public S call() throws Exception { return (S) val.get(); } }; return this; }

Target:
public FunctionPollConfig<S, T> supplier(final Supplier<? extends S> val) { checkNotNull(val, "supplier"); this.callable = new Callable<S>() { @Override public S call() throws Exception { return val.get(); } }; return this; }
Source:
public static SamInputResource of(final Path path) { if (Files.isRegularFile(path)) { return new SamInputResource(new PathInputResource(path)); } else { return of(path.toFile()); } }

Target:
public static SamInputResource of(final Path path) { if (path.getFileSystem() == FileSystems.getDefault() && !Files.isRegularFile(path)) { return of(path.toFile()); } else { return new SamInputResource(new PathInputResource(path)); } }
Source:
private boolean deployFromTemplate(final Run<?, ?> run, final Launcher launcher, final TaskListener listener) throws VSphereException { PrintStream jLogger = listener.getLogger(); String expandedClone = clone; String expandedTemplate = template; String expandedCluster = cluster; String expandedDatastore = datastore; EnvVars env; try { env = run.getEnvironment(listener); } catch (Exception e) { throw new VSphereException(e); } if (run instanceof AbstractBuild) { env.overrideAll(((AbstractBuild) run).getBuildVariables()); expandedClone = env.expand(clone); expandedTemplate = env.expand(template); expandedCluster = env.expand(cluster); expandedDatastore = env.expand(datastore); } String resourcePoolName; if ("".equals(resourcePool) || (resourcePool.length() == 0)) { resourcePoolName = "Resources"; } else { resourcePoolName = env.expand(resourcePool); } vsphere.deployVm(expandedClone, expandedTemplate, linkedClone, resourcePoolName, expandedCluster, expandedDatastore, powerOn, jLogger); VSphereLogger.vsLogger(jLogger, "\""+expandedClone+"\" successfully deployed!"); IP = vsphere.getIp(vsphere.getVmByName(expandedClone), 20); VSphereLogger.vsLogger(jLogger, "Successfully retrieved IP for \""+expandedClone+"\" : "+IP); VSphereLogger.vsLogger(jLogger, "Exposing " + IP + " as environment variable VSPHERE_IP"); if (run instanceof AbstractBuild) { VSphereEnvAction envAction = new VSphereEnvAction(); envAction.add("VSPHERE_IP", IP); run.addAction(envAction); } return true; }

Target:
private boolean deployFromTemplate(final Run<?, ?> run, final Launcher launcher, final TaskListener listener) throws VSphereException { PrintStream jLogger = listener.getLogger(); String expandedClone = clone; String expandedTemplate = template; String expandedCluster = cluster; String expandedDatastore = datastore; EnvVars env; try { env = run.getEnvironment(listener); } catch (Exception e) { throw new VSphereException(e); } if (run instanceof AbstractBuild) { env.overrideAll(((AbstractBuild) run).getBuildVariables()); expandedClone = env.expand(clone); expandedTemplate = env.expand(template); expandedCluster = env.expand(cluster); expandedDatastore = env.expand(datastore); } String resourcePoolName; if ("".equals(resourcePool) || (resourcePool.length() == 0)) { resourcePoolName = "Resources"; } else { resourcePoolName = env.expand(resourcePool); } vsphere.deployVm(expandedClone, expandedTemplate, linkedClone, resourcePoolName, expandedCluster, expandedDatastore, powerOn, jLogger); VSphereLogger.vsLogger(jLogger, "\""+expandedClone+"\" successfully deployed!"); IP = vsphere.getIp(vsphere.getVmByName(expandedClone), 60); if(IP!=null) { VSphereLogger.vsLogger(jLogger, "Successfully retrieved IP for \"" + expandedClone + "\" : " + IP); VSphereLogger.vsLogger(jLogger, "Exposing " + IP + " as environment variable VSPHERE_IP"); if (run instanceof AbstractBuild) { VSphereEnvAction envAction = new VSphereEnvAction(); envAction.add("VSPHERE_IP", IP); run.addAction(envAction); } return true; } else { VSphereLogger.vsLogger(jLogger, "Error: Timed out after waiting 60 seconds to get IP for \""+expandedClone+"\" "); return false; } }
Source:
public void setClassId(String name) { table_.setClassName(ClassIds.FAST_SELECT_TABLE + "_" + name); }

Target:
public void setClassId(String name) { table_.setClassName(ClassIds.FAST_SELECT_TABLE + "_" + ClassIds.idSafeString(name)); }
Source:
public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream)); try { String line; while ((line = reader.readLine()) != null) { if (line.length() != 0) { if(GdbDebugOptions.DEBUG) { GdbDebugOptions.trace(String.format( "%s %s %s", GdbPlugin.getDebugTime(), MI_TRACE_IDENTIFIER, line)); } final String finalLine = line; if (getMITracingStream() != null) { try { String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; while (message.length() > 100) { String partial = message.substring(0, 100) + "\\\n"; message = message.substring(100); getMITracingStream().write(partial.getBytes()); } getMITracingStream().write(message.getBytes()); } catch (IOException e) { setMITracingStream(null); } } processMIOutput(line); } } } catch (IOException e) { } catch (RejectedExecutionException e) { } try { fInputStream.close(); } catch (IOException e) { } }

Target:
public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream)); try { String line; while ((line = reader.readLine()) != null) { if (line.length() != 0) { if(GdbDebugOptions.DEBUG) { GdbDebugOptions.trace(String.format( "%s %s %s\n", GdbPlugin.getDebugTime(), MI_TRACE_IDENTIFIER, line)); } final String finalLine = line; if (getMITracingStream() != null) { try { String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; while (message.length() > 100) { String partial = message.substring(0, 100) + "\\\n"; message = message.substring(100); getMITracingStream().write(partial.getBytes()); } getMITracingStream().write(message.getBytes()); } catch (IOException e) { setMITracingStream(null); } } processMIOutput(line); } } } catch (IOException e) { } catch (RejectedExecutionException e) { } try { fInputStream.close(); } catch (IOException e) { } }
Source:
public RemoteXBeeDevice discoverDevice(String id) throws XBeeException { logger.debug("{}ND for device.", toString(), id); performNodeDiscovery(null, id); XBeeNetwork network = xbeeDevice.getNetwork(); RemoteXBeeDevice rDevice = null; if (deviceList != null && deviceList.size() > 0) { rDevice = deviceList.get(0); if (rDevice != null) rDevice = network.addRemoteDevice(rDevice); } return rDevice; }

Target:
public RemoteXBeeDevice discoverDevice(String id) throws XBeeException { if (!xbeeDevice.isOpen()) throw new InterfaceNotOpenException(); logger.debug("{}ND for device.", xbeeDevice.toString(), id); running = true; discovering = true; performNodeDiscovery(null, id); XBeeNetwork network = xbeeDevice.getNetwork(); RemoteXBeeDevice rDevice = null; if (deviceList != null && deviceList.size() > 0) { rDevice = deviceList.get(0); if (rDevice != null) rDevice = network.addRemoteDevice(rDevice); } return rDevice; }
Source:
public static <T extends HelixProperty> Map<PropertyKey, T> updateReloadProperties( HelixDataAccessor accessor, List<PropertyKey> reloadKeys, List<PropertyKey> cachedKeys, Map<PropertyKey, T> cachedPropertyMap) { Map<PropertyKey, T> refreshedPropertyMap = Maps.newHashMap(); List<HelixProperty.Stat> stats = accessor.getPropertyStats(cachedKeys); for (int i = 0; i < cachedKeys.size(); i++) { PropertyKey key = cachedKeys.get(i); HelixProperty.Stat stat = stats.get(i); if (stat != null) { T property = cachedPropertyMap.get(key); if (property != null && property.getBucketSize() == 0 && property.getStat().equals(stat)) { refreshedPropertyMap.put(key, property); } else { reloadKeys.add(key); } } else { LOG.warn("stat is null for key: " + key); reloadKeys.add(key); } } List<T> reloadedProperty = accessor.getProperty(reloadKeys, true); Iterator<PropertyKey> csKeyIter = reloadKeys.iterator(); for (T property : reloadedProperty) { PropertyKey key = csKeyIter.next(); if (property != null) { refreshedPropertyMap.put(key, property); } else { LOG.warn("CurrentState null for key: " + key); } } return refreshedPropertyMap; }

Target:
public static <T extends HelixProperty> Map<PropertyKey, T> updateReloadProperties( HelixDataAccessor accessor, List<PropertyKey> reloadKeys, List<PropertyKey> cachedKeys, Map<PropertyKey, T> cachedPropertyMap) { Map<PropertyKey, T> refreshedPropertyMap = Maps.newHashMap(); List<HelixProperty.Stat> stats = accessor.getPropertyStats(cachedKeys); for (int i = 0; i < cachedKeys.size(); i++) { PropertyKey key = cachedKeys.get(i); HelixProperty.Stat stat = stats.get(i); if (stat != null) { T property = cachedPropertyMap.get(key); if (property != null && property.getBucketSize() == 0 && property.getStat().equals(stat)) { refreshedPropertyMap.put(key, property); } else { reloadKeys.add(key); } } else { LOG.warn("Stat is null for key: " + key); reloadKeys.add(key); } } List<T> reloadedProperty = accessor.getProperty(reloadKeys, true); Iterator<PropertyKey> reloadKeyIter = reloadKeys.iterator(); for (T property : reloadedProperty) { PropertyKey key = reloadKeyIter.next(); if (property != null) { refreshedPropertyMap.put(key, property); } else { LOG.warn("Reload property is null for key: " + key); } } return refreshedPropertyMap; }
Source:
public String toString() { final List<String> batchNumbers = this.cdmaBatches.values().stream().map(x -> x.getBatchNumber().toString()) .collect(Collectors.toList()); return "CdmaMastSegment [mastSegmentName=" + this.mastSegmentName + ", cdmaBatches=" + String.join(",", batchNumbers) + "]"; }

Target:
public String toString() { return "CdmaMastSegment [mastSegmentName=" + this.mastSegmentName + ", cdmaBatches=" + this.cdmaBatches.keySet() + "]"; }