auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void updateSubscriptionProductMappings(Subscription sdata) { if (sdata == null) { throw new IllegalArgumentException("sdata is null"); } if (sdata.getId() == null || sdata.getId().matches("\\A\\s*\\z")) { throw new IllegalArgumentException("subscription lacks identifying information: " + sdata); } Set<String> pids = new HashSet<>(); if (sdata.getProduct() != null && sdata.getProduct().getId() != null) { pids.add(sdata.getProduct().getId()); } if (sdata.getProvidedProducts() != null) { for (ProductData pdata : sdata.getProvidedProducts()) { if (pdata != null && pdata.getId() != null) { pids.add(pdata.getId()); } } } if (sdata.getDerivedProduct() != null && sdata.getDerivedProduct().getId() != null) { pids.add(sdata.getDerivedProduct().getId()); } if (sdata.getDerivedProvidedProducts() != null) { for (ProductData pdata : sdata.getDerivedProvidedProducts()) { if (pdata != null && pdata.getId() != null) { pids.add(pdata.getId()); } } } for (String pid : pids) { if (!this.productMap.containsKey(pid)) { throw new IllegalStateException("unknown/unexpected product id: " + pid); } if (!this.productSubscriptionMap.containsKey(pid)) { throw new IllegalStateException("product=>subscription map lacks table for product: " + pid); } } for (Map.Entry<String, Set<String>> entry : this.productSubscriptionMap.entrySet()) { String pid = entry.getKey(); Set<String> sids = entry.getValue(); if (pids.contains(pid)) { sids.add(sdata.getId()); } else { sids.remove(sdata.getId()); } } }

Target:
protected void updateSubscriptionProductMappings(Subscription sdata) { if (sdata == null) { throw new IllegalArgumentException("sdata is null"); } if (StringUtils.isBlank(sdata.getId())) { throw new IllegalArgumentException("subscription lacks identifying information: " + sdata); } Set<String> pids = new HashSet<>(); if (sdata.getProduct() != null && sdata.getProduct().getId() != null) { pids.add(sdata.getProduct().getId()); } if (sdata.getProvidedProducts() != null) { for (ProductData pdata : sdata.getProvidedProducts()) { if (pdata != null && pdata.getId() != null) { pids.add(pdata.getId()); } } } if (sdata.getDerivedProduct() != null && sdata.getDerivedProduct().getId() != null) { pids.add(sdata.getDerivedProduct().getId()); } if (sdata.getDerivedProvidedProducts() != null) { for (ProductData pdata : sdata.getDerivedProvidedProducts()) { if (pdata != null && pdata.getId() != null) { pids.add(pdata.getId()); } } } for (String pid : pids) { if (!this.productMap.containsKey(pid)) { throw new IllegalStateException("unknown/unexpected product id: " + pid); } if (!this.productSubscriptionMap.containsKey(pid)) { throw new IllegalStateException("product=>subscription map lacks table for product: " + pid); } } for (Map.Entry<String, Set<String>> entry : this.productSubscriptionMap.entrySet()) { String pid = entry.getKey(); Set<String> sids = entry.getValue(); if (pids.contains(pid)) { sids.add(sdata.getId()); } else { sids.remove(sdata.getId()); } } }
Source:
public void run() { try { Thread.currentThread().setName("consumer-" + subscriptionName); start(); while (running) { consumer.consume(() -> processSignals()); } stop(); } finally { Thread.currentThread().setName("consumer-released-thread"); } }

Target:
public void run() { try { Thread.currentThread().setName("consumer-" + subscriptionName); start(); while (running) { consumer.consume(() -> processSignals()); } stop(); } finally { refreshHealthcheck(); Thread.currentThread().setName("consumer-released-thread"); } }
Source:
private String stripGitCloneCommand(String input) { if (input.startsWith(GIT_CLONE_COMMAND_PREFIX)) { return input.substring(GIT_CLONE_COMMAND_PREFIX.length()).trim(); } return input.trim(); }

Target:
private String stripGitCloneCommand(String input) { input = input.trim(); if (input.startsWith(GIT_CLONE_COMMAND_PREFIX)) { return input.substring(GIT_CLONE_COMMAND_PREFIX.length()).trim(); } return input.trim(); }
Source:
public static XMLGregorianCalendar create(org.joda.time.DateTime dateTime) { return dateTime!=null ? withTypeFactoryDo($->$.newXMLGregorianCalendar(dateTime.toGregorianCalendar())) : null; }

Target:
public static XMLGregorianCalendar create(org.joda.time.DateTime dateTime) { return dateTime!=null ? withTypeFactoryDo(factory->factory.newXMLGregorianCalendar(dateTime.toGregorianCalendar())) : null; }
Source:
protected void done() { loadingNoticePanel.setVisible(false); runJobNowButton.setEnabled(true); if(jobStatus == null) { System.out.println("null jobStatus?!"); } else if(jobStatus.isError()) { JOptionPane.showMessageDialog(frame, "Job completed with errors: " + jobStatus.getMessage()); } else { if (jobTabToRun.getClass().equals(PortJobTab.class)) { PortJobTab selectedPortJobTab = (PortJobTab) jobTabToRun; Object[] options = {"Yes", "No"}; int n = JOptionPane.showOptionDialog(frame, "Port job completed successfully. Would you like to open the destination dataset?\n", "Port Job Successful", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { Utils.openWebpage(selectedPortJobTab.getURIToSinkDataset()); } } else { JOptionPane.showMessageDialog(frame, "Job completed successfully. " + jobStatus.getMessage()); } } }

Target:
protected void done() { loadingNoticePanel.setVisible(false); progressPanel.setVisible(false); runJobNowButton.setEnabled(true); if(jobStatus == null) { System.out.println("null jobStatus?!"); } else if(jobStatus.isError()) { JOptionPane.showMessageDialog(frame, "Job completed with errors: " + jobStatus.getMessage()); } else { if (jobTabToRun.getClass().equals(PortJobTab.class)) { PortJobTab selectedPortJobTab = (PortJobTab) jobTabToRun; Object[] options = {"Yes", "No"}; int n = JOptionPane.showOptionDialog(frame, "Port job completed successfully. Would you like to open the destination dataset?\n", "Port Job Successful", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { Utils.openWebpage(selectedPortJobTab.getURIToSinkDataset()); } } else { JOptionPane.showMessageDialog(frame, "Job completed successfully. " + jobStatus.getMessage()); } } }
Source:
public Object[][] argumentCombinationsdata() { return new Object[][]{ {null, null, null, 1}, {new String[]{"UR,CR", "CR,UR"}, null, null, 0}, {new String[]{"UR,CR", "CR,UR"}, new String[]{"UY"}, null, 1}, {new String[]{"UR,CR", "CR,UR"}, null, new String[]{"AAAAA"}, 1}, {new String[]{"UR,CR", "CR,UR"}, new String[]{"CY", "CY,UY"}, null, 0}, {new String[]{"UR,CR", "CR,UR"}, null, new String[]{"AAA", "AAAAA"}, 0}, {new String[]{"UR,CR", "CR,UR"}, new String[]{"CY", "CY,UY"}, new String[]{"AAA", "AAAAA"}, 0}, }; }

Target:
public Object[][] argumentCombinationsdata() { return new Object[][]{ {null, null, null, 1}, {STG_ARRAY, null, null, 0}, {STG_ARRAY, new String[]{"UY"}, null, 1}, {STG_ARRAY, null, new String[]{"AAAAA"}, 1}, {new String[]{"UR,CR"}, new String[]{"CY,UY"}, null, 0}, {STG_ARRAY, null, new String[]{"AAA", "AAAAA"}, 0}, {STG_ARRAY, new String[]{"CY", "CY,UY"}, new String[]{"AAA", "AAAAA"}, 0}, }; }
Source:
private void refreshState(DaikinHost host) { String url = String.format("http://%s/param.csv", host.getHost()); CloseableHttpClient httpClient = HttpClients.custom().build(); List<String> results = new ArrayList<String>(); try { HttpGet httpGet = new HttpGet( url ); CloseableHttpResponse httpResponse = httpClient.execute( httpGet ); try { InputStream content = httpResponse.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { if (line != null && line.length() > 0) results.add(line.substring(0, line.length() - 1)); } } finally { httpResponse.close(); } } catch (ClientProtocolException e) { logger.error("Client protocol error attempting to request current state", e); return; } catch (IOException e) { logger.error("IO error attempting to request current state", e); return; } if (!results.get(0).equals("OK")) { logger.error("Bad connection state received: {}", results.get(0)); return; } host.setPower(results.get(1).equals("ON")); if (host.getPower()) { host.setMode(parseMode(results.get(2))); host.setFan(parseFan(results.get(4))); BigDecimal temp = parseDecimal(results.get(3)); if (!host.getMode().equals("Dry") || temp.compareTo(new BigDecimal(32)) <= 0) host.setTemp(temp); } host.setSwing(parseSwing(results.get(5))); host.setTempIn(parseDecimal(results.get(6))); host.setTimer(parseTimer(results.get(7))); host.setTempOut(parseDecimal(results.get(14))); host.setHumidityIn(parseDecimal(results.get(15))); }

Target:
private void refreshState(DaikinHost host) { String url = String.format("http://%s/param.csv", host.getHost()); CloseableHttpClient httpClient = HttpClients.custom().build(); List<String> results = new ArrayList<String>(); try { HttpGet httpGet = new HttpGet( url ); CloseableHttpResponse httpResponse = httpClient.execute( httpGet ); try { InputStream content = httpResponse.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { if (line != null && line.length() > 0) results.add(line.substring(0, line.length() - 1)); } } finally { httpResponse.close(); } } catch (ClientProtocolException e) { logger.error("Client protocol error attempting to request current state", e); return; } catch (IOException e) { logger.error("IO error attempting to request current state", e); return; } if (!results.get(0).equals("OK")) { logger.error("Bad connection state received: {}", results.get(0)); return; } host.setPower(results.get(1).equals("ON")); if (host.getPower()) { host.setMode(parseMode(results.get(2))); host.setFan(parseFan(results.get(4))); BigDecimal temp = parseDecimal(results.get(3)); if (!host.getMode().equals(DaikinMode.Dry) || temp.compareTo(new BigDecimal(32)) <= 0) host.setTemp(temp); } host.setSwing(parseSwing(results.get(5))); host.setTempIn(parseDecimal(results.get(6))); host.setTimer(parseTimer(results.get(7))); host.setTempOut(parseDecimal(results.get(14))); host.setHumidityIn(parseDecimal(results.get(15))); }
Source:
public JsonElement toJson(VideoRequest src) { JsonObject json = new JsonObject(); JsonObject requestHeader = new JsonObject(); requestHeader.addProperty("Token", src.getToken()); JsonObject query = new JsonObject(); query.addProperty("SearchPhrase", src.getSearchPhrase()); JsonObject resultOptions = new JsonObject(); resultOptions.addProperty("ItemCount", src.getItemCount()); resultOptions.addProperty("ItemStartNumber", src.getItemStartNumber()); JsonObject searchForVideosRequestBody = new JsonObject(); searchForVideosRequestBody.add("Query", query); searchForVideosRequestBody.add("ResultOptions", resultOptions); json.add("RequestHeader", requestHeader); json.add("SearchForVideosRequestBody", searchForVideosRequestBody); return json; }

Target:
public static JsonElement toJson(VideoRequest src) { JsonObject json = new JsonObject(); JsonObject requestHeader = new JsonObject(); requestHeader.addProperty("Token", src.getToken()); JsonObject query = new JsonObject(); query.addProperty("SearchPhrase", src.getSearchPhrase()); JsonObject resultOptions = new JsonObject(); resultOptions.addProperty("ItemCount", src.getItemCount()); resultOptions.addProperty("ItemStartNumber", src.getItemStartNumber()); JsonObject searchForVideosRequestBody = new JsonObject(); searchForVideosRequestBody.add("Query", query); searchForVideosRequestBody.add("ResultOptions", resultOptions); json.add("RequestHeader", requestHeader); json.add("SearchForVideosRequestBody", searchForVideosRequestBody); return json; }
Source:
public void testPrfSha256() { byte[] secret = Hex.decode("9b be 43 6b a9 40 f0 17 b1 76 52 84 9a 71 db 35".trim()); byte[] seed = Hex.decode("a0 ba 9f 93 6c da 31 18 27 a6 f7 96 ff d5 19 8c".trim()); byte[] label = "test label".getBytes(StandardCharsets.US_ASCII); byte[] expected = Hex.decode( ("e3 f2 29 ba 72 7b e1 7b" + "8d 12 26 20 55 7c d4 53" + "c2 aa b2 1d 07 c3 d4 95" + "32 9b 52 d4 e6 1e db 5a" + "6b 30 17 91 e9 0d 35 c9" + "c9 a4 6b 4e 14 ba f9 af" + "0f a0 22 f7 07 7d ef 17" + "ab fd 37 97 c0 56 4b ab" + "4f bc 91 66 6e 9d ef 9b" + "97 fc e3 4f 79 67 89 ba" + "a4 80 82 d1 22 ee 42 c5" + "a7 2e 5a 51 10 ff f7 01" + "87 34 7b 66").trim() ); byte[] actual = PseudoRandomFunction.hash(secret, label, seed, expected.length, "HmacSha256"); assertArrayEquals(expected, actual); }

Target:
public void testPrfSha256() { byte[] secret = Hex.decode("9b be 43 6b a9 40 f0 17 b1 76 52 84 9a 71 db 35"); byte[] seed = Hex.decode("a0 ba 9f 93 6c da 31 18 27 a6 f7 96 ff d5 19 8c"); byte[] label = "test label".getBytes(CharsetUtil.US_ASCII); byte[] expected = Hex.decode( "e3 f2 29 ba 72 7b e1 7b" + "8d 12 26 20 55 7c d4 53" + "c2 aa b2 1d 07 c3 d4 95" + "32 9b 52 d4 e6 1e db 5a" + "6b 30 17 91 e9 0d 35 c9" + "c9 a4 6b 4e 14 ba f9 af" + "0f a0 22 f7 07 7d ef 17" + "ab fd 37 97 c0 56 4b ab" + "4f bc 91 66 6e 9d ef 9b" + "97 fc e3 4f 79 67 89 ba" + "a4 80 82 d1 22 ee 42 c5" + "a7 2e 5a 51 10 ff f7 01" + "87 34 7b 66"); byte[] actual = PseudoRandomFunction.hash(secret, label, seed, expected.length, "HmacSha256"); assertArrayEquals(expected, actual); }
Source:
public M deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { BigDecimal amount = null; CurrencyUnit currency = null; while (parser.nextToken() != JsonToken.END_OBJECT) { final String field = parser.getCurrentName(); parser.nextToken(); if (field.equals(names.getAmount())) { amount = parser.getDecimalValue(); } else if (field.equals(names.getCurrency())) { currency = context.readValue(parser, CurrencyUnit.class); } } if (amount == null) { throw new JsonParseException(parser, format("Missing '%s' property", names.getAmount())); } if (currency == null) { throw new JsonParseException(parser, format("Missing '%s' property", names.getCurrency())); } return factory.create(amount, currency); }

Target:
public M deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { BigDecimal amount = null; CurrencyUnit currency = null; while (parser.nextToken() != JsonToken.END_OBJECT) { final String field = parser.getCurrentName(); parser.nextToken(); if (field.equals(names.getAmount())) { amount = parser.getDecimalValue(); } else if (field.equals(names.getCurrency())) { currency = context.readValue(parser, CurrencyUnit.class); } else if (field.equals(names.getFormatted())) { continue; } else if (context.isEnabled(FAIL_ON_UNKNOWN_PROPERTIES)) { throw UnrecognizedPropertyException.from(parser, MonetaryAmount.class, field, Arrays.<Object>asList(names.getAmount(), names.getCurrency(), names.getFormatted())); } else { parser.skipChildren(); } } checkPresent(parser, amount, names.getAmount()); checkPresent(parser, currency, names.getCurrency()); return factory.create(amount, currency); }
Source:
private void configureStreamGraph(final StreamGraph graph) { checkNotNull(graph); graph.setChaining(chaining); graph.setUserArtifacts(userArtifacts); graph.setTimeCharacteristic(timeCharacteristic); graph.setJobName(jobName); if (shouldExecuteInBatchMode) { if (checkpointConfig.isCheckpointingEnabled()) { LOG.info("Disabled Checkpointing. Checkpointing is not supported and not needed when executing jobs in BATCH mode."); checkpointConfig.disableCheckpointing(); } graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.POINTWISE_EDGES_PIPELINED); graph.setScheduleMode(ScheduleMode.LAZY_FROM_SOURCES_WITH_BATCH_SLOT_REQUEST); setDefaultBufferTimeout(-1); setBatchStateBackendAndTimerService(graph); } else { graph.setStateBackend(stateBackend); graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.ALL_EDGES_PIPELINED); graph.setAllVerticesInSameSlotSharingGroupByDefault(true); graph.setScheduleMode(ScheduleMode.EAGER); if (checkpointConfig.isApproximateLocalRecoveryEnabled()) { checkApproximateLocalRecoveryCompatibility(); graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.ALL_EDGES_PIPELINED_APPROXIMATE); } else { graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.ALL_EDGES_PIPELINED); } } }

Target:
private void configureStreamGraph(final StreamGraph graph) { checkNotNull(graph); graph.setChaining(chaining); graph.setUserArtifacts(userArtifacts); graph.setTimeCharacteristic(timeCharacteristic); graph.setJobName(jobName); if (shouldExecuteInBatchMode) { if (checkpointConfig.isCheckpointingEnabled()) { LOG.info("Disabled Checkpointing. Checkpointing is not supported and not needed when executing jobs in BATCH mode."); checkpointConfig.disableCheckpointing(); } graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.POINTWISE_EDGES_PIPELINED); graph.setScheduleMode(ScheduleMode.LAZY_FROM_SOURCES_WITH_BATCH_SLOT_REQUEST); setDefaultBufferTimeout(-1); setBatchStateBackendAndTimerService(graph); } else { graph.setStateBackend(stateBackend); graph.setScheduleMode(ScheduleMode.EAGER); if (checkpointConfig.isApproximateLocalRecoveryEnabled()) { checkApproximateLocalRecoveryCompatibility(); graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.ALL_EDGES_PIPELINED_APPROXIMATE); } else { graph.setGlobalDataExchangeMode(GlobalDataExchangeMode.ALL_EDGES_PIPELINED); } } }
Source:
public Value atomize() throws XPathException { if (value == null) { final Object v = attribute.getValue(); value = SaxonXPathRuleQuery.getAtomicRepresentation(v); } return value; }

Target:
public Value atomize() { if (value == null) { value = SaxonXPathRuleQuery.getAtomicRepresentation(attribute.getValue()); } return value; }
Source:
public static SchedulingPolicy map(VDSGroup entity, SchedulingPolicy template) { SchedulingPolicy model = template != null ? template : new SchedulingPolicy(); if (entity.getClusterPolicyName() != null && !entity.getClusterPolicyName().toLowerCase().equals(NONE)) { model.setPolicy(entity.getClusterPolicyName()); if (entity.getClusterPolicyProperties() != null) { model.setThresholds(new SchedulingPolicyThresholds()); String lowUtilization = entity.getClusterPolicyProperties().get(LOW_UTILIZATION); String highUtilization = entity.getClusterPolicyProperties().get(HIGH_UTILIZATION); String cpuOverCommitDurationMinutes = entity.getClusterPolicyProperties().get(CPU_OVER_COMMIT_DURATION_MINUTES); if (lowUtilization != null) { model.getThresholds().setLow(Integer.parseInt(lowUtilization)); } if (highUtilization != null) { model.getThresholds().setHigh(Integer.parseInt(highUtilization)); } if (cpuOverCommitDurationMinutes != null) { int duration = Integer.parseInt(cpuOverCommitDurationMinutes) * 60; model.getThresholds().setDuration(duration); } } } return model; }

Target:
public static SchedulingPolicy map(VDSGroup entity, SchedulingPolicy template) { SchedulingPolicy model = template != null ? template : new SchedulingPolicy(); if (entity.getClusterPolicyName() != null) { model.setPolicy(entity.getClusterPolicyName()); if (entity.getClusterPolicyProperties() != null && !entity.getClusterPolicyProperties().isEmpty()) { model.setThresholds(new SchedulingPolicyThresholds()); String lowUtilization = entity.getClusterPolicyProperties().get(LOW_UTILIZATION); String highUtilization = entity.getClusterPolicyProperties().get(HIGH_UTILIZATION); String cpuOverCommitDurationMinutes = entity.getClusterPolicyProperties().get(CPU_OVER_COMMIT_DURATION_MINUTES); if (lowUtilization != null) { model.getThresholds().setLow(Integer.parseInt(lowUtilization)); } if (highUtilization != null) { model.getThresholds().setHigh(Integer.parseInt(highUtilization)); } if (cpuOverCommitDurationMinutes != null) { int duration = Integer.parseInt(cpuOverCommitDurationMinutes) * 60; model.getThresholds().setDuration(duration); } } } return model; }
Source:
public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<ServerInventory> context) throws IOException { final byte param = input.readByte(); context.executeAsync(new ManagementRequestContext.AsyncTask<ServerInventory>() { @Override public void execute(ManagementRequestContext<ServerInventory> serverInventoryManagementRequestContext) throws Exception { try { final ServerInventory inventory = context.getAttachment(); if(param == DomainServerProtocol.PARAM_OK) { inventory.serverStarted(serverProcessName); } else { inventory.serverStartFailed(serverProcessName); } } finally { resultHandler.done(null); } } }); }

Target:
public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<ServerInventory> context) throws IOException { final byte param = input.readByte(); final String message = input.readUTF(); context.executeAsync(new ManagementRequestContext.AsyncTask<ServerInventory>() { @Override public void execute(ManagementRequestContext<ServerInventory> serverInventoryManagementRequestContext) throws Exception { try { final ServerInventory inventory = context.getAttachment(); if(param == DomainServerProtocol.PARAM_OK) { inventory.serverStarted(serverProcessName); } else { inventory.serverStartFailed(serverProcessName); } } finally { resultHandler.done(null); } } }); }
Source:
public MolecularFormulaGenerator(final IChemObjectBuilder builder, final double minMass, final double maxMass, final MolecularFormulaRange mfRange) throws CDKException { logger.info("Initiate MolecularFormulaGenerator, mass range " + minMass + "-" + maxMass); if ((minMass < 0.0) || (maxMass < 0.0)) { throw (new CDKException( "The minimum and maximum mass values must be >=0")); } if ((minMass > maxMass)) { throw (new CDKException("Minimum mass must be <= maximum mass")); } if ((mfRange == null) || (mfRange.getIsotopeCount() == 0)) { throw (new CDKException( "The MolecularFormulaRange parameter must be non-null and must contain at least one isotope")); } this.builder = builder; this.minMass = minMass; this.maxMass = maxMass; final TreeSet<IIsotope> isotopesSet = new TreeSet<IIsotope>( new IIsotopeSorterByMass()); for (IIsotope isotope : mfRange.isotopes()) { if (isotope.getExactMass() == null) throw new CDKException("The exact mass value of isotope " + isotope + " is not set"); isotopesSet.add(isotope); } isotopes = isotopesSet.toArray(new IIsotope[isotopesSet.size()]); minCounts = new int[isotopes.length]; maxCounts = new int[isotopes.length]; for (int i = 0; i < isotopes.length; i++) { minCounts[i] = mfRange.getIsotopeCountMin(isotopes[i]); maxCounts[i] = mfRange.getIsotopeCountMax(isotopes[i]); int maxCountAccordingToMass = (int) Math.floor(maxMass / isotopes[i].getExactMass()); if (maxCounts[i] > maxCountAccordingToMass) maxCounts[i] = maxCountAccordingToMass; } currentCounts = Arrays.copyOf(minCounts, minCounts.length); }

Target:
public MolecularFormulaGenerator(final IChemObjectBuilder builder, final double minMass, final double maxMass, final MolecularFormulaRange mfRange) throws CDKException { logger.info("Initiate MolecularFormulaGenerator, mass range ", minMass, "-", maxMass); if ((minMass < 0.0) || (maxMass < 0.0)) { throw (new CDKException( "The minimum and maximum mass values must be >=0")); } if ((minMass > maxMass)) { throw (new CDKException("Minimum mass must be <= maximum mass")); } if ((mfRange == null) || (mfRange.getIsotopeCount() == 0)) { throw (new CDKException( "The MolecularFormulaRange parameter must be non-null and must contain at least one isotope")); } this.builder = builder; this.minMass = minMass; this.maxMass = maxMass; final TreeSet<IIsotope> isotopesSet = new TreeSet<IIsotope>( new IIsotopeSorterByMass()); for (IIsotope isotope : mfRange.isotopes()) { if (isotope.getExactMass() == null) throw new CDKException("The exact mass value of isotope " + isotope + " is not set"); isotopesSet.add(isotope); } isotopes = isotopesSet.toArray(new IIsotope[isotopesSet.size()]); minCounts = new int[isotopes.length]; maxCounts = new int[isotopes.length]; for (int i = 0; i < isotopes.length; i++) { minCounts[i] = mfRange.getIsotopeCountMin(isotopes[i]); maxCounts[i] = mfRange.getIsotopeCountMax(isotopes[i]); int maxCountAccordingToMass = (int) Math.floor(maxMass / isotopes[i].getExactMass()); if (maxCounts[i] > maxCountAccordingToMass) maxCounts[i] = maxCountAccordingToMass; } currentCounts = Arrays.copyOf(minCounts, minCounts.length); }
Source:
public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || (getClass() != obj.getClass())) { return false; } ElasticsearchColumnHandle other = (ElasticsearchColumnHandle) obj; return Objects.equals(this.getColumnName(), other.getColumnName()) && Objects.equals(this.getOrdinalPosition(), other.getOrdinalPosition()) && Objects.equals(this.getColumnType(), other.getColumnType()) && Objects.equals(this.getColumnJsonPath(), other.getColumnJsonPath()) && Objects.equals(this.getColumnJsonType(), other.getColumnJsonType()) && Objects.equals(this.getIsList(), other.getIsList()); }

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || (getClass() != obj.getClass())) { return false; } ElasticsearchColumnHandle other = (ElasticsearchColumnHandle) obj; return Objects.equals(this.getColumnName(), other.getColumnName()) && Objects.equals(this.getColumnType(), other.getColumnType()) && Objects.equals(this.getColumnJsonPath(), other.getColumnJsonPath()) && Objects.equals(this.getColumnJsonType(), other.getColumnJsonType()) && Objects.equals(this.getOrdinalPosition(), other.getOrdinalPosition()) && Objects.equals(this.getIsList(), other.getIsList()); }
Source:
public boolean equals(Object o) { if (o == null) { return false; } else if ((o instanceof FabricWorld)) { FabricWorld other = ((FabricWorld) o); World otherWorld = other.worldRef.get(); World thisWorld = worldRef.get(); return otherWorld != null && otherWorld.equals(thisWorld); } else if (o instanceof com.sk89q.worldedit.world.World) { return ((com.sk89q.worldedit.world.World) o).getName().equals(getName()); } else { return false; } }

Target:
public boolean equals(Object o) { if ((o instanceof FabricWorld)) { FabricWorld other = ((FabricWorld) o); World otherWorld = other.worldRef.get(); World thisWorld = worldRef.get(); return otherWorld != null && otherWorld.equals(thisWorld); } else if (o instanceof com.sk89q.worldedit.world.World) { return ((com.sk89q.worldedit.world.World) o).getName().equals(getName()); } else { return false; } }
Source:
public Response<Set<String>> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException, BadRequestException { if (input == null || Strings.isNullOrEmpty(input.hashtags)) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); if (!control.canEditHashtags()) { throw new AuthException("Edit hashtags not permitted"); } ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> hashtags = new HashSet<String>(); Set<String> oldHashtags = notes.getHashtags(); if (oldHashtags != null) { hashtags.addAll(oldHashtags); } hashtags.removeAll(Arrays.asList(input.hashtags.split(","))); update.setHashtags(hashtags); update.commit(); return Response.ok(hashtags); }

Target:
public Response<Set<String>> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException, BadRequestException { if (input == null || Strings.isNullOrEmpty(input.hashtags)) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); if (!control.canEditHashtags()) { throw new AuthException("Edit hashtags not permitted"); } ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> hashtags = new HashSet<String>(); Set<String> oldHashtags = notes.getHashtags(); if (oldHashtags != null) { hashtags.addAll(oldHashtags); } hashtags.removeAll(Arrays.asList(input.hashtags.split(","))); update.setHashtags(hashtags); update.commit(); ChangeUtil.bumpRowVersionNotLastUpdatedOn(req.getChange().getId(), db.get()); return Response.ok(hashtags); }
Source:
@Override public Iterable<K> loadAllKeys() { logger.info( "Starting load all keys for Edge Mapstore" ); Stream<K> keys; try ( Connection connection = hds.getConnection(); Statement stmt = connection.createStatement() ) { connection.setAutoCommit( false ); stmt.setFetchSize( 50000 ); final ResultSet rs = stmt.executeQuery( selectAllKeysQuery ); return StreamUtil .stream( Lists.newArrayList( new KeyIterator<K>( rs, new CountdownConnectionCloser( connection, 1 ), this::mapToKey ) ) ) .peek( key -> logger.debug( "Key to load: {}", key ) ) ::iterator; } catch ( SQLException e ) { logger.error( "Unable to acquire connection load all keys" ); return null; } }

Target:
@Override public Iterable<K> loadAllKeys() { logger.info( "Starting load all keys for Edge Mapstore" ); try ( Connection connection = hds.getConnection(); Statement stmt = connection.createStatement() ) { connection.setAutoCommit( false ); stmt.setFetchSize( 50000 ); final ResultSet rs = stmt.executeQuery( selectAllKeysQuery ); return StreamUtil .stream( () -> new KeyIterator<K>( rs, new CountdownConnectionCloser( connection, 1 ), this::mapToKey ) ) .peek( key -> logger.debug( "Key to load: {}", key ) ) ::iterator; } catch ( SQLException e ) { logger.error( "Unable to acquire connection load all keys" ); return null; } }
Source:
public void init(Context context) { this.tagToRateLimiterMap = Collections.unmodifiableMap(tagToTargetRateMap.entrySet().stream() .map(e -> { String tag = e.getKey(); JobModel jobModel = ((TaskContextImpl) context.getTaskContext()).getJobModel(); int numTasks = jobModel.getContainers().values().stream() .mapToInt(cm -> cm.getTasks().size()) .sum(); Preconditions.checkArgument(e.getValue() >= numTasks, String.format("rate limit count (%d) must be greater than number of tasks (%d)", e.getValue(), numTasks)); int effectiveRate = e.getValue() / numTasks; TaskName taskName = context.getTaskContext().getTaskModel().getTaskName(); LOGGER.info(String.format("Effective rate limit for task %s and tag %s is %d", taskName, tag, effectiveRate)); return new ImmutablePair<>(tag, com.google.common.util.concurrent.RateLimiter.create(effectiveRate)); }) .collect(Collectors.toMap(ImmutablePair::getKey, ImmutablePair::getValue)) ); initialized = true; }

Target:
public void init(Context context) { this.tagToRateLimiterMap = Collections.unmodifiableMap(tagToTargetRateMap.entrySet().stream() .map(e -> { String tag = e.getKey(); JobModel jobModel = ((TaskContextImpl) context.getTaskContext()).getJobModel(); int numTasks = jobModel.getContainers().values().stream() .mapToInt(cm -> cm.getTasks().size()) .sum(); double effectiveRate = (double) e.getValue() / numTasks; TaskName taskName = context.getTaskContext().getTaskModel().getTaskName(); LOGGER.info(String.format("Effective rate limit for task %s and tag %s is %f", taskName, tag, effectiveRate)); if (effectiveRate < 1.0) { LOGGER.warn(String.format("Effective limit rate (%f) is very low. " + "Total rate limit is %d while number of tasks is %d. Consider increasing the rate limit.", effectiveRate, e.getValue(), numTasks)); } return new ImmutablePair<>(tag, com.google.common.util.concurrent.RateLimiter.create(effectiveRate)); }) .collect(Collectors.toMap(ImmutablePair::getKey, ImmutablePair::getValue)) ); initialized = true; }
Source:
private void checkForDisableBackgroundWork(JSONObject responseAsJson) { boolean disableBackgroundWork = responseAsJson.optBoolean("disable_background_work", false); HiddenPreferences.setDisableBackgroundWork(disableBackgroundWork); if (disableBackgroundWork) { WorkManager.getInstance(CommCareApplication.instance()).cancelAllWorkByTag( CommCareApplication.instance().getCurrentApp().getUniqueId()); } }

Target:
private void checkForDisableBackgroundWork(JSONObject responseAsJson) { boolean disableBackgroundWork = responseAsJson.optBoolean("disable_background_work", false); HiddenPreferences.setDisableBackgroundWorkTime(disableBackgroundWork); if (disableBackgroundWork) { WorkManager.getInstance(CommCareApplication.instance()).cancelAllWorkByTag( CommCareApplication.instance().getCurrentApp().getUniqueId()); } }
Source:
public static String formatLogMessage(String entryKind, String logEntry) throws XMLStreamException, IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(outStream); EwsUtilities.writeTraceStartElement(writer, entryKind, false); writer.writeCharacters(SystemUtils.LINE_SEPARATOR); writer.writeCharacters(logEntry); writer.writeCharacters(SystemUtils.LINE_SEPARATOR); writer.writeEndElement(); writer.writeCharacters(SystemUtils.LINE_SEPARATOR); writer.flush(); writer.close(); outStream.flush(); String formattedLogMessage = outStream.toString(); formattedLogMessage = formattedLogMessage.replaceAll("&apos;", "'"); formattedLogMessage = formattedLogMessage.replaceAll("&quot;", "\""); formattedLogMessage = formattedLogMessage.replaceAll("&gt;", ">"); formattedLogMessage = formattedLogMessage.replaceAll("&lt;", "<"); formattedLogMessage = formattedLogMessage.replaceAll("&amp;", "&"); outStream.close(); return formattedLogMessage; }

Target:
public static String formatLogMessage(String entryKind, String logEntry) throws XMLStreamException, IOException { String lineSeparator = System.getProperty("line.separator"); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(outStream); EwsUtilities.writeTraceStartElement(writer, entryKind, false); writer.writeCharacters(lineSeparator); writer.writeCharacters(logEntry); writer.writeCharacters(lineSeparator); writer.writeEndElement(); writer.writeCharacters(lineSeparator); writer.flush(); writer.close(); outStream.flush(); String formattedLogMessage = outStream.toString(); formattedLogMessage = formattedLogMessage.replaceAll("&apos;", "'"); formattedLogMessage = formattedLogMessage.replaceAll("&quot;", "\""); formattedLogMessage = formattedLogMessage.replaceAll("&gt;", ">"); formattedLogMessage = formattedLogMessage.replaceAll("&lt;", "<"); formattedLogMessage = formattedLogMessage.replaceAll("&amp;", "&"); outStream.close(); return formattedLogMessage; }
Source:
private void removeZeroConstraint(SymbolicValue sv) { PMap<Class<? extends Constraint>, Constraint> constraints = programState.getConstraints(sv); if(constraints != null) { programState = programState.addConstraints(sv, constraints.remove(ZeroConstraint.class)); } }

Target:
private void removeZeroConstraint(SymbolicValue sv) { programState = programState.removeConstraintsOnDomain(sv, ZeroConstraint.class); }
Source:
public String getDescription(Context context, boolean withStartDate) { StringBuilder detailBuilder = new StringBuilder(); if (!TextUtils.isEmpty(org)) { detailBuilder.append(org); } if (!TextUtils.isEmpty(number)) { if (detailBuilder.length() > 0) { detailBuilder.append(" | "); } detailBuilder.append(number); } if (withStartDate) { if (detailBuilder.length() > 0) { detailBuilder.append(" | "); } detailBuilder.append(getFormattedStartDate(context)); } if (detailBuilder.length() > 0) { int secondlastCharIndex = detailBuilder.length() - 2; if (detailBuilder.charAt(secondlastCharIndex) == '|') { detailBuilder.delete(secondlastCharIndex, detailBuilder.length()); } } return detailBuilder.toString(); }

Target:
public String getDescription(Context context, boolean withStartDate) { List<CharSequence> sections = new ArrayList<>(); if (!TextUtils.isEmpty(org)) { sections.add(org); } if (!TextUtils.isEmpty(number)) { sections.add(number); } if (withStartDate) { CharSequence formattedDate = getFormattedStartDate(context); if (formattedDate != null) sections.add(formattedDate.toString().toUpperCase()); } return TextUtils.join(" | ", sections); }
Source:
public void stop(StopContext context) { EmbeddedCacheManager container = this.dependencies.getCacheContainer(); CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager(container); counterManager.remove(counterConfigurationName); }

Target:
public void stop(StopContext context) { }
Source:
public void visitNode(AstNode node) { Scope currentScope = currentScope(); super.visitNode(node); if (node.is(PythonGrammar.FUNCDEF)) { createScope(node, currentScope); createFunctionParameters(node); } if (node.is(PythonGrammar.CLASSDEF)) { createScope(node, currentScope); } if (node.is(PythonGrammar.EXPRESSION_STMT)) { for (AstNode assignOperator : node.getChildren(PythonPunctuator.ASSIGN, PythonGrammar.AUGASSIGN)) { if (currentScopeRootTree().is(PythonGrammar.CLASSDEF)) { new ClassVariableAssignmentVisitor(currentScopeRootTree()).scanNode(assignOperator.getNextSibling()); } AstNode target = assignOperator.getPreviousSibling(); if (target.getTokens().size() == 1) { addWriteUsage(target.getFirstDescendant(PythonGrammar.NAME)); } } } if (node.is(PythonGrammar.GLOBAL_STMT)) { node.getChildren(PythonGrammar.NAME).forEach(name -> currentScope().addGlobalName(name.getTokenValue())); } if (node.is(PythonGrammar.NONLOCAL_STMT)) { node.getChildren(PythonGrammar.NAME).forEach(name -> currentScope().addNonlocalName(name.getTokenValue())); } }

Target:
public void visitNode(AstNode node) { Scope currentScope = currentScope(); super.visitNode(node); if (node.is(PythonGrammar.FUNCDEF)) { createScope(node, currentScope); createFunctionParameters(node); } else if (node.is(PythonGrammar.CLASSDEF)) { createScope(node, currentScope); } else if (node.is(PythonGrammar.EXPRESSION_STMT)) { for (AstNode assignOperator : node.getChildren(PythonPunctuator.ASSIGN, PythonGrammar.AUGASSIGN)) { if (currentScopeRootTree().is(PythonGrammar.CLASSDEF)) { new ClassVariableAssignmentVisitor(currentScopeRootTree()).scanNode(assignOperator.getNextSibling()); } AstNode target = assignOperator.getPreviousSibling(); if (target.getTokens().size() == 1) { addWriteUsage(target.getFirstDescendant(PythonGrammar.NAME)); } } } else if (node.is(PythonGrammar.GLOBAL_STMT)) { node.getChildren(PythonGrammar.NAME).forEach(name -> currentScope().addGlobalName(name.getTokenValue())); } else if (node.is(PythonGrammar.NONLOCAL_STMT)) { node.getChildren(PythonGrammar.NAME).forEach(name -> currentScope().addNonlocalName(name.getTokenValue())); } }
Source:
private void restoreFrom(Uri inputUri) { File currentDB = getDatabasePath(PodDBAdapter.DATABASE_NAME); try { InputStream inputStream = getContentResolver().openInputStream(inputUri); copyInputStreamToFile(inputStream, currentDB); inputStream.close(); displayImportSuccessDialog(); } catch (Exception e) { e.printStackTrace(); Snackbar.make(findViewById(R.id.import_export_layout), e.getMessage(), Snackbar.LENGTH_SHORT).show(); } }

Target:
private void restoreFrom(Uri inputUri) { File currentDB = getDatabasePath(PodDBAdapter.DATABASE_NAME); InputStream inputStream = null; try { inputStream = getContentResolver().openInputStream(inputUri); FileUtils.copyInputStreamToFile(inputStream, currentDB); displayImportSuccessDialog(); } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e)); Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show(); } finally { IOUtils.closeQuietly(inputStream); } }
Source:
public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_DEPLOYMENT_NAME); JavaArchive earLib = ShrinkWrap.create(JavaArchive.class); earLib.addClass(DeploymentModulesListTestCase.class); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "emptyJarLibResource.properties"); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "properties/nestedJarLib.properties"); ear.addAsLibraries(earLib); WebArchive war = ShrinkWrap.create(WebArchive.class, INNER_WAR_ARCHIVE_NAME); war.addClass(DeploymentModulesListTestCase.class); war.add(EmptyAsset.INSTANCE, "META-INF/example.txt"); war.add(EmptyAsset.INSTANCE, "META-INF/properties/nested.properties"); war.addAsWebInfResource(DeploymentModulesListTestCase.class.getPackage(), "web.xml", "web.xml"); JavaArchive libJar = ShrinkWrap.create(JavaArchive.class, INNER_JAR_ARCHIVE_NAME); libJar.addClass(DeploymentModulesListTestCase.class); war.addAsLibraries(libJar); ear.addAsModules(libJar, war); ear.add(new StringAsset(prepareJBossEarDeploymentStructure()),"/META-INF/jboss-deployment-structure.xml"); ear.addAsResource(EmptyAsset.INSTANCE, "emptyEarResource"); ear.addAsManifestResource(DeploymentModulesListTestCase.class.getPackage(), "application.xml", "application.xml"); return ear; }

Target:
public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_DEPLOYMENT_NAME); JavaArchive earLib = ShrinkWrap.create(JavaArchive.class); earLib.addClass(DeploymentModulesListTestCase.class); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "emptyJarLibResource.properties"); earLib.addAsManifestResource(EmptyAsset.INSTANCE, "properties/nestedJarLib.properties"); ear.addAsLibraries(earLib); WebArchive war = ShrinkWrap.create(WebArchive.class, INNER_WAR_ARCHIVE_NAME); war.addClass(DeploymentModulesListTestCase.class); war.add(EmptyAsset.INSTANCE, "META-INF/example.txt"); war.add(EmptyAsset.INSTANCE, "META-INF/properties/nested.properties"); JavaArchive libJar = ShrinkWrap.create(JavaArchive.class, INNER_JAR_ARCHIVE_NAME); libJar.addClass(DeploymentModulesListTestCase.class); war.addAsLibraries(libJar); ear.addAsModules(libJar, war); ear.add(new StringAsset(prepareJBossEarDeploymentStructure()),"/META-INF/jboss-deployment-structure.xml"); ear.addAsResource(EmptyAsset.INSTANCE, "emptyEarResource"); return ear; }
Source:
private static SweepResults getCumulativeSweepResults(TableToSweep tableToSweep, SweepResults currentIteration) { long staleValuesDeleted = tableToSweep.getStaleValuesDeletedPreviously() + currentIteration.getStaleValuesDeleted(); long cellsExamined = tableToSweep.getCellsExaminedPreviously() + currentIteration.getCellTsPairsExamined(); long minimumSweptTimestamp = Math.min( tableToSweep.getPreviousMinimumSweptTimestamp().orElse(Long.MAX_VALUE), currentIteration.getSweptTimestamp()); long timeInMillis = tableToSweep.getTimeInMillisPreviously() + currentIteration.getTimeInMillis(); return SweepResults.builder() .staleValuesDeleted(staleValuesDeleted) .cellTsPairsExamined(cellsExamined) .sweptTimestamp(minimumSweptTimestamp) .nextStartRow(currentIteration.getNextStartRow()) .timeInMillis(timeInMillis) .build(); }

Target:
private static SweepResults getCumulativeSweepResults(TableToSweep tableToSweep, SweepResults currentIteration) { return tableToSweep.getPreviousSweepResults().accumulateWith(currentIteration); }
Source:
private void runUpdate() { if (!initUpdate()) { logger.error("Failed to initialize update"); } downloadUpdateData(); downloadUpdateForApplication(); }

Target:
private void runUpdate() { if (!initUpdate()) { logger.error(ERROR_INIT_UPDATE); return; } if (!downloadUpdateData()) { logger.error(ERROR_DOWNLOAD_UPDATE_DATA); return; } if (!downloadUpdateForApplication()) { logger.error(ERROR_DOWNLOAD_UPDATE_APP); return; } }
Source:
public void testReadBytesLengthToSmall() { }

Target:
public void testReadBytesLengthToSmall() { byte[] data = new byte[]{0, 1, 2, 3}; byte[] expected = Arrays.copyOfRange(data, 0, 3); byte[] actual = IOUtility.readBytes(newInputStream(data), 3); assertArrayEquals(expected, actual); }
Source:
public void resetPassword(final String email) { restApi.resetPassword(email).enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { if (response.isSuccessful()) loginView.showToastMessage("Please check your inbox."); else loginView.showToastMessage("Faced some error please try again."); } @Override public void onFailure(Call<Void> call, Throwable t) { loginView.showToastMessage("Faced some error please try later."); } }); }

Target:
public void resetPassword(final String email) { restApi.resetPassword(email).enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { if (response.isSuccessful()) { String message = new StringBuilder().append(Resources.getSystem().getString(R.string.check_your_email_id)).append(email).toString(); ToastUtil.success(message); } else { ToastUtil.error(Resources.getSystem().getString(R.string.error_message)); } } @Override public void onFailure(Call<Void> call, Throwable t) { ToastUtil.error(t.getMessage()); } }); }
Source:
private static boolean isUsedInFunctionLike(Tree usageTree, FunctionLike functionLike) { ParameterList parameters = functionLike.parameters(); if (parameters != null && parameters.nonTuple().stream().anyMatch(p -> p.defaultValue() != null && (usageTree.equals(p.defaultValue()) || TreeUtils.hasDescendant(p.defaultValue(), t -> t.equals(usageTree))))) { return false; } if (functionLike.is(Tree.Kind.FUNCDEF)) { FunctionDef functionDef = (FunctionDef) functionLike; for (Decorator decorator : functionDef.decorators()) { if (TreeUtils.hasDescendant(decorator, t -> t.equals(usageTree))) { return false; } } } return TreeUtils.hasDescendant(functionLike, tree -> tree.equals(usageTree)); }

Target:
private static boolean isUsedInFunctionLike(Tree usageTree, FunctionLike functionLike) { ParameterList parameters = functionLike.parameters(); if (parameters != null && isUsedAsDefaultValue(usageTree, parameters)) { return false; } if (functionLike.is(Tree.Kind.FUNCDEF)) { FunctionDef functionDef = (FunctionDef) functionLike; for (Decorator decorator : functionDef.decorators()) { if (TreeUtils.hasDescendant(decorator, t -> t.equals(usageTree))) { return false; } } } return TreeUtils.hasDescendant(functionLike, tree -> tree.equals(usageTree)); }
Source:
private void addClassLiterals(ComponentManager compMgr, List<Class<?>> allClasses) { boolean validMode = GenInputsAbstract.literals_level != ClassLiteralsMode.NONE; if (GenInputsAbstract.literals_file.size() > 0 && !validMode) { System.out.println("Invalid parameter combination: specified a class literal file but --use-class-literals=NONE"); System.exit(1); } for (String filename : GenInputsAbstract.literals_file) { MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> literalmap; if (filename.equals("CLASSES")) { Collection<ClassFileConstants.ConstantSet> css = new ArrayList<ClassFileConstants.ConstantSet>(allClasses.size()); for (Class<?> clazz : allClasses) { css.add(ClassFileConstants.getConstants(clazz.getName())); } literalmap = ClassFileConstants.toMap(css); } else { literalmap = LiteralFileReader.parse(filename); } for (Class<?> cls : literalmap.keySet()) { Package pkg = (GenInputsAbstract.literals_level == ClassLiteralsMode.PACKAGE ? cls.getPackage() : null); for (PrimitiveOrStringOrNullDecl p : literalmap.getValues(cls)) { Sequence seq = Sequence.create(p); switch (GenInputsAbstract.literals_level) { case CLASS: compMgr.addClassLevelLiteral(cls, seq); break; case PACKAGE: assert pkg != null; compMgr.addPackageLevelLiteral(pkg, seq); break; case ALL: compMgr.addGeneratedSequence(seq); break; default: throw new Error("Unexpected error in GenTests -- please report"); } } } } }

Target:
private void addClassLiterals(ComponentManager compMgr, List<Class<?>> allClasses) { boolean validMode = GenInputsAbstract.literals_level != ClassLiteralsMode.NONE; if (GenInputsAbstract.literals_file.size() > 0 && !validMode) { System.out.println("Invalid parameter combination: specified a class literal file but --use-class-literals=NONE"); System.exit(1); } for (String filename : GenInputsAbstract.literals_file) { MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> literalmap; if (filename.equals("CLASSES")) { Collection<ClassFileConstants.ConstantSet> css = new ArrayList<ClassFileConstants.ConstantSet>(allClasses.size()); for (Class<?> clazz : allClasses) { css.add(ClassFileConstants.getConstants(clazz.getName())); } literalmap = ClassFileConstants.toMap(css); } else { literalmap = LiteralFileReader.parse(filename); } for (Class<?> cls : literalmap.keySet()) { Package pkg = (GenInputsAbstract.literals_level == ClassLiteralsMode.PACKAGE ? cls.getPackage() : null); for (PrimitiveOrStringOrNullDecl p : literalmap.getValues(cls)) { Sequence seq = Sequence.create(p); switch (GenInputsAbstract.literals_level) { case CLASS: compMgr.addClassLevelLiteral(cls, seq); break; case PACKAGE: assert pkg != null; compMgr.addPackageLevelLiteral(pkg, seq); break; case ALL: compMgr.addGeneratedSequence(seq); break; default: throw new Error("Unexpected error in GenTests -- please report at <LINK_0>"); } } } } }