auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static Calendar getCalendarParameter(String param) { if (param != null) { Calendar cal = Calendar.getInstance(); try { Date date = DateParser.parseW3CDateTime(param); if (date != null) { <START> cal.setTime(DateParser.parseW3CDateTime(param)); <END> return cal; } } catch (IllegalArgumentException e) { log.warn("Date should have 'YYYY-MM-DDThh:mm:ss.sTZD' format, trying to parse 'yyyy-MM-dd' format"); DateTime date = ISODateTimeFormat.date().parseDateTime(param); if (date != null) { cal.setTime(date.toDate()); return cal; } } } return null; }</code><technical_language>date instead of re-parsing? remark master</technical_language>

Target:
public static Calendar getCalendarParameter(String param) { if (param != null) { Calendar cal = Calendar.getInstance(); try { Date date = DateParser.parseW3CDateTime(param); if (date != null) { cal.setTime(date); return cal; } } catch (IllegalArgumentException e) { log.warn("Date should have 'YYYY-MM-DDThh:mm:ss.sTZD' format, trying to parse 'yyyy-MM-dd' format"); DateTime date = ISODateTimeFormat.date().parseDateTime(param); if (date != null) { cal.setTime(date.toDate()); return cal; } } } return null; }
Source:
<code>public CopyArtifact(String projectName, String parameters, BuildSelector selector, String filter, String excludes, String target, boolean flatten, boolean optional, boolean fingerprintArtifacts) { StaplerRequest req = Stapler.getCurrentRequest(); if (req!=null) { AbstractProject<?,?> p = req.findAncestorObject(AbstractProject.class); if (p != null) { ItemGroup<?> context = p.getParent(); if (projectName.indexOf('$') < 0 && Jenkins.getInstance().getItem(projectName, context, Job.class) == null) projectName = ""; } } this.project = projectName; this.parameters = Util.fixEmptyAndTrim(parameters); if (selector == null) { <START> this.selector = new StatusBuildSelector(true); <END> } else { this.selector = selector; } this.filter = Util.fixNull(filter).trim(); this.excludes = Util.fixNull(excludes).trim(); this.target = Util.fixNull(target).trim(); this.flatten = flatten ? Boolean.TRUE : null; this.optional = optional ? Boolean.TRUE : null; this.doNotFingerprintArtifacts = !fingerprintArtifacts; }</code><technical_language>@DataBoundSetter define a default for a property. [Tips](<LINK_0></technical_language>

Target:
public CopyArtifact(String projectName, String parameters, BuildSelector selector, String filter, String excludes, String target, boolean flatten, boolean optional, boolean fingerprintArtifacts) { this(projectName); setParameters(parameters); setFilter(filter); setTarget(target); setExcludes(excludes); if (selector == null) { selector = DEFAULT_BUILD_SELECTOR; } setSelector(selector); setFlatten(flatten); setOptional(optional); setFingerprintArtifacts(fingerprintArtifacts); }
Source:
<code>public void shouldFailRequestingARefund_whenChargeRefundIsFull() { Long refundAmount = defaultTestCharge.getAmount(); String externalChargeId = defaultTestCharge.getExternalChargeId(); Long chargeId = defaultTestCharge.getChargeId(); postRefundFor(externalChargeId, refundAmount, defaultTestCharge.getAmount()) .statusCode(ACCEPTED.getStatusCode()); List<Map<String, Object>> refundsFoundByChargeId = databaseTestHelper.getRefundsByChargeId(chargeId); <START> assertThat(refundsFoundByChargeId.size(), is(1)); <END> assertRefundsHistoryInDBForSuccessfulOrPartialRefund(defaultTestCharge); postRefundFor(externalChargeId, 1L, defaultTestCharge.getAmount() - refundAmount) .statusCode(BAD_REQUEST.getStatusCode()) .body("reason", is("full")) .body("message", is(format("Charge with id [%s] not available for refund.", externalChargeId))); }</code><technical_language>need this assertion</technical_language>

Target:
public void shouldFailRequestingARefund_whenChargeRefundIsFull() { Long refundAmount = defaultTestCharge.getAmount(); String externalChargeId = defaultTestCharge.getExternalChargeId(); Long chargeId = defaultTestCharge.getChargeId(); postRefundFor(externalChargeId, refundAmount, defaultTestCharge.getAmount()) .statusCode(ACCEPTED.getStatusCode()); List<Map<String, Object>> refundsFoundByChargeId = databaseTestHelper.getRefundsByChargeId(chargeId); assertThat(refundsFoundByChargeId.size(), is(1)); postRefundFor(externalChargeId, 1L, defaultTestCharge.getAmount() - refundAmount) .statusCode(BAD_REQUEST.getStatusCode()) .body("reason", is("full")) .body("message", is(format("Charge with id [%s] not available for refund.", externalChargeId))); }
Source:
<code>@Override public Token load(ClientSecret key) throws Exception { <START> return api.authorizeClientSecret(key.clientId(), key.clientSecret(), key.resource()); <END> }</code><technical_language>[the spec](<LINK_0>, scope parameter is optional. is present in ClientSecret object configuring in Azure OAuth module. Is reason is in request</technical_language>

Target:
@Override public Token load(ClientSecret key) throws Exception { return api.authorizeClientSecret(key.clientId(), key.clientSecret(), key.resource(), key.scope()); }
Source:
<code>public BinaryContent transform( Metacard metacard, String transformerShortname, Map<String, Serializable> arguments) throws CatalogTransformerException { <START> return transformOperations.transform(metacard, transformerShortname, arguments).get(0); <END> }</code><technical_language>Do need check for a non-empty list</technical_language>

Target:
public BinaryContent transform( Metacard metacard, String transformerShortname, Map<String, Serializable> arguments) throws CatalogTransformerException { List<BinaryContent> binaryContents = transformOperations.transform(metacard, transformerShortname, arguments); if (CollectionUtils.isNotEmpty(binaryContents)) { return binaryContents.get(0); } throw new CatalogTransformerException("Unable to transform metacard."); }
Source:
<code>public String getLocalAuthor(IProgressMonitor monitor) { final ICVSFile cvsFile= getCVSFile(); if (cvsFile == null) return null; final ResourceSyncInfo info= getSyncInfoForLocal(cvsFile); if (info == null) return null; final String localRevision= info.getRevision(); if (localRevision == null) return null; final ILogEntry entries[]= getLogEntries(cvsFile, monitor); if (entries == null || entries.length == 0) return null; for (ILogEntry <START> entrie : <END> entries) { try { if (localRevision.equals(entrie.getRemoteFile().getRevision())) { return entrie.getAuthor(); } }catch (TeamException e) { CVSProviderPlugin.log(e); } } return null; }</code><technical_language>entry</technical_language>

Target:
public String getLocalAuthor(IProgressMonitor monitor) { final ICVSFile cvsFile= getCVSFile(); if (cvsFile == null) return null; final ResourceSyncInfo info= getSyncInfoForLocal(cvsFile); if (info == null) return null; final String localRevision= info.getRevision(); if (localRevision == null) return null; final ILogEntry entries[]= getLogEntries(cvsFile, monitor); if (entries == null || entries.length == 0) return null; for (ILogEntry entry : entries) { try { if (localRevision.equals(entry.getRemoteFile().getRevision())) { return entry.getAuthor(); } } catch (TeamException e) { CVSProviderPlugin.log(e); } } return null; }
Source:
<code>public String toString() { <START> return "Request metadata: " + (restRequestMetadata != null ? restRequestMetadata.toString() : "null") + <END> " Request content: " + (restRequestContent != null ? restRequestContent.toString() : "null") + " Response handler: " + (restResponseHandler != null ? restResponseHandler.toString() : "null"); }</code><technical_language>StringBuilder here</technical_language>

Target:
public String toString() { return "Request metadata: " + restRequestMetadata + " Request content: " + restRequestContent + " Response handler: " + restResponseHandler; }
Source:
<code>private ArrayList<Double> findMarketPrice(ArrayList<Order> buyList, ArrayList<Order> sellList) { ArrayList<Double> <START> values = <END> new ArrayList<Double>(); int buyVolume = 0; int sellVolume = 0; int finalBuyVolume = 10000000; int finalSellVolume = 0; int totalSellVolume = -1; int buyNumber = -1, sellNumber = -1; double price = -1.0; for (int i = 0; i < buyList.size(); i++){ buyVolume += buyList.get(i).getSize(); sellVolume = 0; for (int j = 0; j < sellList.size(); j++) { sellVolume += sellList.get(j).getSize(); if (buyVolume >= sellVolume) { if ((buyVolume - sellVolume) <= (finalBuyVolume - finalSellVolume) && totalSellVolume < sellVolume && buyList.get(i).getPrice() >= sellList.get(j).getPrice()) { buyNumber = i; sellNumber = j; finalBuyVolume = buyVolume; finalSellVolume = sellVolume; price = sellList.get(sellNumber).getPrice(); totalSellVolume = sellVolume; } } } } values.add((double) buyNumber); values.add((double) sellNumber); values.add(price); values.add((double) totalSellVolume); return values; }</code><technical_language>rename this list values is holding. a programmer feel more confident in adding if needed to</technical_language>

Target:
private ArrayList<Double> findMarketPrice(ArrayList<Order> buyList, ArrayList<Order> sellList) { ArrayList<Double> marketTradeInformation = new ArrayList<Double>(); int buyVolume = 0; int sellVolume = 0; int finalBuyVolume = 10000000; int finalSellVolume = 0; int totalSellVolume = -1; int buyNumber = -1, sellNumber = -1; double price = -1.0; for (int i = 0; i < buyList.size(); i++){ buyVolume += buyList.get(i).getSize(); sellVolume = 0; for (int j = 0; j < sellList.size(); j++) { sellVolume += sellList.get(j).getSize(); if (buyVolume >= sellVolume) { if ((buyVolume - sellVolume) <= (finalBuyVolume - finalSellVolume) && totalSellVolume < sellVolume && buyList.get(i).getPrice() >= sellList.get(j).getPrice()) { buyNumber = i; sellNumber = j; finalBuyVolume = buyVolume; finalSellVolume = sellVolume; price = sellList.get(sellNumber).getPrice(); totalSellVolume = sellVolume; } } } } marketTradeInformation.add((double) buyNumber); marketTradeInformation.add((double) sellNumber); marketTradeInformation.add(price); marketTradeInformation.add((double) totalSellVolume); return values; }
Source:
<code>public final <T> void setTag(Class<T> clazz, T value) { if (clazz != value.getClass()) { throw new IllegalArgumentException("Tag value must be of type " + clazz.getName()); } if (tags == null) { <START> tags = new HashMap<>(); <END> } tags.put(clazz, value); }</code><technical_language>LinkedHashMap please <LINK_0></technical_language>

Target:
public final <T> void setTag(Class<T> clazz, T value) { if (!clazz.isAssignableFrom(value.getClass())) { throw new IllegalArgumentException("Tag value must be of type " + clazz.getName()); } if (tags == null) { tags = new LinkedHashMap<>(); } tags.put(clazz, value); }
Source:
<code>UnixDESCryptPasswordImpl(final ClearPasswordSpec spec) throws InvalidKeySpecException { <START> this.salt = (short) (ThreadLocalRandom.current().nextInt() & 0xff); <END> this.hash = generateHash(this.salt, spec.getEncodedPassword().clone()); }</code><technical_language>this be: this.salt = (short) (ThreadLocalRandom.current().nextInt() & 0xfff); i.e. 12 bits instead of 8</technical_language>

Target:
UnixDESCryptPasswordImpl(final ClearPasswordSpec spec) throws InvalidKeySpecException { this.salt = (short) (ThreadLocalRandom.current().nextInt() & 0xfff); this.hash = generateHash(this.salt, spec.getEncodedPassword().clone()); }
Source:
<code>public Date getDate(Date date, boolean floorDate) { Utils.checkState(validated, Utils.formatL("PathTemplateEL for '{}' must be validated", pathTemplate)); DateContext dc = new DateContext(date, timeZone); elVars.addContextVariable(DATE_CONTEXT, dc); try { freqEdgeElEval.eval(elVars, pathTemplate, String.class); } catch (ELEvalException ex) { <START> throw new RuntimeException("Unknown OnError value " + ex.toString(), ex); <END> } elVars.addContextVariable(DATE_CONTEXT, null); if (!dc.noDate) { int rangeEdgeCorrection = (floorDate) ? 0 : 1; for (int i = 0; i < UNITS_ORDERED.length; i++) { if (UNITS_ORDERED[i] > incrementUnit) { dc.adjusted.set(UNITS_ORDERED[i], dc.adjusted.getMinimum(UNITS_ORDERED[i])); } } dc.adjusted.set(Calendar.MILLISECOND, 0); if (dc.frequency > 1) { if (dc.frequencyUnit == 0) { throw new IllegalStateException(Utils.format( "Unknown error every() function in path template seems to have an invalid unit: {}", pathTemplate)); } int frequencyRangeEdge = (dc.adjusted.get(dc.frequencyUnit) / dc.frequency + rangeEdgeCorrection) * dc.frequency; dc.adjusted.set(dc.frequencyUnit, dc.adjusted.getMinimum(dc.frequencyUnit)); dc.adjusted.add(dc.frequencyUnit, frequencyRangeEdge); } else { dc.adjusted.add(incrementUnit, rangeEdgeCorrection); } if (!floorDate) { dc.adjusted.add(Calendar.MILLISECOND, -1); } date = dc.adjusted.getTime(); } else { date = null; } return date; }</code><technical_language>this is exception message needs change</technical_language>

Target:
public Date getDate(Date date, boolean floorDate) { Utils.checkState(validated, Utils.formatL("PathTemplateEL for '{}' must be validated", pathTemplate)); DateContext dc = new DateContext(date, timeZone); elVars.addContextVariable(DATE_CONTEXT, dc); try { freqEdgeElEval.eval(elVars, pathTemplate, String.class); } catch (ELEvalException ex) { throw new RuntimeException(Utils.format("Unexpected exception: {}", ex.toString()), ex); } elVars.addContextVariable(DATE_CONTEXT, null); if (!dc.noDate) { int rangeEdgeCorrection = (floorDate) ? 0 : 1; for (int i = 0; i < UNITS_ORDERED.length; i++) { if (UNITS_ORDERED[i] > incrementUnit) { dc.adjusted.set(UNITS_ORDERED[i], dc.adjusted.getMinimum(UNITS_ORDERED[i])); } } dc.adjusted.set(Calendar.MILLISECOND, 0); if (dc.frequency > 1) { if (dc.frequencyUnit == 0) { throw new IllegalStateException(Utils.format( "Unknown error every() function in path template seems to have an invalid unit: {}", pathTemplate)); } int frequencyRangeEdge = (dc.adjusted.get(dc.frequencyUnit) / dc.frequency + rangeEdgeCorrection) * dc.frequency; dc.adjusted.set(dc.frequencyUnit, dc.adjusted.getMinimum(dc.frequencyUnit)); dc.adjusted.add(dc.frequencyUnit, frequencyRangeEdge); } else { dc.adjusted.add(incrementUnit, rangeEdgeCorrection); } if (!floorDate) { dc.adjusted.add(Calendar.MILLISECOND, -1); } date = dc.adjusted.getTime(); } else { date = null; } return date; }
Source:
<code>public boolean equals(Object o) { if (o == this) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BinaryPredicate that = (BinaryPredicate) o; <START> return getType().equals(that.getType()); <END> }</code><technical_language>needs compare left right</technical_language>

Target:
public boolean equals(Object o) { if (o == this) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BinaryPredicate that = (BinaryPredicate) o; if (!getType().equals(that.getType())) { return false; } if (!left.equals(that.left)) { return false; } return right.equals(that.right); }
Source:
<code>private ChangeInfo toChangeInfo(ChangeData cd) throws OrmException { ChangeInfo out = new ChangeInfo(); Change in = cd.change(db); out.project = in.getProject().get(); out.branch = in.getDest().getShortName(); out.topic = in.getTopic(); out.id = in.getKey().get(); out.subject = in.getSubject(); out.status = in.getStatus(); out.owner = asAccountAttribute(in.getOwner()); out.updated = in.getLastUpdatedOn(); out._number = in.getId().get(); out._sortkey = in.getSortKey(); out.starred = user.getStarredChanges().contains(in.getId()) ? true : null; <START> out.labels = true ? labelsFor(cd) : null; <END> return out; }</code><technical_language>'out.labels = labelsFor(cd);'? In Eclipse this a warning dead code</technical_language>

Target:
private ChangeInfo toChangeInfo(ChangeData cd) throws OrmException { ChangeInfo out = new ChangeInfo(); Change in = cd.change(db); out.project = in.getProject().get(); out.branch = in.getDest().getShortName(); out.topic = in.getTopic(); out.id = in.getKey().get(); out.subject = in.getSubject(); out.status = in.getStatus(); out.owner = asAccountAttribute(in.getOwner()); out.updated = in.getLastUpdatedOn(); out._number = in.getId().get(); out._sortkey = in.getSortKey(); out.starred = user.getStarredChanges().contains(in.getId()) ? true : null; out.labels = labelsFor(cd); return out; }
Source:
<code>private PartitionStatistics getExistingPartitionStatistics(Partition partition, String partitionName) { try { PartitionStatistics statistics = delegate.getPartitionStatistics(partition.getDatabaseName(), partition.getTableName(), ImmutableSet.of(partitionName)) .get(partitionName); if (statistics == null) { throw new PrestoException( TRANSACTION_CONFLICT, format("The partition that this transaction modified was deleted in another transaction. %s %s", partition.getTableName(), partition.getValues())); } return statistics; } catch (PrestoException e) { if (e.getErrorCode().equals(HIVE_CORRUPTED_COLUMN_STATISTICS.toErrorCode())) { <START> log.error(e); <END> return PartitionStatistics.empty(); } throw e; } }</code><technical_language>perhaps, a warning</technical_language>

Target:
private PartitionStatistics getExistingPartitionStatistics(Partition partition, String partitionName) { try { PartitionStatistics statistics = delegate.getPartitionStatistics(partition.getDatabaseName(), partition.getTableName(), ImmutableSet.of(partitionName)) .get(partitionName); if (statistics == null) { throw new PrestoException( TRANSACTION_CONFLICT, format("The partition that this transaction modified was deleted in another transaction. %s %s", partition.getTableName(), partition.getValues())); } return statistics; } catch (PrestoException e) { if (e.getErrorCode().equals(HIVE_CORRUPTED_COLUMN_STATISTICS.toErrorCode())) { log.warn( e, "Corrupted statistics found when altering partition. Table: %s.%s. Partition: %s", partition.getDatabaseName(), partition.getTableName(), partition.getValues()); return PartitionStatistics.empty(); } throw e; } }
Source:
<code>public void onPartitionsLost(final Collection<TopicPartition> partitions) { log.info("at state {}: partitions lost due to missed rebalance.\n" + "\tlost active tasks: {}\n" + "\tlost assigned standby tasks: {}\n", streamThread.state(), partitions, taskManager.activeTaskIds(), taskManager.standbyTaskIds()); final long start = time.milliseconds(); try { taskManager.handleLostAll(); <START> } catch (final Exception e) { <END> throw new TaskMigratedException("Error caught during partitions lost", e); } finally { log.info("partitions lost took ms.", time.milliseconds() - start); } }</code><technical_language>Hmm.. do want capture Exceptions TaskMigratedException? I capture StreamsException TaskMigratedException thrown here</technical_language>

Target:
public void onPartitionsLost(final Collection<TopicPartition> partitions) { log.info("at state {}: partitions lost due to missed rebalance.\n" + "\tlost active tasks: {}\n" + "\tlost assigned standby tasks: {}\n", streamThread.state(), partitions, taskManager.activeTaskIds(), taskManager.standbyTaskIds()); final long start = time.milliseconds(); try { taskManager.handleLostAll(); } finally { log.info("partitions lost took ms.", time.milliseconds() - start); } }
Source:
<code>public HttpRequest filter(final HttpRequest request) throws HttpException { return request.toBuilder() <START> .replaceHeader(HttpHeaders.ACCEPT, String.format("application/json; version=%s", apiVersion)) <END> .build(); }</code><technical_language>Do want override Accept header, is? append version if missing? approaches LGTM. If for former, remove @Consumes annotations Api classes, header put this filter</technical_language>

Target:
public HttpRequest filter(final HttpRequest request) throws HttpException { Collection<String> accept = checkNotNull(request.getHeaders().get(ACCEPT), "accept header must not be null"); String versionHeader = Joiner.on("; ").join(ImmutableList.builder() .addAll(accept) .add(format("version=%s", apiVersion)) .build()); return request.toBuilder() .replaceHeader(ACCEPT, versionHeader) .build(); }
Source:
<code>public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Storing delivery for " + BlockingQueueConsumer.this); } try { if (BlockingQueueConsumer.this.abortStarted > 0) { if (!BlockingQueueConsumer.this.queue.offer(new Delivery(consumerTag, envelope, properties, body), BlockingQueueConsumer.this.shutdownTimeout, TimeUnit.MILLISECONDS)) { try { BlockingQueueConsumer.this.queue.clear(); getChannel().basicNack(envelope.getDeliveryTag(), true, true); getChannel().basicCancel(consumerTag); RabbitUtils.setPhysicalCloseRequired(true); getChannel().close(); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error performing 'basicCancel'", e); <START> } <END> } } } else { BlockingQueueConsumer.this.queue.put(new Delivery(consumerTag, envelope, properties, body)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }</code><technical_language>This is exception. bubble is? More exception basicCancel here</technical_language>

Target:
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Storing delivery for " + BlockingQueueConsumer.this); } try { if (BlockingQueueConsumer.this.abortStarted > 0) { if (!BlockingQueueConsumer.this.queue.offer(new Delivery(consumerTag, envelope, properties, body), BlockingQueueConsumer.this.shutdownTimeout, TimeUnit.MILLISECONDS)) { RabbitUtils.setPhysicalCloseRequired(true); BlockingQueueConsumer.this.queue.clear(); getChannel().basicNack(envelope.getDeliveryTag(), true, true); getChannel().basicCancel(consumerTag); try { getChannel().close(); } catch (TimeoutException e) { } } } else { BlockingQueueConsumer.this.queue.put(new Delivery(consumerTag, envelope, properties, body)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
Source:
<code>private File getTempMediaFile(int type) { try { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File outputDir; File outputFile; if (type == MEDIA_TYPE_IMAGE) { outputDir = _reactContext.getCacheDir(); outputFile = File.createTempFile("IMG_" + timeStamp, ".jpg", outputDir); } else if (type == MEDIA_TYPE_VIDEO) { <START> outputDir = _reactContext.getFilesDir(); END> outputFile = File.createTempFile("VID_" + timeStamp, ".mp4", outputDir); } else { Log.e(TAG, "Unsupported media type:" + type); return null; } return outputFile; } catch (Exception e) { Log.e(TAG, e.getMessage()); return null; } }</code><technical_language>tmp dir here? If saving videos "temp" option, I expect clean later, this line requires to</technical_language>

Target:
private File getTempMediaFile(int type) { try { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File outputDir = _reactContext.getCacheDir(); File outputFile; if (type == MEDIA_TYPE_IMAGE) { outputFile = File.createTempFile("IMG_" + timeStamp, ".jpg", outputDir); } else if (type == MEDIA_TYPE_VIDEO) { outputFile = File.createTempFile("VID_" + timeStamp, ".mp4", outputDir); } else { Log.e(TAG, "Unsupported media type:" + type); return null; } return outputFile; } catch (Exception e) { Log.e(TAG, e.getMessage()); return null; } }
Source:
<code>public void testLoginFailureWrongPassword() throws IdPClientException, AuthenticationException { Map<String, String> userProperties = new HashMap<>(); Role defaultRole = new Role("1", "admin"); User defaultUser = new User("admin", "YWRtaW4=", userProperties, Collections.singletonList(defaultRole)); LocalIdPClient localIdPClient = new LocalIdPClient(1, Collections.singletonList(defaultUser), Collections.singletonList(defaultRole)); Map<String, String> loginProperties = new HashMap<>(); loginProperties.put(IdPClientConstants.GRANT_TYPE, IdPClientConstants.PASSWORD_GRANT_TYPE); loginProperties.put(IdPClientConstants.USERNAME, "admin"); loginProperties.put(IdPClientConstants.PASSWORD, "admin2" + <START> ""); <END> Map<String, String> login = localIdPClient.login(loginProperties); Assert.assertEquals(IdPClientConstants.LoginStatus.LOGIN_FAILURE, login.get(IdPClientConstants.LOGIN_STATUS)); }</code><technical_language>this "admin2")</technical_language>

Target:
public void testLoginFailureWrongPassword() throws IdPClientException, AuthenticationException { Map<String, String> userProperties = new HashMap<>(); Role defaultRole = new Role("1", "admin"); User defaultUser = new User("admin", "YWRtaW4=", userProperties, Collections.singletonList(defaultRole)); LocalIdPClient localIdPClient = new LocalIdPClient(1, Collections.singletonList(defaultUser), Collections.singletonList(defaultRole)); Map<String, String> loginProperties = new HashMap<>(); loginProperties.put(IdPClientConstants.GRANT_TYPE, IdPClientConstants.PASSWORD_GRANT_TYPE); loginProperties.put(IdPClientConstants.USERNAME, "admin"); loginProperties.put(IdPClientConstants.PASSWORD, "admin2"); Map<String, String> login = localIdPClient.login(loginProperties); Assert.assertEquals(IdPClientConstants.LoginStatus.LOGIN_FAILURE, login.get(IdPClientConstants.LOGIN_STATUS)); }
Source:
<code><START> public String toString() { <END> String str = ""; str += super.toString(); str += "\n - Sub type = " + subType; str += "\n - Id = " + sensorId; str += "\n - Wind direction = " + windDirection; str += "\n - Wind speed = " + windSpeed; str += "\n - Average Wind speed = " + windAvSpeed; if (subType == SubType.TFA) { str += "\n - Temperature = " + temperature; str += "\n - Chill Factor = " + chillFactor; } str += "\n - Signal level = " + signalLevel; str += "\n - Battery level = " + batteryLevel; return str; }</code><technical_language>Consider refactoring this a StringBuffer for building return value. Absolutely required for this PR</technical_language>

Target:
public String toString() { StringBuilder sb = new StringBuilder(super.toString()); sb.append("\n - Sub type = ").append(subType); sb.append("\n - Id = ").append(sensorId); sb.append("\n - Wind direction = ").append(windDirection); sb.append("\n - Wind speed = ").append(windSpeed); sb.append("\n - Average Wind speed = ").append(windAvSpeed); if (subType == SubType.TFA) { sb.append("\n - Temperature = ").append(temperature); sb.append("\n - Chill Factor = ").append(chillFactor); } sb.append("\n - Signal level = ").append(signalLevel); sb.append("\n - Battery level = ").append(batteryLevel); return sb.toString(); }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Job)) { return false; } Job other = (Job) obj; if (actionType != other.actionType) { return false; } if (correlationId == null) { if (other.correlationId != null) { return false; } } else if (!correlationId.equals(other.correlationId)) { return false; } if (endTime == null) { if (other.endTime != null) { return false; } } else if (!endTime.equals(other.endTime)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (isVisible != other.isVisible) { return false; } if (jobSubjectEntities == null) { if (other.jobSubjectEntities != null) { return false; } } else if (!jobSubjectEntities.equals(other.jobSubjectEntities)) { return false; } if (lastUpdateTime == null) { if (other.lastUpdateTime != null) { return false; } } else if (!lastUpdateTime.equals(other.lastUpdateTime)) { return false; } if (ownerId == null) { if (other.ownerId != null) { return false; } } else if (!ownerId.equals(other.ownerId)) { return false; } if (startTime == null) { if (other.startTime != null) { return false; } } else if (!startTime.equals(other.startTime)) { return false; } if (status != other.status) { return false; } if (steps == null) { if (other.steps != null) { return false; } } else if (!steps.equals(other.steps)) { return false; } <START> if (external != other.external) { <END> return false; } return true; }</code><technical_language>autoCleared a part of equals</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Job)) { return false; } Job other = (Job) obj; if (actionType != other.actionType) { return false; } if (correlationId == null) { if (other.correlationId != null) { return false; } } else if (!correlationId.equals(other.correlationId)) { return false; } if (endTime == null) { if (other.endTime != null) { return false; } } else if (!endTime.equals(other.endTime)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (isVisible != other.isVisible) { return false; } if (jobSubjectEntities == null) { if (other.jobSubjectEntities != null) { return false; } } else if (!jobSubjectEntities.equals(other.jobSubjectEntities)) { return false; } if (lastUpdateTime == null) { if (other.lastUpdateTime != null) { return false; } } else if (!lastUpdateTime.equals(other.lastUpdateTime)) { return false; } if (ownerId == null) { if (other.ownerId != null) { return false; } } else if (!ownerId.equals(other.ownerId)) { return false; } if (startTime == null) { if (other.startTime != null) { return false; } } else if (!startTime.equals(other.startTime)) { return false; } if (status != other.status) { return false; } if (steps == null) { if (other.steps != null) { return false; } } else if (!steps.equals(other.steps)) { return false; } if (external != other.external) { return false; } if (autoCleared != other.autoCleared) { return false; } return true; }
Source:
<code>public final Object get(PageContext pc, Key key, Object defaultValue) { synchronized (_req) { Object value = _req.getAttribute(key.getLowerString()); if (value != null) return value; <START> Iterator<String> it = ListUtil.toIterator(_req.getAttributeNames()); <END> Collection.Key k; while (it.hasNext()) { k = KeyImpl.init(it.next()); if (key.equals(k)) return _req.getAttribute(k.getString()); } return defaultValue; } }</code><technical_language>revert change</technical_language>

Target:
public final Object get(PageContext pc, Key key, Object defaultValue) { synchronized (_req) { Object value = _req.getAttribute(key.getLowerString()); if (value != null) return value; Enumeration<String> names = _req.getAttributeNames(); Collection.Key k; while (names.hasMoreElements()) { k = KeyImpl.init(names.nextElement()); if (key.equals(k)) return _req.getAttribute(k.getString()); } return defaultValue; } }
Source:
<code>public final int delete(final String table, final String key) { try { final MongoCollection collection = database.getCollection(table); final Document q = BuilderFactory.start().add("_id", key).build(); final long res = collection.delete(q, writeConcern); if (res == 0) { System.err.println("Nothing deleted for key " + key); <START> return StatusCode.ERROR; <END> } return StatusCode.OK; } catch (final Exception e) { System.err.println(e.toString()); return StatusCode.ERROR; } }</code><technical_language>This Status.NOT_FOUND</technical_language>

Target:
public final Status delete(final String table, final String key) { try { final MongoCollection collection = database.getCollection(table); final Document q = BuilderFactory.start().add("_id", key).build(); final long res = collection.delete(q, writeConcern); if (res == 0) { System.err.println("Nothing deleted for key " + key); return Status.NOT_FOUND; } return Status.OK; } catch (final Exception e) { System.err.println(e.toString()); return Status.ERROR; } }
Source:
<code>public void setUp() throws Exception { <START> organization1.addAdmin(adminTestUser.getId()); <END> organization2.addAdmin(adminTestUser.getId()); organization2.addMember(testUser.getId()); suborg1.addAdmin(adminTestUser.getId()); suborg2.addMember(testUser.getId()); suborgNameAdmin = organization1.getName() + "/" + suborg1.getName(); suborgNameMember = organization2.getName() + "/" + suborg2.getName(); dashboard.open(adminTestUser.getName(), adminTestUser.getPassword()); }</code><technical_language>short name org in variables</technical_language>

Target:
public void setUp() throws Exception { org1.addAdmin(adminTestUser.getId()); org2.addAdmin(adminTestUser.getId()); org2.addMember(testUser.getId()); suborg1.addAdmin(adminTestUser.getId()); suborg2.addMember(testUser.getId()); suborgForAdminName = org1.getName() + "/" + suborg1.getName(); suborgForMemberName = org2.getName() + "/" + suborg2.getName(); dashboard.open(adminTestUser.getName(), adminTestUser.getPassword()); }
Source:
<code>private DBCollection getCollection(final Object obj) { if (obj == null) { <START> return null; <END> } return getCollection(obj instanceof Class ? (Class) obj : obj.getClass()); }</code><technical_language>callers assuming this method returns a non-null DBCollection, point in this check</technical_language>

Target:
public DBCollection getCollection(final Object obj) { if (obj == null) { return null; } return getCollection(obj instanceof Class ? (Class) obj : obj.getClass()); }
Source:
<code>public Set<PluginRoleConfig> pluginRoles() { <START> return roleToUsersMappings.keySet(); <END> }</code><technical_language>This keyset is mutable changes keyset changes in underlying map. if need return a copy</technical_language>

Target:
protected Set<PluginRoleConfig> pluginRoles() { return new HashSet<>(roleToUsersMappings.keySet()); }
Source:
<code>public PinotQueryGeneratorContext withFilter(String filter) { checkSupported(!hasFilter(), "There already exists a filter. Pinot doesn't support filters at multiple levels"); checkSupported(!hasAggregation(), "Pinot doesn't support filtering the results of aggregation"); checkSupported(!hasLimit(), "Pinot doesn't support filtering on top of the limit"); <START> return new PinotQueryGeneratorContext(selections, from, filter, numAggregations, <END> groupByColumns, topNColumnOrderingMap, limit, hiddenColumnSet); }</code><technical_language>param line; for other places</technical_language>

Target:
public PinotQueryGeneratorContext withFilter(String filter) { checkSupported(!hasFilter(), "There already exists a filter. Pinot doesn't support filters at multiple levels"); checkSupported(!hasAggregation(), "Pinot doesn't support filtering the results of aggregation"); checkSupported(!hasLimit(), "Pinot doesn't support filtering on top of the limit"); return new PinotQueryGeneratorContext( selections, from, Optional.of(filter), aggregations, groupByColumns, topNColumnOrderingMap, limit, variablesInAggregation, hiddenColumnSet); }
Source:
<code>public JwtIssuerValidator(String issuer) { Assert.notNull(issuer, "issuer cannot be null"); <START> Predicate<Object> testClaimValueURL = ( <END> claimValue) -> ((claimValue instanceof URL) && issuer.equals(claimValue.toString())); this.validator = new JwtClaimValidator<>(JwtClaimNames.ISS, testClaimValueURL.or(issuer::equals)); }</code><technical_language>considered java Predicate<Object> testClaimValue = (claimValue) -> claimValue != null && issuer.equals(claimValue.toString()) simplifies logic</technical_language>

Target:
public JwtIssuerValidator(String issuer) { Assert.notNull(issuer, "issuer cannot be null"); Predicate<Object> testClaimValue = (claimValue) -> (claimValue != null) && issuer.equals(claimValue.toString()); this.validator = new JwtClaimValidator<>(JwtClaimNames.ISS, testClaimValue); }
Source:
<code>public static void validate(TableConfig tableConfig, @Nullable Schema schema) { if (tableConfig.getTableType() == TableType.REALTIME) { Preconditions.checkState(schema != null, "Schema should not be null for REALTIME table"); } validateValidationConfig(tableConfig, schema); validateIngestionConfig(tableConfig.getIngestionConfig(), schema); validateTierConfigList(tableConfig.getTierConfigsList()); <START> validateIndexingConfig(tableConfig.getIndexingConfig(), schema); <END> }</code><technical_language>update description of method validate well</technical_language>

Target:
public static void validate(TableConfig tableConfig, @Nullable Schema schema) { if (tableConfig.getTableType() == TableType.REALTIME) { Preconditions.checkState(schema != null, "Schema should not be null for REALTIME table"); } validateValidationConfig(tableConfig, schema); validateIngestionConfig(tableConfig.getIngestionConfig(), schema); validateTierConfigList(tableConfig.getTierConfigsList()); validateIndexingConfig(tableConfig.getIndexingConfig(), schema); validateFieldConfigList(tableConfig.getFieldConfigList(), schema); }
Source:
<code>protected void clickXY(int x, int y) { log.debug(MessageFormat.format("Clicking on {0}", this)); notifyTable(SWT.MouseEnter); notifyTable(SWT.MouseMove); notifyTable(SWT.Activate); notifyTable(SWT.FocusIn); notifyTable(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1)); syncExec(new VoidResult() { public void run() { if (table.getSelectionCount() != 1 || <START> table.getSelection()[0].equals(widget)) <END> { table.setSelection(widget); } } }); notifyTable(SWT.Selection, createEvent()); notifyTable(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1)); notifyTable(SWT.MouseHover); notifyTable(SWT.MouseMove); notifyTable(SWT.MouseExit); notifyTable(SWT.Deactivate); notifyTable(SWT.FocusOut); log.debug(MessageFormat.format("Clicked on {0}", this)); }</code><technical_language>I meant !(equals)</technical_language>

Target:
protected void clickXY(int x, int y) { log.debug(MessageFormat.format("Clicking on {0}", this)); notifyTable(SWT.MouseEnter); notifyTable(SWT.MouseMove); notifyTable(SWT.Activate); notifyTable(SWT.FocusIn); notifyTable(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1)); syncExec(new VoidResult() { public void run() { if (table.getSelectionCount() != 1 || !table.getSelection()[0].equals(widget)) { table.setSelection(widget); } } }); notifyTable(SWT.Selection, createEvent()); notifyTable(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.BUTTON1, 1)); notifyTable(SWT.MouseHover); notifyTable(SWT.MouseMove); notifyTable(SWT.MouseExit); notifyTable(SWT.Deactivate); notifyTable(SWT.FocusOut); log.debug(MessageFormat.format("Clicked on {0}", this)); }
Source:
<code>public final boolean IsConnected() { if (sdkLevel >= SdkLevel.LEVEL_ICE_CREAM_SANDWICH) { return (connectedBluetoothSocket != null && BluetoothReflection.isBluetoothSocketConnected(connectedBluetoothSocket)); } <START> else <END> return (connectedBluetoothSocket != null); }</code><technical_language>else case curly braces for a single statement ([Google Java Style Guide](<LINK_0></technical_language>

Target:
public final boolean IsConnected() { if (sdkLevel >= SdkLevel.LEVEL_ICE_CREAM_SANDWICH) { return (connectedBluetoothSocket != null && BluetoothReflection.isBluetoothSocketConnected(connectedBluetoothSocket)); } else { return (connectedBluetoothSocket != null); } }
Source:
<code>protected AuthenticationToken createToken( final ServletRequest request, final ServletResponse response ) { if ( null != keys ) { final HttpServletRequest http = WebUtils.toHttp( request ); final Map<String, char[]> credentials = new HashMap<String, char[]>(); for ( final String k : keys ) { final String guid = http.getHeader( k ); if ( null != guid ) { <START> credentials.put( k, guid.toCharArray() ); <END> } } if ( !credentials.isEmpty() ) { return new NexusApiKeyAuthenticationToken( credentials, RemoteIPFinder.findIP( http ) ); } } return super.createToken( request, response ); }</code><technical_language>more set of credentials</technical_language>

Target:
protected AuthenticationToken createToken( final ServletRequest request, final ServletResponse response ) { if ( null != apiKeys ) { final HttpServletRequest http = WebUtils.toHttp( request ); for ( final String key : apiKeys ) { final String token = http.getHeader( key ); if ( null != token ) { return new NexusApiKeyAuthenticationToken( key, token.toCharArray(), request.getRemoteHost() ); } } } return super.createToken( request, response ); }
Source:
<code>public void test_setCursorLocationII() { Display display = new Display(); try { Point originalLocation = display.getCursorLocation(); display.addListener(SWT.Dispose, e -> display.setCursorLocation(originalLocation)); Point location = new Point(100, 100); display.setCursorLocation(location.x, location.y); drainEventQueue(display, 150); Point actual = display.getCursorLocation(); if (!BUG_492569 && <START> !wayland) { <END> if (!location.equals(actual)) { Screenshots.takeScreenshot(getClass(), testName.getMethodName()); fail("\nExpected:"+location.toString()+" Actual:"+actual.toString()); } } else { System.out.println(getClass().getName() + "#" + testName.getMethodName() + ": actual == " + actual); } } finally { display.dispose(); } }</code><technical_language>Hmm. I suggest create a wrapper function 'takeScreenshot(..)' in SwtTestUtil.java put 'if wayland' logic in instead. reason is other tests do some 'if wayland' logic, e.g is a browserTest require a 'if wayland' guard</technical_language>

Target:
public void test_setCursorLocationII() { Display display = new Display(); try { Point originalLocation = display.getCursorLocation(); display.addListener(SWT.Dispose, e -> display.setCursorLocation(originalLocation)); Point location = new Point(100, 100); display.setCursorLocation(location.x, location.y); drainEventQueue(display, 150); Point actual = display.getCursorLocation(); if (!BUG_492569 && !SwtTestUtil.isWayland) { if (!location.equals(actual)) { Screenshots.takeScreenshot(getClass(), testName.getMethodName()); fail("\nExpected:"+location.toString()+" Actual:"+actual.toString()); } } else { System.out.println(getClass().getName() + "#" + testName.getMethodName() + ": actual == " + actual); } } finally { display.dispose(); } }
Source:
<code>public String getQueryEncoding() { <START> return _queryEncoding == null ? null : _queryEncoding.toString(); <END> }</code><technical_language>_queryEncoding.name(), toString()</technical_language>

Target:
public String getQueryEncoding() { return _queryEncoding == null ? null : _queryEncoding.name(); }
Source:
<code>public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) { int created = 0; int deleted = 0; for (Notification n : notifications) { Object notifier = n.getNotifier(); <START> if (notifier instanceof DView && n.getFeatureID(DView.class) == ViewpointPackage.DVIEW__OWNED_REPRESENTATIONS) { <END> switch (n.getEventType()) { case Notification.ADD: created += 1; break; case Notification.ADD_MANY: int oldSize = ((Collection<?>) n.getOldValue()).size(); int newSize = ((Collection<?>) n.getNewValue()).size(); created += (newSize - oldSize); break; case Notification.REMOVE: created += 1; break; case Notification.REMOVE_MANY: oldSize = ((Collection<?>) n.getOldValue()).size(); newSize = ((Collection<?>) n.getNewValue()).size(); deleted += (oldSize - newSize); break; default: break; } } } if (created > 0 || deleted > 0) { Command cmd = new SendNotificationsCommand(session, created, deleted); return Options.newSome(cmd); } else { return Options.newNone(); } }</code><technical_language>if (notifier instanceof DView && n.getFeatureID(DView.class) == ViewpointPackage.DVIEW__OWNED_REPRESENTATIONS) { replaced n.getFeature() == ViewpointPackage.Literals.DVIEW__OWNED_REPRESENTATIONS, ntofier instanceof DView is more needed. I this added scope of model change trigger, filter notifications called ly notifications inspect</technical_language>

Target:
public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) { int created = 0; int deleted = 0; for (Notification n : notifications) { if (n.getFeature() == ViewpointPackage.Literals.DVIEW__OWNED_REPRESENTATIONS) { switch (n.getEventType()) { case Notification.ADD: created += 1; break; case Notification.ADD_MANY: int oldSize = ((Collection<?>) n.getOldValue()).size(); int newSize = ((Collection<?>) n.getNewValue()).size(); created += newSize - oldSize; break; case Notification.REMOVE: created += 1; break; case Notification.REMOVE_MANY: oldSize = ((Collection<?>) n.getOldValue()).size(); newSize = ((Collection<?>) n.getNewValue()).size(); deleted += oldSize - newSize; break; default: break; } } } if (created > 0 || deleted > 0) { Command cmd = new SendNotificationsCommand(session, created, deleted); return Options.newSome(cmd); } else { return Options.newNone(); } }
Source:
<code>public Collection<ServerHolder> getAllServers() { <START> final List<ServerHolder> allServers = historicals.values().stream() <END> .flatMap(Collection::stream) .collect(Collectors.toList()); allServers.addAll(realtimes); return allServers; }</code><technical_language>Suggested more old-style avoid list reallocation: java int historicalServers = historicals.values().stream().mapToInt(Collection::size).sum(); int allServers = historicalServers + realtimes.size(); List<ServerHolder> result = new ArrayList<>(allServers); historicals.values().forEach(tierServers -> result.addAll(tierServers)); result.addAll(realtimes); return result;</technical_language>

Target:
public Collection<ServerHolder> getAllServers() { final int historicalSize = historicals.values().stream().mapToInt(Collection::size).sum(); final int realtimeSize = realtimes.size(); final List<ServerHolder> allServers = new ArrayList<>(historicalSize + realtimeSize); historicals.values().forEach(allServers::addAll); allServers.addAll(realtimes); return allServers; }
Source:
<code>public Long encode(OffsetTime value) { if ( value == null ) { return null; } OffsetDateTime offsetDateTime = value.atDate( LocalDate.of( 2019, Month.JANUARY, 1 ) ); <START> return offsetDateTime.toInstant().toEpochMilli(); <END> }</code><technical_language>value.toEpochNano()? * more consistent LuceneLocalTimeFieldCodec#encode(java.time.LocalTime), LocalTime#toNanoOfDay(). * get nano precision for free, I suspect resulting long easier understand (0 epoch midnight)</technical_language>

Target:
public Long encode(OffsetTime value) { if ( value == null ) { return null; } long nod = value.toLocalTime().toNanoOfDay(); long offsetNanos = value.getOffset().getTotalSeconds() * 1000_000_000L; return nod - offsetNanos; }
Source:
<code>static List<String> buildNimbusCommands(Map conf) throws IOException { List<String> toRet = getCommonJavaParameters(conf, backtype.storm.Config.NIMBUS_CHILDOPTS); <START> File jvm = new File(new File(System.getProperty("java.home"), "bin"), "java"); <END> toRet.add(0, jvm.toString()); toRet.add("-Dlogfile.name=nimbus.log"); toRet.add("backtype.storm.daemon.nimbus"); return toRet; }</code><technical_language>switch getCommonJavaParameters buildCommandPrefix JVM a parameter passed in. I is cleaner ArrayList.add(0,jvm.toString()) forces of other parameters in ArrayList moved space</technical_language>

Target:
static List<String> buildNimbusCommands(Map conf) throws IOException { String javaHome = System.getProperty("java.home"); List<String> toRet = buildCommandPrefix(javaHome, null, conf, backtype.storm.Config.NIMBUS_CHILDOPTS); toRet.add("-Dlogfile.name=nimbus.log"); toRet.add("backtype.storm.daemon.nimbus"); return toRet; }
Source:
<code>public void execute(IProgressMonitor monitor) throws CoreException { Git repoTree; if (paths != null) { for (IResource res : resources) { <START> repoTree = new Git(getRepository(res)); <END> repoTree.clean().setPaths(paths).call(); } } else { for (IResource res : resources) { repoTree = new Git(getRepository(res)); repoTree.clean().call(); } } }</code><technical_language>get NPE if getRepository() return null (when resource in project shared git)</technical_language>

Target:
public void execute(IProgressMonitor monitor) throws CoreException { Git repoTree; if (resources.length > 0) { if (paths != null) { for (IResource res : resources) { repoTree = new Git(getRepository(res)); repoTree.clean().setPaths(paths).call(); } } else { for (IResource res : resources) { repoTree = new Git(getRepository(res)); repoTree.clean().call(); } } } }
Source:
<code>public boolean canStart(String line, int lineOffset) { blockLineCount = 0; listState = null; matcher = LIST_PATTERN.matcher(line); matcher.region(lineOffset, line.length()); <START> final boolean <END> matches = matcher.matches(); if (matches) { String listSpec = matcher.group(1); if (listSpec.charAt(0) == '-') { int level = calculateLevel(listSpec); if (level > 1) { return false; } } } return matches; }</code><technical_language>need for final</technical_language>

Target:
public boolean canStart(String line, int lineOffset) { blockLineCount = 0; listState = null; matcher = LIST_PATTERN.matcher(line); matcher.region(lineOffset, line.length()); boolean matches = matcher.matches(); if (matches) { String listSpec = matcher.group(1); if (listSpec.charAt(0) == '-') { int level = calculateLevel(listSpec); if (level > 1) { return false; } } } return matches; }