auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void initTrackerServers(List<TrackerServer> serverList) { TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024, true, false)); pipeline.addLast("objectEncoder", new GranitProtocolEncoder()); pipeline.addLast("objectDecoder", new GranitProtocolDecoder(GranitProtocol.this)); } }; server.setEndianness(ByteOrder.LITTLE_ENDIAN); serverList.add(server); }

Target:
public void initTrackerServers(List<TrackerServer> serverList) { TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); pipeline.addLast("objectEncoder", new GranitProtocolEncoder()); pipeline.addLast("objectDecoder", new GranitProtocolDecoder(GranitProtocol.this)); } }; server.setEndianness(ByteOrder.LITTLE_ENDIAN); serverList.add(server); }
Source:
public API(String name, String context) { super(name); setContext(context); restUtils = new RESTUtils(); }

Target:
public API(String name, String context) { super(name); setContext(context); }
Source:
public void handle(FilterResult result, Message message, Subscription subscription) { if (result.isFiltered()) { if (logger.isDebugEnabled()) { logger.debug("Message filtered for subscription {}", subscription.getQualifiedName(), result); } offsetQueue.offerCommittedOffset(SubscriptionPartitionOffset.subscriptionPartitionOffset(message, subscription)); updateMetrics(message, subscription); trackers.get(subscription).logFiltered(toMessageMetadata(message, subscription), result.getFilterType().get()); consumerRateLimiter.acquireFiltered(); } }

Target:
public void handle(FilterResult result, Message message, Subscription subscription) { if (result.isFiltered()) { if (logger.isDebugEnabled()) { logger.debug("Message filtered for subscription {}", subscription.getQualifiedName(), result); } offsetQueue.offerCommittedOffset(SubscriptionPartitionOffset.subscriptionPartitionOffset(message, subscription)); updateMetrics(message, subscription); if(subscription.isTrackingEnabled()) { trackers.get(subscription).logFiltered(toMessageMetadata(message, subscription), result.getFilterType().get()); } consumerRateLimiter.acquireFiltered(); } }
Source:
public List<String> getLZOsOlderThan(int daysAgo) throws IOException { List<String> out = new ArrayList<String>(); List<Long> hourDirs = new ArrayList<Long>(); int nFiles = 0; FileStatus[] stats = getFileSystem().listStatus(new Path(HadoopLogsConfigs.getMapreduceInputPrefix())); Long ninetyDaysAgoLong = StaticDateTimeUtils.dateTimeToHourLong( StaticDateTimeUtils.nowDateTime( true).minusDays(daysAgo)); for (FileStatus stat : stats) { try { String pathStr = pathTailString(stat); long hourLong = Long.parseLong(pathStr); if (hourLong < ninetyDaysAgoLong) { nFiles++; hourDirs.add(hourLong); } } catch (Exception ex) { continue; } } Collections.sort(hourDirs); for (Long hourLong : hourDirs) { String pathStr = StaticFileUtils.joinPath(HadoopLogsConfigs.getMapreduceInputPrefix(), hourLong.toString()); out.add(pathStr); } return out; }

Target:
public List<String> getLZOsOlderThan(int daysAgo) throws IOException { List<String> out = new ArrayList<String>(); List<Long> hourDirs = new ArrayList<Long>(); int nFiles = 0; FileStatus[] stats = getFileSystem().listStatus(new Path(HadoopLogsConfigs.getMapreduceInputPrefix())); Long daysAgoLimit = StaticDateTimeUtils.dateTimeToHourLong( StaticDateTimeUtils.nowDateTime( true).minusDays(daysAgo)); for (FileStatus stat : stats) { try { String pathStr = pathTailString(stat); long hourLong = Long.parseLong(pathStr); if (hourLong < daysAgoLimit) { nFiles++; hourDirs.add(hourLong); } } catch (Exception ex) { continue; } } Collections.sort(hourDirs); for (Long hourLong : hourDirs) { String pathStr = StaticFileUtils.joinPath(HadoopLogsConfigs.getMapreduceInputPrefix(), hourLong.toString()); out.add(pathStr); } return out; }
Source:
public String getModuleName() { if (moduleAttribute == null) return null; return moduleAttribute.module_name; }

Target:
public String getModuleName() { return classDef.getModuleName(); }
Source:
private BigDecimal fromDenonValue(String string) { BigDecimal value = new BigDecimal(string); if (value.compareTo(new BigDecimal("99")) == 1 || (string.startsWith("0") && string.length() > 2)) { value = value.divide(new BigDecimal("10")); } return value; }

Target:
private BigDecimal fromDenonValue(String string) { BigDecimal value = new BigDecimal(string); if (value.compareTo(NINETYNINE) == 1 || (string.startsWith("0") && string.length() > 2)) { value = value.divide(BigDecimal.TEN); } return value; }
Source:
public Document getPolicyDocumentByPatientId(String patientId) { LOG.info("Begin AdapterPAPImpl.getPolicyDocument(...)"); Document document = new Document(); try { DocumentQueryParams params = new DocumentQueryParams(); LOG.debug("patientid:" + patientId); params.setPatientId(patientId); List<String> classCodeValues = new ArrayList<>(); classCodeValues.add(AdapterPAPConstants.DOCUMENT_CLASS_CODE); params.setClassCodes(classCodeValues); DocumentService service = new DocumentService(); List<Document> docs = service.documentQuery(params); int docsSize = 0; if (!CollectionUtils.isEmpty(docs)){ docsSize = docs.size(); document = docs.get(0); } LOG.debug("Document size: {}", docsSize); } catch (Exception ex) { LOG.error("Exception occured while retrieving documents: {}", ex.getLocalizedMessage(), ex); } LOG.info("End AdapterPAPImpl.getPolicyDocument(...)"); return document; }

Target:
public Document getPolicyDocumentByPatientId(String patientId) { LOG.info("Begin AdapterPAPImpl.getPolicyDocument(...)"); Document document = new Document(); try { DocumentQueryParams params = new DocumentQueryParams(); LOG.debug("patientid:" + patientId); params.setPatientId(patientId); List<String> classCodeValues = new ArrayList<>(); classCodeValues.add(AdapterPAPConstants.DOCUMENT_CLASS_CODE); params.setClassCodes(classCodeValues); DocumentService service = new DocumentService(); List<Document> docs = service.documentQuery(params); int docsSize = 0; if (CollectionUtils.isNotEmpty(docs)){ docsSize = docs.size(); document = docs.get(0); } LOG.debug("Document size: {}", docsSize); } catch (Exception ex) { LOG.error("Exception occured while retrieving documents: {}", ex.getLocalizedMessage(), ex); } LOG.info("End AdapterPAPImpl.getPolicyDocument(...)"); return document; }
Source:
protected Object setSkipRemoteGetsAndInvokeNextForManyEntriesCommand(InvocationContext ctx, WriteCommand command, CompletionStage<Void> delay) { if (delay != null) { return asyncValue(delay).thenApply(ctx, command, (rCtx, rCommand, rValue) -> invokeNextAndHandle(ctx, command, handleManyWriteReturn)); } return invokeNextAndHandle(ctx, command, handleManyWriteReturn); }

Target:
protected Object setSkipRemoteGetsAndInvokeNextForManyEntriesCommand(InvocationContext ctx, WriteCommand command, CompletionStage<Void> delay) { return makeStage(asyncInvokeNext(ctx, command, delay)).andHandle(ctx, command, handleManyWriteReturn); }
Source:
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; }

Target:
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; }
Source:
public void updateInPerspective(@NotNull ActionEvent e) { CurrentProject project = appContext.getCurrentProject(); if (project == null || !"maven".equals(project.getRootProject().getType())) { e.getPresentation().setEnabledAndVisible(false); return; } Selection<?> selection = projectExplorer.getSelection(); if (selection == null) { e.getPresentation().setEnabledAndVisible(false); return; } e.getPresentation().setVisible(true); e.getPresentation().setEnabled(selection.isSingleSelection() && (selection.getHeadElement() instanceof SourceFolderNode || selection.getHeadElement() instanceof PackageNode)); }

Target:
public void updateInPerspective(@NotNull ActionEvent e) { CurrentProject project = appContext.getCurrentProject(); if (project == null || !MAVEN.equals(project.getRootProject().getType())) { e.getPresentation().setEnabledAndVisible(false); return; } Selection<?> selection = projectExplorer.getSelection(); if (selection == null) { e.getPresentation().setEnabledAndVisible(false); return; } e.getPresentation().setVisible(true); e.getPresentation().setEnabled(selection.isSingleSelection() && (selection.getHeadElement() instanceof SourceFolderNode || selection.getHeadElement() instanceof PackageNode)); }
Source:
public void getConditionByUuid_shouldFindConditionGivenValidUuid() { executeDataSet(CONDITION_XML); String uuid="2cc6880e-2c46-15e4-9038-a6c5e4d22fb7"; String clinical_status = "INACTIVE"; String verification_status = "PROVISIONAL"; expectedException = ExpectedException.none(); Condition condition = conditionService.getConditionByUuid(uuid); Assert.assertEquals(clinical_status, condition.getClinicalStatus().toString()); Assert.assertEquals(verification_status, condition.getVerificationStatus().toString()); }

Target:
public void getConditionByUuid_shouldFindConditionGivenValidUuid() { String uuid="2cc6880e-2c46-15e4-9038-a6c5e4d22fb7"; Condition condition = conditionService.getConditionByUuid(uuid); Assert.assertEquals(uuid, condition.getUuid()); }
Source:
public ValidationResult validate(Object value) { ValidationResult result = new ValidationResult(); if (value != null && ((value instanceof String && !value.equals("")) || value instanceof Integer)) { Integer intValue = value instanceof String ? IntegerCompat.tryParse((String) value) : (Integer) value; String msg = ""; String prefixMsg = ConstantsManager.getInstance().getConstants().thisFieldMustContainIntegerNumberInvalidReason(); if (intValue == null) { result.setSuccess(false); msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberBetweenInvalidReason(prefixMsg, getMinimum(), getMaximum()); result.getReasons().add(msg); } else if (intValue < getMinimum() || intValue > getMaximum()) { if (getMinimum() != Integer.MIN_VALUE && getMaximum() != Integer.MAX_VALUE) { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberBetweenInvalidReason(prefixMsg, getMinimum(), getMaximum()); } else if (getMinimum() != Integer.MIN_VALUE) { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberGreaterInvalidReason(prefixMsg, getMinimum()); } else if (getMaximum() != Integer.MAX_VALUE) { if (getMaximum() == 0) { msg = ConstantsManager.getInstance().getConstants().virtualDiskMaxSizeReached(); } else { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberLessInvalidReason(prefixMsg, getMaximum()); } } result.setSuccess(false); result.getReasons().add(msg); } } return result; }

Target:
public ValidationResult validate(Object value) { ValidationResult result = new ValidationResult(); if (value != null && ((value instanceof String && !value.equals("")) || value instanceof Integer)) { Integer intValue = value instanceof String ? IntegerCompat.tryParse((String) value) : (Integer) value; String msg = ""; String prefixMsg = ConstantsManager.getInstance().getConstants().thisFieldMustContainIntegerNumberInvalidReason(); if (intValue == null) { result.setSuccess(false); msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberBetweenInvalidReason(prefixMsg, getMinimum(), getMaximum()); result.getReasons().add(msg); } else if (intValue < getMinimum() || intValue > getMaximum()) { if (getMinimum() != Integer.MIN_VALUE && getMaximum() != Integer.MAX_VALUE) { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberBetweenInvalidReason(prefixMsg, getMinimum(), getMaximum()); } else if (getMinimum() != Integer.MIN_VALUE) { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberGreaterInvalidReason(prefixMsg, getMinimum()); } else if (getMaximum() != Integer.MAX_VALUE) { msg = ConstantsManager.getInstance() .getMessages() .integerValidationNumberLessInvalidReason(prefixMsg, getMaximum()); } result.setSuccess(false); result.getReasons().add(msg); } } return result; }
Source:
public synchronized IncrementalProjectBuilder getBuilder(IBuildConfiguration config) { synchronized (builderLock) { if (builders != null && supportsConfigs()) return builders.get(config); return builder; } }

Target:
public IncrementalProjectBuilder getBuilder(IBuildConfiguration config) { synchronized (builderLock) { if (builders != null && supportsConfigs()) return builders.get(config); return builder; } }
Source:
public void testInputOutputBindingOrder() { ConfigurableApplicationContext applicationContext = SpringApplication.run(TestSource.class, "--server.port=-1", "--spring.cloud.stream.defaultBinder=mock"); @SuppressWarnings("rawtypes") Binder binder = applicationContext.getBean(BinderFactory.class).getBinder(null, MessageChannel.class); Processor processor = applicationContext.getBean(Processor.class); verify(binder).bindConsumer(eq("input"), isNull(), eq(processor.input()), Mockito.any()); SomeLifecycle someLifecycle = applicationContext.getBean(SomeLifecycle.class); assertThat(someLifecycle.isRunning()); applicationContext.close(); assertThat(someLifecycle.isRunning()).isFalse(); applicationContext.close(); }

Target:
public void testInputOutputBindingOrder() { ConfigurableApplicationContext applicationContext = SpringApplication.run(TestSource.class, "--spring.cloud.stream.defaultBinder=mock"); @SuppressWarnings("rawtypes") Binder binder = applicationContext.getBean(BinderFactory.class).getBinder(null, MessageChannel.class); Processor processor = applicationContext.getBean(Processor.class); verify(binder).bindConsumer(eq("input"), isNull(), eq(processor.input()), Mockito.any()); SomeLifecycle someLifecycle = applicationContext.getBean(SomeLifecycle.class); assertThat(someLifecycle.isRunning()); applicationContext.close(); assertThat(someLifecycle.isRunning()).isFalse(); applicationContext.close(); }
Source:
public void set(TypedHistogram value) { if (value instanceof SingleTypedHistogram) { typedHistogram = (SingleTypedHistogram) value; } else { slowPathSet(value); } }

Target:
public void set(TypedHistogram value) { checkArgument(value instanceof SingleTypedHistogram, "set must be called with class type % only. Received %s", this.getClass(), value.getClass()); typedHistogram = (SingleTypedHistogram) value; }
Source:
private void rollbackCoveredTx(ExchangeActions exchActions) { Set<Integer> cachesToStop; if (!exchActions.cacheGroupsToStop().isEmpty() || !exchActions.cacheStopRequests().isEmpty()) { cachesToStop = new HashSet<>(); for (ExchangeActions.CacheGroupActionData act : exchActions.cacheGroupsToStop()) { @Nullable CacheGroupContext grpCtx = context().cache().cacheGroup(act.descriptor().groupId()); if (grpCtx != null && grpCtx.sharedGroup()) cachesToStop.addAll(grpCtx.cacheIds()); } for (ExchangeActions.CacheActionData act : exchActions.cacheStopRequests()) cachesToStop.add(act.descriptor().cacheId()); if (!cachesToStop.isEmpty()) { IgniteTxManager tm = context().tm(); Collection<IgniteInternalTx> active = tm.activeTransactions(); GridCompoundFuture<IgniteInternalTx, IgniteInternalTx> compFut = new GridCompoundFuture<>(); for (IgniteInternalTx tx : active) { for (IgniteTxEntry e : tx.allEntries()) { if (cachesToStop.contains(e.context().cacheId())) { compFut.add(tx.rollbackAsync()); break; } } } compFut.markInitialized(); try { compFut.get(); } catch (IgniteCheckedException e) { U.error(log, "Error occured during tx rollback.", e); } } } }

Target:
private void rollbackCoveredTx(ExchangeActions exchActions) { if (!exchActions.cacheGroupsToStop().isEmpty() || !exchActions.cacheStopRequests().isEmpty()) { Set<Integer> cachesToStop = new HashSet<>(); for (ExchangeActions.CacheGroupActionData act : exchActions.cacheGroupsToStop()) { @Nullable CacheGroupContext grpCtx = context().cache().cacheGroup(act.descriptor().groupId()); if (grpCtx != null && grpCtx.sharedGroup()) cachesToStop.addAll(grpCtx.cacheIds()); } for (ExchangeActions.CacheActionData act : exchActions.cacheStopRequests()) cachesToStop.add(act.descriptor().cacheId()); if (!cachesToStop.isEmpty()) { IgniteTxManager tm = context().tm(); tm.rollbackTransactionsForCaches(cachesToStop); } } }
Source:
private static Object getCellValueAsObject(final Workbook workbook, final Cell cell) { if (cell == null) { return null; } final Object result; switch (cell.getCellType()) { case BLANK: case _NONE: result = null; break; case BOOLEAN: result = Boolean.valueOf(cell.getBooleanCellValue()); break; case ERROR: String errorResult; try { errorResult = FormulaError.forInt(cell.getErrorCellValue()).getString(); } catch (final RuntimeException e) { logger .debug("Getting error code for ({},{}) failed!: {}", cell.getRowIndex(), cell.getColumnIndex(), e.getMessage()); if (cell instanceof XSSFCell) { errorResult = ((XSSFCell) cell).getErrorCellString(); } else { logger .error("Couldn't handle unexpected error scenario in cell: (" + cell.getRowIndex() + "," + cell.getColumnIndex() + ")", e); throw e; } } result = errorResult; break; case FORMULA: result = getFormulaCellValueAsObject(workbook, cell); break; case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { result = cell.getDateCellValue(); } else { result = getDoubleAsNumber(cell.getNumericCellValue()); } break; case STRING: result = cell.getRichStringCellValue().getString(); break; default: throw new IllegalStateException("Unknown cell type: " + cell.getCellType()); } logger.debug("cell ({},{}) resolved to value: {}", cell.getRowIndex(), cell.getColumnIndex(), result); return result; }

Target:
private static Object getCellValueAsObject(final Workbook workbook, final Cell cell) { if (cell == null) { return null; } final Object result; switch (cell.getCellType()) { case BLANK: case _NONE: result = null; break; case BOOLEAN: result = Boolean.valueOf(cell.getBooleanCellValue()); break; case ERROR: result = getErrorResult(cell); break; case FORMULA: result = getFormulaCellValueAsObject(workbook, cell); break; case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { result = cell.getDateCellValue(); } else { result = getDoubleAsNumber(cell.getNumericCellValue()); } break; case STRING: result = cell.getRichStringCellValue().getString(); break; default: throw new IllegalStateException("Unknown cell type: " + cell.getCellType()); } logger.debug("cell ({},{}) resolved to value: {}", cell.getRowIndex(), cell.getColumnIndex(), result); return result; }
Source:
private void transitionSlotToAllocated(DeclarativeTaskManagerSlot slot, JobID jobId) { Preconditions.checkNotNull(slot); Preconditions.checkState(slot.getState() == SlotState.PENDING); Preconditions.checkState(jobId.equals(slot.getJobId())); slotStatusUpdateListener.notifySlotStatusChange(slot, SlotState.PENDING, SlotState.ALLOCATED, jobId); slot.completeAllocation(); }

Target:
private void transitionSlotToAllocated(DeclarativeTaskManagerSlot slot, JobID jobId) { Preconditions.checkNotNull(slot); Preconditions.checkState(slot.getState() == SlotState.PENDING); Preconditions.checkState(jobId.equals(slot.getJobId())); slot.completeAllocation(); slotStatusUpdateListeners.notifySlotStatusChange(slot, SlotState.PENDING, SlotState.ALLOCATED, jobId); }
Source:
public ProductItem(int id, @Nullable String description, @Nullable String softwareDescriptionId, @Nullable SoftwareDescription softwareDescription) { this.id = checkNotNull(id, "id"); this.description = description; this.softwareDescriptionId = softwareDescriptionId; this.softwareDescription = softwareDescription; }

Target:
public ProductItem(int id, @Nullable String description, @Nullable String softwareDescriptionId, @Nullable SoftwareDescription softwareDescription) { this.id = id; this.description = description; this.softwareDescriptionId = softwareDescriptionId; this.softwareDescription = softwareDescription; }
Source:
protected void readOsSection(XmlNode section) { _vm.getStaticData().setId(new Guid(section.Attributes.get("ovf:id").getValue())); XmlNode node = section.SelectSingleNode("Description"); if (node.InnerText.equals(6)) { node.InnerText = "0"; } if (node != null) { _vm.getStaticData().setOsId(osRepository.getOsIdByUniqueName(node.InnerText)); } }

Target:
protected void readOsSection(XmlNode section) { _vm.getStaticData().setId(new Guid(section.Attributes.get("ovf:id").getValue())); XmlNode node = section.SelectSingleNode("Description"); if (node.InnerText.equals(String.valueOf(OsRepository.OLD_OTHER_ID))) { node.InnerText = String.valueOf(OsRepository.DEFAULT_OS); } if (node != null) { _vm.getStaticData().setOsId(osRepository.getOsIdByUniqueName(node.InnerText)); } }
Source:
@Override public Expression implement(RexToLixTranslator translator, Expression inputEnumerable, RexCall call, PhysType inputPhysType, PhysType outputPhysType) { Expression intervalExpression = translator.translate(call.getOperands().get(1)); RexCall descriptor = (RexCall) call.getOperands().get(0); List<Expression> translatedOperands = new ArrayList<>(); final ParameterExpression parameter = Expressions.parameter(Primitive.box(inputPhysType.getJavaRowType()), "_input"); Expression wmColExpr = inputPhysType.fieldReference(parameter, ((RexInputRef) descriptor.getOperands().get(0)).getIndex(), outputPhysType.getJavaFieldType( inputPhysType.getRowType().getFieldCount())); translatedOperands.add(wmColExpr); translatedOperands.add(intervalExpression); final Expression offsetExpr = call.getOperands().size() > 2 ? translator.translate(call.getOperands().get(2)) : Expressions.constant(0, long.class); translatedOperands.add(offsetExpr); return Expressions.call( BuiltInMethod.TUMBLING.method, inputEnumerable, EnumUtils.tumblingWindowSelector( inputPhysType, outputPhysType, translatedOperands.get(0), translatedOperands.get(1), translatedOperands.get(2))); }

Target:
@Override public Expression implement(RexToLixTranslator translator, Expression inputEnumerable, RexCall call, PhysType inputPhysType, PhysType outputPhysType) { Expression intervalExpression = translator.translate(call.getOperands().get(1)); RexCall descriptor = (RexCall) call.getOperands().get(0); final ParameterExpression parameter = Expressions.parameter(Primitive.box(inputPhysType.getJavaRowType()), "_input"); Expression wmColExpr = inputPhysType.fieldReference(parameter, ((RexInputRef) descriptor.getOperands().get(0)).getIndex(), outputPhysType.getJavaFieldType( inputPhysType.getRowType().getFieldCount())); final Expression offsetExpr = call.getOperands().size() > 2 ? translator.translate(call.getOperands().get(2)) : Expressions.constant(0, long.class); return Expressions.call( BuiltInMethod.TUMBLING.method, inputEnumerable, EnumUtils.tumblingWindowSelector( inputPhysType, outputPhysType, wmColExpr, intervalExpression, offsetExpr)); }
Source:
public void testConnectUnknownMode() throws Exception { PowerMockito.doReturn(XBeeMode.UNKNOWN).when(xbeeDevice, "determineConnectionMode"); try { xbeeDevice.connect(); } catch (XBeeException e) { fail("This exception shouldn't be thrown now."); } catch (InvalidOperatingModeException e) { } assertEquals(xbeeDevice.getOperatingMode(), XBeeMode.UNKNOWN); }

Target:
public void testConnectUnknownMode() throws Exception { PowerMockito.doReturn(OperatingMode.UNKNOWN).when(xbeeDevice, "determineConnectionMode"); try { xbeeDevice.open(); } catch (XBeeException e) { fail("This exception shouldn't be thrown now."); } catch (InvalidOperatingModeException e) { } assertFalse(xbeeDevice.isOpen()); assertFalse(dataReader.isRunning()); assertEquals(xbeeDevice.getOperatingMode(), OperatingMode.UNKNOWN); }
Source:
private void updateTrigger(Trigger t, EncodingType encType) throws TriggerLoaderException { String json = JSONUtils.toJSON(t.toJson()); byte[] data = null; try { byte[] stringData = json.getBytes("UTF-8"); data = stringData; if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } logger.debug("NumChars: " + json.length() + " UTF-8:" + stringData.length + " Gzip:" + data.length); } catch (IOException e) { logger.error("Trigger encoding fails", e); throw new TriggerLoaderException("Error encoding the trigger " + t.toString()); } try { int updates = dbOperator.update(UPDATE_TRIGGER, t.getSource(), t.getLastModifyTime(), encType.getNumVal(), data, t.getTriggerId()); if (updates == 0) { throw new TriggerLoaderException("No trigger has been updated."); } } catch (SQLException ex) { throw new TriggerLoaderException("DB Trigger update failed. "); } }

Target:
private void updateTrigger(Trigger t, EncodingType encType) throws TriggerLoaderException { String json = JSONUtils.toJSON(t.toJson()); byte[] data = null; try { byte[] stringData = json.getBytes("UTF-8"); data = stringData; if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } logger.debug("NumChars: " + json.length() + " UTF-8:" + stringData.length + " Gzip:" + data.length); } catch (IOException e) { logger.error("Trigger encoding fails", e); throw new TriggerLoaderException("Error encoding the trigger " + t.toString(), e); } try { int updates = dbOperator.update(UPDATE_TRIGGER, t.getSource(), t.getLastModifyTime(), encType.getNumVal(), data, t.getTriggerId()); if (updates == 0) { throw new TriggerLoaderException("No trigger has been updated."); } } catch (SQLException ex) { logger.error("Updating Trigger " + t.getTriggerId() + " failed." ); throw new TriggerLoaderException("DB Trigger update failed. ", ex); } }
Source:
private static ImmutableSet<String> readFile(String sourceFileName) throws UnsupportedEncodingException, FileNotFoundException, IOException { Builder<String> builder = ImmutableSet.builder(); BufferedReader input = new BufferedReader(new InputStreamReader( new FileInputStream(sourceFileName), "utf-8")); String line = input.readLine(); while (line != null) { if (!line.startsWith("#")) { String title = line.trim(); title = title.replace("_", " "); if (title.startsWith(":")) title = line.substring(1); if (title.length() > 0) builder.add(title); } line = input.readLine(); } input.close(); return builder.build(); }

Target:
private static ImmutableSet<String> readFile(String sourceFileName) throws IOException { Builder<String> builder = ImmutableSet.builder(); BufferedReader input = new BufferedReader(new InputStreamReader( new FileInputStream(sourceFileName), "utf-8")); String line = input.readLine(); while (line != null) { if (!line.startsWith("#")) { String title = line.trim(); title = title.replace("_", " "); if (title.startsWith(":")) title = line.substring(1); if (title.length() > 0) builder.add(title); } line = input.readLine(); } input.close(); return builder.build(); }
Source:
protected ImmutableValue<Set<String>> constructImmutableValue(Set<String> value) { return ImmutableSpongeSetValue.cachedOf(Keys.TAGS, Collections.<String>emptySet(), value); }

Target:
protected ImmutableValue<Set<String>> constructImmutableValue(Set<String> value) { return ImmutableSpongeSetValue.cachedOf(Keys.TAGS, Collections.emptySet(), value); }
Source:
public void onCreate(final MediaSessionService2 service) { MediaSession2 session; synchronized (mLock) { session = mSession; } if (session == null) { session = service.onCreateSession(); if (session == null) { throw new RuntimeException("Session is null"); } synchronized (mLock) { mSession = session; } } mNotificationHandler = new MediaNotificationHandler(service); }

Target:
public void onCreate(final MediaSessionService2 service) { MediaSession2 session; synchronized (mLock) { session = mSession; } if (session == null) { session = service.onCreateSession(); if (session == null) { throw new RuntimeException("Session shouldn't be null"); } synchronized (mLock) { mSession = session; } } mNotificationHandler = new MediaNotificationHandler(service); }
Source:
public DrawableLocatorMutation(final DefaultNode node, final double width, final double maxRefPosition) { this.maxRefPosition = maxRefPosition; this.width = width; setStroke(Paint.valueOf("blue")); setStartX(getXPosition(node.getRefStartPosition())); setEndX(node.getRefStartPosition() / maxRefPosition * width); setStartY(0); setEndY(LOCATOR_HEIGHT); }

Target:
public DrawableLocatorMutation(final DefaultNode node, final double width, final double maxRefPosition) { this.maxRefPosition = maxRefPosition; this.width = width; setStroke(Paint.valueOf("blue")); setStartX(getXPosition(node.getRefStartPosition())); setEndX(getXPosition(node.getRefStartPosition())); setStartY(2); setEndY(LOCATOR_HEIGHT); }
Source:
public String getNewQuestionSpecificEditFormHtml() { this.numOfRubricChoices = 4; this.rubricChoices.add("Strongly Disagree"); this.rubricChoices.add("Disagree"); this.rubricChoices.add("Agree"); this.rubricChoices.add("Strongly Agree"); this.rubricWeights.add(0); this.rubricWeights.add(0); this.rubricWeights.add(0); this.rubricWeights.add(0); this.numOfRubricSubQuestions = 2; this.rubricSubQuestions.add("This student participates well in online discussions."); this.rubricSubQuestions.add("This student completes assigned tasks on time."); this.initializeRubricDescriptions(); setDescription(0, 0, "Rarely or never responds."); setDescription(0, 1, "Occasionally responds, but never initiates discussions."); setDescription(0, 2, "Takes part in discussions and sometimes initiates discussions."); setDescription(0, 3, "Initiates discussions frequently, and engages the team."); setDescription(1, 0, "Rarely or never completes tasks."); setDescription(1, 1, "Often misses deadlines."); setDescription(1, 2, "Occasionally misses deadlines."); setDescription(1, 3, "Tasks are always completed before the deadline."); return "<div id=\"rubricForm\">" + this.getQuestionSpecificEditFormHtml(-1) + "</div>"; }

Target:
public String getNewQuestionSpecificEditFormHtml() { this.numOfRubricChoices = 4; this.rubricChoices.add("Strongly Disagree"); this.rubricChoices.add("Disagree"); this.rubricChoices.add("Agree"); this.rubricChoices.add("Strongly Agree"); this.hasAssignedWeights = false; this.numOfRubricSubQuestions = 2; this.rubricSubQuestions.add("This student participates well in online discussions."); this.rubricSubQuestions.add("This student completes assigned tasks on time."); this.initializeRubricDescriptions(); setDescription(0, 0, "Rarely or never responds."); setDescription(0, 1, "Occasionally responds, but never initiates discussions."); setDescription(0, 2, "Takes part in discussions and sometimes initiates discussions."); setDescription(0, 3, "Initiates discussions frequently, and engages the team."); setDescription(1, 0, "Rarely or never completes tasks."); setDescription(1, 1, "Often misses deadlines."); setDescription(1, 2, "Occasionally misses deadlines."); setDescription(1, 3, "Tasks are always completed before the deadline."); return "<div id=\"rubricForm\">" + this.getQuestionSpecificEditFormHtml(-1) + "</div>"; }
Source:
public void setup() { setupHelper.start( BACKEND_1_NAME ) .withBackendProperty( BACKEND_1_NAME, "directory.type", directoryType ) .withIndex( INDEX_NAME_1_1, ctx -> this.indexMapping_1_1 = new IndexMapping_1_1( ctx.getSchemaElement() ), indexMapping -> this.indexManager_1_1 = indexMapping ) .withIndex( INDEX_NAME_1_2, ctx -> this.indexMapping_1_2 = new IndexMapping_1_2( ctx.getSchemaElement() ), indexMapping -> this.indexManager_1_2 = indexMapping ) .setup(); initData(); }

Target:
public void setup() { setupHelper.start() .withBackendProperty( "directory.type", directoryType ) .withIndex( INDEX_NAME_1_1, ctx -> this.indexMapping_1_1 = new IndexMapping_1_1( ctx.getSchemaElement() ), indexMapping -> this.indexManager_1_1 = indexMapping ) .withIndex( INDEX_NAME_1_2, ctx -> this.indexMapping_1_2 = new IndexMapping_1_2( ctx.getSchemaElement() ), indexMapping -> this.indexManager_1_2 = indexMapping ) .setup(); initData(); }
Source:
public void test(TestHarness th) { this.th = th; InputStream is = getClass().getResourceAsStream("/midlets/MediaSampler/res/laser.wav"); try { Player player = Manager.createPlayer(is, "audio/x-wav"); testPlay(player); } catch (Exception e) { e.printStackTrace(); th.fail("Unexpected exception: " + e); } try { String url = "file:/ FileConnection file = (FileConnection)Connector.open(url, Connector.READ_WRITE); if (!file.exists()) { file.create(); } OutputStream os = file.openDataOutputStream(); os.write(read(is)); os.close(); Player player = Manager.createPlayer(url); testPlay(player); } catch (Exception e) { e.printStackTrace(); th.todo(false, "Unexpected exception: " + e); } }

Target:
public void test(TestHarness th) { this.th = th; InputStream is = getClass().getResourceAsStream("/midlets/MediaSampler/res/laser.wav"); try { Player player = Manager.createPlayer(is, "audio/x-wav"); testPlay(player); } catch (Exception e) { e.printStackTrace(); th.fail("Unexpected exception: " + e); } try { String url = "file:/ FileConnection file = (FileConnection)Connector.open(url, Connector.READ_WRITE); if (!file.exists()) { file.create(); } OutputStream os = file.openDataOutputStream(); os.write(read(is)); os.close(); Player player = Manager.createPlayer(url); testPlay(player); file.delete(); file.close(); } catch (Exception e) { e.printStackTrace(); th.todo(false, "Unexpected exception: " + e); } }
Source:
public Object[] transform(InputRow inputRow) { final String originalValue = inputRow.getValue(column); if (originalValue == null) { if (lookUpEveryToken) { return new String[3]; } else { return new String[1]; } } if (lookUpEveryToken) { final SynonymCatalogConnection.Replacement replacement = synonymCatalogConnection.replaceInline(originalValue); if (replacedSynonymsType == ReplacedSynonymsType.STRING) { return new Object[] { replacement.getReplacedString(), Joiner.on(' ').join(replacement.getSynonyms()), Joiner.on(' ').join(replacement.getMasterTerms()) }; } else { return new Object[] { replacement.getReplacedString(), replacement.getSynonyms(), replacement.getMasterTerms() }; } } else { final String replacedValue = lookup(originalValue); return new String[] { replacedValue }; } }

Target:
public Object[] transform(InputRow inputRow) { final String originalValue = inputRow.getValue(column); if (originalValue == null) { return new String[3]; } if (lookUpEveryToken) { final SynonymCatalogConnection.Replacement replacement = synonymCatalogConnection.replaceInline( originalValue); if (replacedSynonymsType == ReplacedSynonymsType.STRING) { return new Object[] { replacement.getReplacedString(), Joiner.on(' ').join(replacement.getSynonyms()), Joiner.on(' ').join(replacement.getMasterTerms()) }; } else { return new Object[] { replacement.getReplacedString(), replacement.getSynonyms(), replacement .getMasterTerms() }; } } else { final String masterTerm = synonymCatalogConnection.getMasterTerm(originalValue); final Object lookupResult = masterTerm != null ? masterTerm : (retainOriginalValue ? originalValue : null); final Object synonym = masterTerm != null ? originalValue : null; return new Object[] { lookupResult, synonym, masterTerm }; } }
Source:
public TFM_Admin(UUID uuid, ConfigurationSection section) { this.uuid = uuid; this.lastLoginName = section.getString("last_login_name"); this.ips = section.getStringList("ips"); this.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L)))); this.loginMessage = section.getString("custom_login_message", ""); this.isSeniorAdmin = section.getBoolean("is_senior_admin", false); this.isTelnetAdmin = section.getBoolean("is_telnet_admin", false); this.consoleAliases = section.getStringList("console_aliases"); this.cmdSpyEnabled = section.getBoolean("cmdspy_is_on", false); this.isActivated = section.getBoolean("is_activated", true); for (Iterator<?> it = TFM_MainConfig.getList(TFM_ConfigEntry.NOADMIN_IPS).iterator(); it.hasNext();) { ips.remove((String) it.next()); } }

Target:
public TFM_Admin(UUID uuid, ConfigurationSection section) { this.uuid = uuid; this.lastLoginName = section.getString("last_login_name"); this.ips = section.getStringList("ips"); this.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L)))); this.loginMessage = section.getString("custom_login_message", ""); this.isSeniorAdmin = section.getBoolean("is_senior_admin", false); this.isTelnetAdmin = section.getBoolean("is_telnet_admin", false); this.consoleAliases = section.getStringList("console_aliases"); this.cmdSpyEnabled = section.getBoolean("cmdspy", true); this.isActivated = section.getBoolean("is_activated", true); for (Iterator<?> it = TFM_MainConfig.getList(TFM_ConfigEntry.NOADMIN_IPS).iterator(); it.hasNext();) { ips.remove((String) it.next()); } }
Source:
private static File verifyFileExistsAndCanRead(File file) { if (!file.exists() || !file.canRead() || !file.isFile()) { throw new IllegalArgumentException("Unable to read specified resource: " + file); } return file; }

Target:
private static File verifyFileExistsAndCanRead(File file) { if (!file.isFile() || !file.canRead()) { throw new IllegalArgumentException("Unable to read specified resource: " + file); } return file; }
Source:
public ToggleDebuggingCommand(IServerWorkingCopy server, Button useImageDevmodeKeyButton, Text devmodeKeyText, SelectionListener toggleListener, ModifyListener textListener) { super(server, "Enable Debugging"); this.wc = server; this.useImageDevmodeKeyButton = useImageDevmodeKeyButton; this.devmodeKeyText = devmodeKeyText; preSelected = !useImageDevmodeKeyButton.getSelection(); preText = devmodeKeyText.getText(); this.toggleListener = toggleListener; this.textListener = textListener; }

Target:
public ToggleDebuggingCommand(IServerWorkingCopy server, Button useImageDevmodeKeyButton, Text devmodeKeyText, SelectionListener toggleListener, ModifyListener textListener) { super(server, "Enable Debugging"); this.wc = server; this.useImageDevmodeKeyButton = useImageDevmodeKeyButton; this.devmodeKeyText = devmodeKeyText; this.preSelected = !useImageDevmodeKeyButton.getSelection(); this.preText = devmodeKeyText.getText(); this.toggleListener = toggleListener; this.textListener = textListener; }
Source:
public Value getDateTimeValues( Value request ) throws FaultException { SimpleDateFormat sdf; Value v = Value.create(); try { String format; if ( request.getFirstChild( "format" ).strValue().isEmpty() ) { format = "dd/MM/yyyy hh:ss:mm"; } else { format = request.getFirstChild( "format" ).strValue(); } if ( request.hasChildren( "language" ) ) { String language = request.getFirstChild( "language" ).strValue(); if ( language.equals( "uk" ) ) { sdf = new SimpleDateFormat( format, Locale.ENGLISH ); } else if ( language.equals( "it" ) ) { sdf = new SimpleDateFormat( format, Locale.ITALIAN ); } else { sdf = new SimpleDateFormat( format, Locale.US ); } } else { sdf = new SimpleDateFormat( format, Locale.US ); } GregorianCalendar cal = new GregorianCalendar(); final Date dt = sdf.parse( request.strValue() ); cal.setTimeInMillis( dt.getTime() ); v.getFirstChild( "day" ).setValue( cal.get( Calendar.DAY_OF_MONTH ) ); v.getFirstChild( "month" ).setValue( cal.get( Calendar.MONTH ) + 1 ); v.getFirstChild( "year" ).setValue( cal.get( Calendar.YEAR ) ); v.getFirstChild( "hour" ).setValue( cal.get( Calendar.HOUR ) ); v.getFirstChild( "minute" ).setValue( cal.get( Calendar.MINUTE ) ); v.getFirstChild( "second" ).setValue( cal.get( Calendar.SECOND ) ); } catch( ParseException pe ) { throw new FaultException( "InvalidDate", pe ); } return v; }

Target:
public Value getDateTimeValues( Value request ) throws FaultException { SimpleDateFormat sdf; Value v = Value.create(); try { String format; if ( request.getFirstChild( "format" ).strValue().isEmpty() ) { format = "dd/MM/yyyy hh:ss:mm"; } else { format = request.getFirstChild( "format" ).strValue(); } if ( request.hasChildren( "language" ) ) { String language = request.getFirstChild( "language" ).strValue(); if ( language.equals( "us" ) ) { sdf = new SimpleDateFormat( format, Locale.ENGLISH ); } else if ( language.equals( "it" ) ) { sdf = new SimpleDateFormat( format, Locale.ITALIAN ); } else { sdf = new SimpleDateFormat( format, Locale.US ); } } else { sdf = new SimpleDateFormat( format, Locale.US ); } GregorianCalendar cal = new GregorianCalendar(); final Date dt = sdf.parse( request.strValue() ); cal.setTimeInMillis( dt.getTime() ); v.getFirstChild( "day" ).setValue( cal.get( Calendar.DAY_OF_MONTH ) ); v.getFirstChild( "month" ).setValue( cal.get( Calendar.MONTH ) + 1 ); v.getFirstChild( "year" ).setValue( cal.get( Calendar.YEAR ) ); v.getFirstChild( "hour" ).setValue( cal.get( Calendar.HOUR ) ); v.getFirstChild( "minute" ).setValue( cal.get( Calendar.MINUTE ) ); v.getFirstChild( "second" ).setValue( cal.get( Calendar.SECOND ) ); } catch( ParseException pe ) { throw new FaultException( "InvalidDate", pe ); } return v; }
Source:
public static int getSignalFromUrl(String url) { if ("signal:typefocus".equals(url)) { return TYPE_FOCUS; } else if ("signal:relinquishFocus".equals(url)) { return RELINQUISH_FOCUS; } return SIGNAL_NONE; }

Target:
public static int getSignalFromUrl(String url) { switch (url) { case "signal:typefocus": return TYPE_FOCUS; case "signal:relinquishFocus": return RELINQUISH_FOCUS; case "signal:show_answer": return SHOW_ANSWER; case "signal:answer_ease1": return ANSWER_ORDINAL_1; case "signal:answer_ease2": return ANSWER_ORDINAL_2; case "signal:answer_ease3": return ANSWER_ORDINAL_3; case "signal:answer_ease4": return ANSWER_ORDINAL_4; default: break; } if (url.startsWith("signal:answer_ease")) { Timber.w("Unhandled signal: ease value: %s", url); return SIGNAL_NOOP; } return SIGNAL_UNHANDLED; }
Source:
private ListenableFuture<VersionMessage> getVersionMessage(Peer peer) { SettableFuture<VersionMessage> peerVersionMessageFuture = SettableFuture.create(); var versionHandshakeDone = peer.getVersionHandshakeFuture(); FutureCallback<Peer> fetchPeerVersionMessage = new FutureCallback<Peer>() { public void onSuccess(Peer peer) { peerVersionMessageFuture.set(peer.getPeerVersionMessage()); } public void onFailure(Throwable thr) { ; } }; Futures.addCallback( versionHandshakeDone, fetchPeerVersionMessage ); PeerDisconnectedEventListener cancelIfConnectionFails = new PeerDisconnectedEventListener() { public void onPeerDisconnected(Peer peer, int peerCount) { var peerVersionMessageAlreadyReceived = peerVersionMessageFuture.isDone(); if (peerVersionMessageAlreadyReceived) { return; } var peerVersionMessage = peer.getPeerVersionMessage(); if (peerVersionMessage != null) { log.info("Handshake attempt was interrupted;" + " however, the local node's version message was coerced."); peerVersionMessageFuture.set(peerVersionMessage); } else { log.info("Handshake attempt did not result in a version message exchange."); var mayInterruptWhileRunning = true; peerVersionMessageFuture.cancel(mayInterruptWhileRunning); } } }; peer.addDisconnectedEventListener(cancelIfConnectionFails); return peerVersionMessageFuture; }

Target:
private ListenableFuture<VersionMessage> getVersionMessage(Peer peer) { SettableFuture<VersionMessage> peerVersionMessageFuture = SettableFuture.create(); var versionHandshakeDone = peer.getVersionHandshakeFuture(); FutureCallback<Peer> fetchPeerVersionMessage = new FutureCallback<>() { public void onSuccess(Peer peer) { peerVersionMessageFuture.set(peer.getPeerVersionMessage()); } public void onFailure(@NotNull Throwable thr) { } }; Futures.addCallback(versionHandshakeDone, fetchPeerVersionMessage); PeerDisconnectedEventListener cancelIfConnectionFails = (Peer disconnectedPeer, int peerCount) -> { var peerVersionMessageAlreadyReceived = peerVersionMessageFuture.isDone(); if (peerVersionMessageAlreadyReceived) { return; } var peerVersionMessage = disconnectedPeer.getPeerVersionMessage(); if (peerVersionMessage != null) { log.info("Handshake attempt was interrupted; " + "however, the local node's version message was coerced."); peerVersionMessageFuture.set(peerVersionMessage); } else { log.info("Handshake attempt did not result in a version message exchange."); peerVersionMessageFuture.cancel(true); } }; peer.addDisconnectedEventListener(cancelIfConnectionFails); return peerVersionMessageFuture; }
Source:
public synchronized int registerEvaluator(final String contextId, final int numInitialEvals) { if (evalIdToPartitionIds.containsKey(contextId)) { throw new RuntimeException("This evaluator is already registered. Its context Id is " + contextId); } final int memoryStoreId = numEvalCounter.getAndIncrement(); LOG.log(Level.FINE, "MemoryStore({0}) is registered to {1}", new Object[]{memoryStoreId, contextId}); if (memoryStoreId < numPartitions) { evalIdToPartitionIds.put(contextId, new HashSet<Integer>()); for (int partitionId = memoryStoreId; partitionId < numPartitions; partitionId += numInitialEvals) { evalIdToPartitionIds.get(contextId).add(partitionId); } } return memoryStoreId; }

Target:
public synchronized int registerEvaluator(final String contextId, final int numInitialEvals) { if (evalIdToPartitionIds.containsKey(contextId)) { throw new RuntimeException("This evaluator is already registered. Its context Id is " + contextId); } final int memoryStoreId = numEvalCounter.getAndIncrement(); LOG.log(Level.FINE, "MemoryStore({0}) is registered to {1}", new Object[]{memoryStoreId, contextId}); if (memoryStoreId < numInitialEvals) { evalIdToPartitionIds.put(contextId, new HashSet<Integer>()); for (int partitionId = memoryStoreId; partitionId < numPartitions; partitionId += numInitialEvals) { evalIdToPartitionIds.get(contextId).add(partitionId); } } return memoryStoreId; }
Source:
public void shouldLoadPredictableRecipesFromValidJson() throws Exception { recipeLoader = new PredefinedRecipeLoader("recipes.json", recipeDao); List<RecipeImpl> result = new ArrayList<>(); Mockito.doAnswer(r -> result.add((RecipeImpl)r.getArguments()[0])).when(recipeDao).create(any()); recipeLoader.start(); Assert.assertEquals(result.size(), 2); }

Target:
public void shouldLoadPredictableRecipesFromValidJson() throws Exception { recipeLoader = new PredefinedRecipeLoader("recipes.json", recipeDao); recipeLoader.start(); verify(recipeDao, times(2)).create(any()); }
Source:
public final Single<T> doOnEach(final Action1<Notification<? extends T>> onNotification) { if (onNotification == null) { throw new IllegalArgumentException("onNotification is null"); } Observer<T> observer = new Observer<T>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { onNotification.call(Notification.<T>createOnError(e)); } @Override public void onNext(T t) { onNotification.call(Notification.<T>createOnNext(t)); } }; return Observable.create(new OnSubscribeDoOnEach<T>(this.toObservable(), observer)).toSingle(); }

Target:
public final Single<T> doOnEach(final Action1<Notification<? extends T>> onNotification) { if (onNotification == null) { throw new IllegalArgumentException("onNotification is null"); } return Single.create(new SingleDoOnEvent<T>(this, new Action1<T>() { @Override public void call(final T t) { onNotification.call(Notification.<T>createOnNext(t)); } }, new Action1<Throwable>() { @Override public void call(final Throwable throwable) { onNotification.call(Notification.<T>createOnError(throwable)); } })); }
Source:
public static boolean isSamtoolsAvailable() { final String binPath = getSamtoolsBin(); if (binPath == null) { LOG.warn(String.format( "No samtools binary found. Set property %s to enable testing with samtools.", SAMTOOLS_BIN_PROPERTY)); return false; } final Path binFile = Paths.get(binPath); if (!Files.exists(binFile)) { throw new IllegalArgumentException( String.format( "%s property is set to non-existent file: %s", SAMTOOLS_BIN_PROPERTY, binFile)); } return true; }

Target:
public static boolean isSamtoolsAvailable() { final String binPath = getSamtoolsBin(); final Path binFile = Paths.get(binPath); return Files.exists(binFile); }