auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testSubjectAndDescriptionProperties() { ProcessInstance processInstance = kieSession.startProcess(HUMAN_TASK_ID); List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK"); TaskSummary task = list.get(0); Task t = taskService.getTaskById(task.getId()); Assertions.assertThat(task.getDescription()).isEqualTo("This is description of the human task."); Assertions.assertThat(task.getSubject()).isNullOrEmpty(); Assertions.assertThat(t.getSubject()).isEqualTo("Bake a cake"); taskService.start(task.getId(), "john"); taskService.complete(task.getId(), "john", null); ProcessInstanceLog plog = getLogService().findProcessInstance(processInstance.getId()); Assertions.assertThat(plog.getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED); }

Target:
public void testSubjectAndDescriptionProperties() { ProcessInstance processInstance = kieSession.startProcess(HUMAN_TASK_ID); List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK"); TaskSummary task = list.get(0); Task t = taskService.getTaskById(task.getId()); Assertions.assertThat(task.getDescription()).isEqualTo("This is description of the human task."); Assertions.assertThat(task.getSubject()).isNullOrEmpty(); Assertions.assertThat(t.getSubject()).isEqualTo(EXPECTED_SUBJECT); taskService.start(task.getId(), "john"); taskService.complete(task.getId(), "john", null); ProcessInstanceLog plog = getLogService().findProcessInstance(processInstance.getId()); Assertions.assertThat(plog.getStatus()).isEqualTo(ProcessInstance.STATE_COMPLETED); }
Source:
public Mono<Long> schedule(ServiceBusMessage messageToSchedule, Instant scheduledEnqueueTime, int maxSendLinkSize) { messageToSchedule.setScheduledEnqueueTime(scheduledEnqueueTime); return isAuthorized(SCHEDULE_MESSAGE_OPERATION).thenMany(createRequestResponse.flatMap(channel -> { Message requestMessage = createManagementMessage(SCHEDULE_MESSAGE_OPERATION, channel.getReceiveLinkName()); Map<String, Object> requestBodyMap = createScheduleMessgeAmqpValue(messageToSchedule, maxSendLinkSize); requestMessage.setBody(new AmqpValue(requestBodyMap)); return channel.sendWithAck(requestMessage); }).flatMapMany(responseMessage -> { int statusCode = RequestResponseUtils.getResponseStatusCode(responseMessage); if (statusCode != AmqpResponseCode.OK.getValue()) { return FluxUtil.monoError(logger, new AmqpException(false, String.format("Could not schedule message with message id: '%s'.", messageToSchedule.getMessageId()), getErrorContext())); } return Flux.fromIterable(messageSerializer.deserializeList(responseMessage, Long.class)); })) .next(); }

Target:
public Mono<Long> schedule(ServiceBusMessage messageToSchedule, Instant scheduledEnqueueTime, int maxSendLinkSize) { messageToSchedule.setScheduledEnqueueTime(scheduledEnqueueTime); return isAuthorized(SCHEDULE_MESSAGE_OPERATION).then(createRequestResponse.flatMap(channel -> { Message requestMessage = createManagementMessage(SCHEDULE_MESSAGE_OPERATION, channel.getReceiveLinkName()); Map<String, Object> requestBodyMap = createScheduleMessgeAmqpValue(messageToSchedule, maxSendLinkSize); requestMessage.setBody(new AmqpValue(requestBodyMap)); return channel.sendWithAck(requestMessage); }).map(responseMessage -> { int statusCode = RequestResponseUtils.getResponseStatusCode(responseMessage); if (statusCode != AmqpResponseCode.OK.getValue()) { throw logger.logExceptionAsError(new AmqpException(false, String.format("Could not schedule message with message id: '%s'.", messageToSchedule.getMessageId()), getErrorContext())); } List<Long> sequenceNumberList = messageSerializer.deserializeList(responseMessage, Long.class); if (CoreUtils.isNullOrEmpty(sequenceNumberList)) { throw logger.logExceptionAsError(new AmqpException(false, String.format("Service bus response empty. Could not schedule message with message id: '%s'.", messageToSchedule.getMessageId()), getErrorContext())); } return sequenceNumberList.get(0); })); }
Source:
private static final File getBaseDir() throws FileNotFoundException { String baseEnv = System.getenv("BASE"); if (baseEnv == null) { throw new FileNotFoundException("Unable to locate Jenkins base directory. Environment variable 'BASE' not found."); } return new File(baseEnv); }

Target:
private static final File getBaseDir() { File baseDir; String baseEnv = System.getenv("BASE"); if (baseEnv != null) { baseDir = new File(baseEnv); } else { LOGGER.log(Level.WARNING, "Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME"); baseDir = Jenkins.getInstance().getRootDir(); } return baseDir; }
Source:
private void actionCompleted(SegmentHolder segmentHolder) { switch (segmentHolder.getType()) { case LOAD: segmentsToLoad.remove(segmentHolder.getSegment()); queuedSize.addAndGet(-segmentHolder.getSegmentSize()); break; case DROP: segmentsToDrop.remove(segmentHolder.getSegment()); break; default: throw new UnsupportedOperationException(); } callBackExecutor.execute( () -> executeCallbacks(segmentHolder) ); }

Target:
private void actionCompleted(SegmentHolder segmentHolder) { switch (segmentHolder.getType()) { case LOAD: segmentsToLoad.remove(segmentHolder.getSegment()); queuedSize.addAndGet(-segmentHolder.getSegmentSize()); break; case DROP: segmentsToDrop.remove(segmentHolder.getSegment()); break; default: throw new UnsupportedOperationException(); } executeCallbacks(segmentHolder); }
Source:
public Map<String, Object> calculateInputVariables(DelegateExecution execution) { Extension extensions = processExtensionService.getExtensionsForId(execution.getProcessDefinitionId()); Map<String, Object> constants = calculateConstants(execution, extensions); if (!extensions.hasMapping(execution.getCurrentActivityId())) { return constants; } Map<String, Object> inboundVariables; if (extensions.hasMappingTypeInputs(execution.getCurrentActivityId())) { inboundVariables = execution.getVariables(); } else { inboundVariables = calculateInputVariables(execution, extensions); } inboundVariables = expressionResolver.resolveExpressionsMap(new VariableScopeExpressionEvaluator(execution), inboundVariables); inboundVariables.putAll(constants); return inboundVariables; }

Target:
public Map<String, Object> calculateInputVariables(DelegateExecution execution) { Extension extensions = processExtensionService.getExtensionsForId(execution.getProcessDefinitionId()); Map<String, Object> constants = calculateConstants(execution, extensions); if (!extensions.hasMapping(execution.getCurrentActivityId())) { return constants; } Map<String, Object> inboundVariables; if (extensions.shouldMapAllInputs(execution.getCurrentActivityId())) { inboundVariables = execution.getVariables(); } else { inboundVariables = calculateInputVariables(execution, extensions); } inboundVariables = expressionResolver.resolveExpressionsMap(new VariableScopeExpressionEvaluator(execution), inboundVariables); inboundVariables.putAll(constants); return inboundVariables; }
Source:
void read(HttpServletRequest request, HttpServletResponse response, AssetFileIdentity id) throws IOException { Map<String, Object> objMeta; try { objMeta = contentRepoService.getRepoObjMetaLatestVersion(id.toString()); } catch (ContentRepoException e) { if (e.getErrorType() == ErrorType.ErrorFetchingObjectMeta) { throw reportNotFound(id); } else { throw e; } } String contentType = (String) objMeta.get("contentType"); response.setHeader(HttpHeaders.CONTENT_TYPE, contentType); String filename = (String) objMeta.get("downloadName"); if (filename == null) { filename = id.getFileName(); } String contentDisposition = "attachment; filename=" + filename; response.setHeader(HttpHeaders.CONTENT_DISPOSITION, contentDisposition); Timestamp timestamp = Timestamp.valueOf((String) objMeta.get("timestamp")); setLastModifiedHeader(response, timestamp); if (!checkIfModifiedSince(request, timestamp)) { response.setStatus(HttpStatus.NOT_MODIFIED.value()); return; } List<String> reproxyUrls = (List<String>) objMeta.get("reproxyURL"); if (clientSupportsReproxy(request) && reproxyUrls != null && !reproxyUrls.isEmpty()) { String reproxyUrlHeader = REPROXY_URL_JOINER.join(reproxyUrls); response.setStatus(HttpStatus.OK.value()); response.setHeader("X-Reproxy-URL", reproxyUrlHeader); response.setHeader("X-Reproxy-Cache-For", REPROXY_CACHE_FOR_HEADER); } else { try (InputStream fileStream = assetCrudService.read(id); OutputStream responseStream = response.getOutputStream()) { ByteStreams.copy(fileStream, responseStream); } } }

Target:
void read(HttpServletRequest request, HttpServletResponse response, AssetFileIdentity id) throws IOException { Map<String, Object> objMeta; try { objMeta = contentRepoService.getRepoObjMetaLatestVersion(id.toString()); } catch (ContentRepoException e) { if (e.getErrorType() == ErrorType.ErrorFetchingObjectMeta) { throw reportNotFound(id); } else { throw e; } } String contentType = (String) objMeta.get("contentType"); if (contentType == null) { contentType = id.inferContentType().toString(); } response.setHeader(HttpHeaders.CONTENT_TYPE, contentType); String filename = (String) objMeta.get("downloadName"); if (filename == null) { filename = id.getFileName(); } String contentDisposition = "attachment; filename=" + filename; response.setHeader(HttpHeaders.CONTENT_DISPOSITION, contentDisposition); Timestamp timestamp = Timestamp.valueOf((String) objMeta.get("timestamp")); setLastModifiedHeader(response, timestamp); if (!checkIfModifiedSince(request, timestamp)) { response.setStatus(HttpStatus.NOT_MODIFIED.value()); return; } List<String> reproxyUrls = (List<String>) objMeta.get("reproxyURL"); if (clientSupportsReproxy(request) && reproxyUrls != null && !reproxyUrls.isEmpty()) { String reproxyUrlHeader = REPROXY_URL_JOINER.join(reproxyUrls); response.setStatus(HttpStatus.OK.value()); response.setHeader("X-Reproxy-URL", reproxyUrlHeader); response.setHeader("X-Reproxy-Cache-For", REPROXY_CACHE_FOR_HEADER); } else { try (InputStream fileStream = assetCrudService.read(id); OutputStream responseStream = response.getOutputStream()) { ByteStreams.copy(fileStream, responseStream); } } }
Source:
public void testListAccounts() throws Exception { List<AccountInfo> possibleAccounts = api().listAccounts(); assertNotNull(possibleAccounts, "possibleAccounts was not set"); assertTrue(possibleAccounts.size() > 0, "Expected at least 1 Account but list was empty"); boolean accountFound = false; for (AccountInfo possibleAccount : possibleAccounts) { if (possibleAccount.username().equals(username)) { accountFound = true; } } assertTrue(accountFound, "Expected but could not find Account amongst " + possibleAccounts.size() + " found"); }

Target:
public void testListAccounts() throws Exception { List<AccountInfo> possibleAccounts = api().listAccounts(); assertNotNull(possibleAccounts, "possibleAccounts was not set"); assertTrue(possibleAccounts.size() > 0, "Expected at least 1 Account but list was empty"); AccountInfo possibleAccount = Iterables.find(possibleAccounts, new Predicate<AccountInfo>() { @Override public boolean apply(AccountInfo arg0) { return arg0.userName().equals(username); } }, null); assertNotNull(possibleAccount, "Expected but could not find Account amongst " + possibleAccounts.size() + " found"); }
Source:
public Optional<Task> getTask(String taskid) { Preconditions.checkNotNull(taskid, "taskid"); if(tasks.containsKey(taskid)) { return Optional.of(tasks.get(taskid).task); } else { return Optional.absent(); } }

Target:
public Optional<Task> getTask(String taskid) { Preconditions.checkNotNull(taskid, "taskid"); if(tasks.containsKey(taskid)) { return Optional.of(tasks.get(taskid).getTask()); } else { return Optional.absent(); } }
Source:
public TTSService getTTS() { TTSService tts = null; if (defaultTTS != null) { tts = ttsServices.get(defaultTTS); if (tts == null) { logger.warn("Default TTS service '{}' not available!", defaultTTS); } } else if (ttsServices.size() > 0) { tts = ttsServices.values().iterator().next(); } else { logger.debug("No TTS service available!"); } return tts; }

Target:
public TTSService getTTS() { TTSService tts = null; if (defaultTTS != null) { tts = ttsServices.get(defaultTTS); if (tts == null) { logger.warn("Default TTS service '{}' not available!", defaultTTS); } } else if (!ttsServices.isEmpty()) { tts = ttsServices.values().iterator().next(); } else { logger.debug("No TTS service available!"); } return tts; }
Source:
protected <T> T invokeWithRetry(Callable<T> func, T defaultReturnValue) throws Exception { for (int currentRetryCount = 1; currentRetryCount <= MAX_RETY_COUNT; currentRetryCount++) { try { LOG.debug("HiveAtlasPlugin: retrying method: {}", func.getClass().getName(), null); return func.call(); } catch (Exception e) { if (processImportExportLockException(e, currentRetryCount)) { continue; } if (processInvalidParameterException(e)) { return null; } LOG.error("HiveAtlasPlugin: " + func.getClass().getName(), e); throw new Exception(e); } } return defaultReturnValue; }

Target:
protected <T> T invokeWithRetry(Callable<T> func, T defaultReturnValue) throws Exception { for (int currentRetryCount = 1; currentRetryCount <= MAX_RETY_COUNT; currentRetryCount++) { try { LOG.debug("Retrying method: {}", func.getClass().getName(), null); return func.call(); } catch (Exception e) { if (processImportExportLockException(e, currentRetryCount)) { continue; } if (processInvalidParameterException(e)) { return null; } LOG.error(func.getClass().getName(), e); throw new Exception(e); } } return defaultReturnValue; }
Source:
protected BusinessDetail loadBusinessDetail(File file) throws JAXBException { BusinessDetail resp = null; try { synchronized (file) { JAXBContext context = JAXBContext.newInstance(BusinessDetail.class); final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); dbf.setFeature(NhincConstants.FEATURE_GENERAL_ENTITIES, false); dbf.setFeature(NhincConstants.FEATURE_DISALLOW_DOCTYPE, true); dbf.setFeature(NhincConstants.FEATURE_PARAMETER_ENTITIES, false); dbf.setExpandEntityReferences(false); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document doc = db.parse(file); doc.getDocumentElement().normalize(); DOMSource source = new DOMSource(doc); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); StreamResult result = new StreamResult(); ByteArrayOutputStream out = new ByteArrayOutputStream(); result.setOutputStream(out); transformer.transform(source, result); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBElement<BusinessDetail> jaxbElement = unmarshaller.unmarshal(new StreamSource(in), BusinessDetail.class); resp = jaxbElement.getValue(); } } catch (final IOException e) { LOG.error("unable to load XDRConfiguration file", e); } catch (final ParserConfigurationException e) { LOG.error("unable to load XDRConfiguration file", e); } catch (final TransformerException e) { LOG.error("unable to load XDRConfiguration file", e); } catch (final SAXException e) { LOG.error("unable to load XDRConfiguration file", e); } return resp; }

Target:
protected BusinessDetail loadBusinessDetail(File file) throws JAXBException { BusinessDetail resp = null; FileInputStream inputStream = null; try { synchronized (file) { JAXBContext context = JAXBContext.newInstance(BusinessDetail.class); Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBUnmarshallingUtil util = new JAXBUnmarshallingUtil(); inputStream = new FileInputStream(file); JAXBElement<BusinessDetail> jaxbElement = unmarshaller .unmarshal(util.getSafeStreamReaderFromInputStream(inputStream), BusinessDetail.class); resp = jaxbElement.getValue(); } } catch (FileNotFoundException | XMLStreamException e) { LOG.error("Exception in reading/parsing Connection Information file: {}", e.getLocalizedMessage(), e); } finally { StreamUtils.closeStreamSilently(inputStream); } return resp; }
Source:
private Guid getStorageDomainId(Disk disk) { if (disk.isSetStorageDomains() && disk.getStorageDomains().isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetId()) { return asGuid(disk.getStorageDomains().getStorageDomains().get(0).getId()); } else if (disk.isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetName()) { String storageName = disk.getStorageDomains().getStorageDomains().get(0).getName(); Guid storageDomainId = getStorageDomainIdByName(storageName); if (storageDomainId == null) { throw new WebFaultException(null, localize(Messages.BACKEND_FAILED), localize(Messages.ENTITY_NOT_FOUND_TEMPLATE, storageName), Response.Status.NOT_FOUND); } else { return storageDomainId; } } return null; }

Target:
private Guid getStorageDomainId(Disk disk) { if (disk.isSetStorageDomains() && disk.getStorageDomains().isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetId()) { return asGuid(disk.getStorageDomains().getStorageDomains().get(0).getId()); } else if (disk.isSetStorageDomains() && disk.getStorageDomains().getStorageDomains().get(0).isSetName()) { String storageName = disk.getStorageDomains().getStorageDomains().get(0).getName(); Guid storageDomainId = getStorageDomainIdByName(storageName); if (storageDomainId == null) { notFound(storageName); } else { return storageDomainId; } } return null; }
Source:
private void testEncryptDecrypt(byte[] payload) throws GeneralSecurityException, HandshakeException { Record record = new Record(ContentType.APPLICATION_DATA, EPOCH, 1, new ApplicationMessage(payload, session.getPeer()), session, true, 0); byte[] raw = record.toByteArray(); List<Record> list = Record.fromByteArray(raw, session.getPeer(), null, ClockUtil.nanoRealtime()); assertFalse("failed to decode raw message", list.isEmpty()); for (Record recv : list) { recv.setSession(session); DTLSMessage message = recv.getFragment(); assertArrayEquals("decrpted payload differs", payload, message.toByteArray()); } }

Target:
private void testEncryptDecrypt(byte[] payload) throws GeneralSecurityException, HandshakeException { Record record = new Record(ContentType.APPLICATION_DATA, EPOCH, 1, new ApplicationMessage(payload, session.getPeer()), session, true, 0); byte[] raw = record.toByteArray(); List<Record> list = Record.fromByteArray(raw, session.getPeer(), null, ClockUtil.nanoRealtime()); assertFalse("failed to decode raw message", list.isEmpty()); for (Record recv : list) { recv.setSession(session); DTLSMessage message = recv.getFragment(); assertArrayEquals("decrypted payload differs", payload, message.toByteArray()); } }
Source:
public void setDstAddrHostname(String dstAddrHostname) { addHost(dstAddrHostname); this.dstAddrHostname = dstAddrHostname; }

Target:
public void setDstAddrHostname(String dstAddrHostname) { this.dstAddrHostname = dstAddrHostname; }
Source:
private static SWTBotView openSymbolProviderDialog() { final SWTBotView viewBot = fBot.viewById(CallStackView.ID); viewBot.setFocus(); viewBot.toolbarButton(CONFIGURE_SYMBOL_PROVIDERS).click(); fBot.waitUntil(Conditions.shellIsActive("Symbol mapping")); return viewBot; }

Target:
private static void openSymbolProviderDialog() { final SWTBotView viewBot = fBot.viewById(CallStackView.ID); viewBot.setFocus(); viewBot.toolbarButton(CONFIGURE_SYMBOL_PROVIDERS).click(); fBot.waitUntil(Conditions.shellIsActive("Symbol mapping")); }
Source:
private static Activity getActivity(final Context context) { if (context == null) { return null; } else if (context instanceof Activity) { return (Activity) context; } else if (context instanceof ContextWrapper) { return getActivity(((ContextWrapper) context).getBaseContext()); } return null; }

Target:
private static Activity getActivity(final Context context) { if (context instanceof Activity) { return (Activity) context; } else if (context instanceof ContextWrapper) { return getActivity(((ContextWrapper) context).getBaseContext()); } return null; }
Source:
private void setFinalResult( Result resultMessage, Frame responseFrame, boolean schemaInAgreement, NodeResponseCallback callback) { try { ExecutionInfo executionInfo = buildExecutionInfo(callback, resultMessage, responseFrame, schemaInAgreement); AsyncResultSet resultSet = Conversions.toResultSet(resultMessage, executionInfo, session, context); if (result.complete(resultSet)) { cancelScheduledTasks(); session .getMetricUpdater() .updateTimer( CoreSessionMetric.cql_requests, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS); } } catch (Throwable error) { setFinalError(error); } }

Target:
private void setFinalResult( Result resultMessage, Frame responseFrame, boolean schemaInAgreement, NodeResponseCallback callback) { try { ExecutionInfo executionInfo = buildExecutionInfo(callback, resultMessage, responseFrame, schemaInAgreement); AsyncResultSet resultSet = Conversions.toResultSet(resultMessage, executionInfo, session, context); if (result.complete(resultSet)) { cancelScheduledTasks(); session .getMetricUpdater() .updateTimer( CoreSessionMetric.CQL_REQUESTS, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS); } } catch (Throwable error) { setFinalError(error); } }
Source:
private void handleConnectionClosedException() { while (true) { try { destroyState(); reconnect(); retrieveEntity(); connectionRecoveryListener.run(); return; } catch (ConnectionClosedException | ConnectionShutdownException e) { LOGGER.info("Disconnected to the server", e); } } }

Target:
private void handleConnectionClosedException() { while (true) { try { destroyState(); reconnect(); retrieveEntity(); connectionRecoveryListener.run(); break; } catch (ConnectionClosedException | ConnectionShutdownException e) { LOGGER.info("Disconnected from the server", e); } } }
Source:
public Injector init() throws Exception { Map<String, SecureStoreLoadUtil.Metadata> secureStores = getAllSecureStores(); Set<String> secureStoreNames = Sets.newHashSet(secureStores.keySet()); if (secureStoreNames.isEmpty()) { return createInjectorWithCustomSecureStore(DefaultSecureStore.class); } secureStoreNames.add(DefaultSecureStore.NAME); String currentProvider = getCurrentSecureStoreName(); String secureStoreName = ui.readString(currentProvider, secureStoreNames, "Secure store"); if (DefaultSecureStore.NAME.equals(secureStoreName)) { if (!DefaultSecureStore.NAME.equals(currentProvider)) { flags.cfg.unset("gerrit", null, "secureStore"); } return createInjectorWithCustomSecureStore(DefaultSecureStore.class); } SecureStoreLoadUtil.Metadata selectedPlugin = secureStores.get(secureStoreName); File installedPlugin = installPlugin(selectedPlugin.jarFile, ui, site); flags.cfg.setString("gerrit", null, "secureStore", secureStoreName); Class<? extends SecureStore> storeClass = selectedPlugin.load(installedPlugin); return createInjectorWithCustomSecureStore(storeClass); }

Target:
public Injector init() throws Exception { Map<String, SecureStoreLoadUtil.Metadata> secureStores = getAllSecureStores(); Set<String> secureStoreNames = Sets.newTreeSet(secureStores.keySet()); if (secureStoreNames.isEmpty()) { return createInjectorWithCustomSecureStore(DefaultSecureStore.class); } secureStoreNames.add(DefaultSecureStore.NAME); String currentProvider = getCurrentSecureStoreName(); String secureStoreName = ui.readString(currentProvider, secureStoreNames, "Secure store"); if (DefaultSecureStore.NAME.equals(secureStoreName)) { if (!DefaultSecureStore.NAME.equals(currentProvider)) { flags.cfg.unset("gerrit", null, "secureStore"); } return createInjectorWithCustomSecureStore(DefaultSecureStore.class); } SecureStoreLoadUtil.Metadata selectedPlugin = secureStores.get(secureStoreName); File installedPlugin = installPlugin(selectedPlugin, ui, site); flags.cfg.setString("gerrit", null, "secureStore", secureStoreName); Class<? extends SecureStore> storeClass = selectedPlugin.load(installedPlugin); return createInjectorWithCustomSecureStore(storeClass); }
Source:
public LogData(ByteBuf buf) { lastKnownSize = buf.readableBytes(); type = ICorfuPayload.fromBuffer(buf, DataType.class); if (type == DataType.DATA) { data = ICorfuPayload.fromBuffer(buf, byte[].class); } else { data = null; } if (type.isMetadataAware()) { metadataMap = ICorfuPayload.enumMapFromBuffer(buf, IMetadata.LogUnitMetadataType.class); } else { metadataMap = new EnumMap<>(IMetadata.LogUnitMetadataType.class); } }

Target:
public LogData(ByteBuf buf) { try { lastKnownSize = buf.readableBytes(); type = ICorfuPayload.fromBuffer(buf, DataType.class); if (type == DataType.DATA) { data = ICorfuPayload.fromBuffer(buf, byte[].class); } else { data = null; } if (type.isMetadataAware()) { buf.readInt(); metadataMap = ICorfuPayload.enumMapFromBuffer(buf, IMetadata.LogUnitMetadataType.class); } else { metadataMap = new EnumMap<>(IMetadata.LogUnitMetadataType.class); } } catch (Exception e) { throw e; } }
Source:
void setBackgroundColor (long context, long handle, GdkRGBA rgba) { if (rgba == null) { GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND; background = new GdkRGBA (); background = display.toGdkRGBA (temp); } else { background = rgba; } GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = new GdkRGBA (); selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(background) + ";}\n" + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}"; gtk_css_provider_load_from_css(context, css); } else { super.setBackgroundColor(context, handle, rgba); OS.gtk_widget_override_background_color(handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground); } }

Target:
void setBackgroundColor (long context, long handle, GdkRGBA rgba) { if (rgba == null) { GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND; background = display.toGdkRGBA (temp); } else { background = rgba; } GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(background) + ";}\n" + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}"; gtk_css_provider_load_from_css(context, css); } else { super.setBackgroundColor(context, handle, rgba); OS.gtk_widget_override_background_color(handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground); } }
Source:
private void addNewPaymentDetailToGroupIfTotalIsPositive(PdpFeedGroupEntry newGroupEntry, PdpFeedDetailEntry newDetailEntry, KualiDecimal originalDetailTransactionTotal) { if (originalDetailTransactionTotal.isPositive()) { if (LOG.isDebugEnabled()) { LOG.debug("addNewPaymentDetailToGroupIfTotalIsPositive, total transaction for " + newDetailEntry.getSourceDocNbr() + " detail: " + originalDetailTransactionTotal); } newGroupEntry.getDetail().add(newDetailEntry); } else { if (LOG.isInfoEnabled()) { StringBuilder sb = new StringBuilder("addNewPaymentDetailToGroupIfTotalIsPositive, Not adding detail to group for source document "); sb.append(newDetailEntry.getSourceDocNbr()).append(" with a tansaction total of ").append(originalDetailTransactionTotal); if (originalDetailTransactionTotal.isNegative()) { sb.append(". A negative amount, it will be handled by the collector."); } else { sb.append(". A zero amount, no payment needs to be issued."); } LOG.info(sb.toString()); } } }

Target:
private void addNewPaymentDetailToGroupIfTotalIsPositive(PdpFeedGroupEntry newGroupEntry, PdpFeedDetailEntry newDetailEntry, KualiDecimal originalDetailTransactionTotal) { if (originalDetailTransactionTotal.isPositive()) { if (LOG.isInfoEnabled()) { LOG.info("addNewPaymentDetailToGroupIfTotalIsPositive, total transaction for " + newDetailEntry.getSourceDocNbr() + " detail: " + originalDetailTransactionTotal); } newGroupEntry.getDetail().add(newDetailEntry); } else { if (LOG.isInfoEnabled()) { StringBuilder sb = new StringBuilder("addNewPaymentDetailToGroupIfTotalIsPositive, Not adding detail to group for source document "); sb.append(newDetailEntry.getSourceDocNbr()).append(" with a tansaction total of ").append(originalDetailTransactionTotal); if (originalDetailTransactionTotal.isNegative()) { sb.append(". A negative amount, it will be handled by the collector"); } else { sb.append(". A zero amount, no payment needs to be issued"); } LOG.info(sb.toString()); } } }
Source:
public void init() { instance = this; DenizenAPI.getCurrentInstance().getCommandRegistry().registerCoreMember(WorldEditCommand.class, "WORLDEDIT", "worldedit [cuboid_to_schematic/cuboid_to_clipboard/schematic_to_paste/schematic_to_clipboard] (rotate:<amount>) (target:<player>)", 2); PropertyParser.registerProperty(WorldEditPlayerProperties.class, PlayerTag.class); }

Target:
public void init() { instance = this; DenizenAPI.getCurrentInstance().getCommandRegistry().registerCoreMember(WorldEditCommand.class, "WORLDEDIT", "worldedit [create_schematic/copy_to_clipboard/paste] (file:<file path>) (cuboid:<cuboid>) (position:<location>) (rotate:<#>) (undoable) (noair)", 2); PropertyParser.registerProperty(WorldEditPlayerProperties.class, PlayerTag.class); }
Source:
public void testGetDriveInfo() throws Exception { String uuid = "f17cce62-bcc9-4e0b-a57b-a5582b05aff0"; CloudSigma2Api api = requestSendsResponse( getBuilder() .endpoint(endpoint + "drives/" + uuid + "/") .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/drive-info.json", MediaType.APPLICATION_JSON)) .build()); DriveInfo result = api.getDriveInfo(uuid); assertNotNull(result); Assert.assertEquals(result.getName(), "test_drive_1"); Assert.assertEquals(result.getJobs().get(0).getResourceUri(), "/api/2.0/jobs/ec01d3bc-1ec0-440d-a1c3-0a6421d0d511/"); Assert.assertEquals(result.getJobs().get(0).getUuid(), "ec01d3bc-1ec0-440d-a1c3-0a6421d0d511"); Assert.assertEquals(result.getJobs().get(2).getResourceUri(), "/api/2.0/jobs/8bacb5b3-6392-4f74-8094-ba3376a3f5f7/"); Assert.assertEquals(result.getJobs().get(2).getUuid(), "8bacb5b3-6392-4f74-8094-ba3376a3f5f7"); }

Target:
public void testGetDriveInfo() throws Exception { String uuid = "f17cce62-bcc9-4e0b-a57b-a5582b05aff0"; CloudSigma2Api api = requestSendsResponse( getBuilder() .endpoint(endpoint + "drives/" + uuid + "/") .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/drive-info.json", MediaType.APPLICATION_JSON)) .build()); DriveInfo result = api.getDriveInfo(uuid); assertNotNull(result); assertEquals(result.getName(), "test_drive_1"); assertEquals(result.getJobs().get(0).getResourceUri(), "/api/2.0/jobs/ec01d3bc-1ec0-440d-a1c3-0a6421d0d511/"); assertEquals(result.getJobs().get(0).getUuid(), "ec01d3bc-1ec0-440d-a1c3-0a6421d0d511"); assertEquals(result.getJobs().get(2).getResourceUri(), "/api/2.0/jobs/8bacb5b3-6392-4f74-8094-ba3376a3f5f7/"); assertEquals(result.getJobs().get(2).getUuid(), "8bacb5b3-6392-4f74-8094-ba3376a3f5f7"); }
Source:
public LogEventType getLogEvent(Long id) { ViewErrorLogRequestMessageType request = new ViewErrorLogRequestMessageType(); request.setConfigAssertion(buildConfigAssertion()); request.setId(id); try { LogEventSimpleResponseMessageType response = (LogEventSimpleResponseMessageType) invokeClientPort( ADMIN_DASHBOARD_ERRORLOG_VIEW, request); logDebug(ADMIN_DASHBOARD_ERRORLOG_VIEW, response.getEventLogList().size()); if (CollectionUtils.isNotEmpty(response.getEventLogList())) { return response.getEventLogList().get(0); } } catch (Exception e) { LOG.error("error during view-log-event: {}", e.getLocalizedMessage(), e); } return null; }

Target:
public LogEventType getLogEvent(Long id) { ViewErrorLogRequestMessageType request = new ViewErrorLogRequestMessageType(); request.setConfigAssertion(buildConfigAssertion()); request.setId(id); try { LogEventSimpleResponseMessageType response = (LogEventSimpleResponseMessageType) invokeClientPort( ADMIN_DASHBOARD_ERRORLOG_VIEW, request); logDebug(ADMIN_DASHBOARD_ERRORLOG_VIEW, response.getEventLogList().size()); return response.getEventLogList().get(0); } catch (Exception ex) { LOG.error("Error while calling service view-errorlog: {}", ex.getMessage(), ex); HelperUtil.addMessageError(null, SERVICE_ERROR); } return null; }
Source:
protected Control createContents(Composite parent) { getShell().setText(Messages.ManageXMLAnalysisDialog_ManageXmlAnalysesFiles); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(2, false)); Composite tableContainer = new Composite(mainComposite, SWT.NONE); tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout lcgl = new GridLayout(); lcgl.marginHeight = 0; lcgl.marginWidth = 0; tableContainer.setLayout(lcgl); createTable(tableContainer); createLabels(tableContainer); createImportButtons(mainComposite); createSelectionButtons(mainComposite); fillAnalysesTable(); getShell().setMinimumSize(300, 275); return mainComposite; }

Target:
protected Control createContents(Composite parent) { getShell().setText(Messages.ManageXMLAnalysisDialog_ManageXmlAnalysesFiles); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(2, false)); Composite tableContainer = new Composite(mainComposite, SWT.NONE); tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayoutFactory.fillDefaults().applyTo(tableContainer); createTable(tableContainer); createLabels(tableContainer); createImportButtons(mainComposite); createSelectionButtons(mainComposite); fillAnalysesTable(); getShell().setMinimumSize(300, 275); return mainComposite; }
Source:
public void testCombineGenotypingArrayVcfs() throws IOException { final CombineGenotypingArrayVcfs combineGenotypingArrayVcfs = new CombineGenotypingArrayVcfs(); final File inputVcf1 = TEST_DATA_DIR.resolve("input.vcf").toFile(); final File inputVcf2 = TEST_DATA_DIR.resolve("input2.vcf").toFile(); final List<File> inputs = new ArrayList<File>(); inputs.add(inputVcf1); inputs.add(inputVcf2); final File output = File.createTempFile("output", ".vcf"); output.deleteOnExit(); combineGenotypingArrayVcfs.INPUT = inputs; combineGenotypingArrayVcfs.OUTPUT = output; Assert.assertEquals(combineGenotypingArrayVcfs.doWork(), 0); final File expected = TEST_DATA_DIR.resolve("combined_output.vcf").toFile(); VcfTestUtils.assertVcfFilesAreEqual(output, expected); }

Target:
public void testCombineGenotypingArrayVcfs() throws IOException { final CombineGenotypingArrayVcfs combineGenotypingArrayVcfs = new CombineGenotypingArrayVcfs(); final File inputVcf1 = TEST_DATA_DIR.resolve("input_for_combine.vcf").toFile(); final File inputVcf2 = TEST_DATA_DIR.resolve("input2_for_combine.vcf").toFile(); final List<File> inputs = Arrays.asList(inputVcf1, inputVcf2); final File output = File.createTempFile("output", ".vcf"); output.deleteOnExit(); combineGenotypingArrayVcfs.INPUT = inputs; combineGenotypingArrayVcfs.OUTPUT = output; Assert.assertEquals(combineGenotypingArrayVcfs.doWork(), 0); final File expected = TEST_DATA_DIR.resolve("combined_output.vcf").toFile(); VcfTestUtils.assertVcfFilesAreEqual(output, expected); }
Source:
public void keyspaceNotAccessibleDoesNotError() throws Exception { when(client.describe_keyspace("system_palantir")).thenThrow(new NotFoundException()); DummyClientPool clientPool = new DummyClientPool(client); Supplier<Map<String, String>> hostnamesByIpSupplier = new HostnamesByIpSupplier(() -> clientPool); assertThatCode(hostnamesByIpSupplier::get).doesNotThrowAnyException(); assertThat(hostnamesByIpSupplier.get()).isEmpty(); }

Target:
public void keyspaceNotAccessibleDoesNotError() throws Exception { when(client.describe_keyspace("system_palantir")).thenThrow(new NotFoundException()); assertThatCode(hostnamesByIpSupplier::get).doesNotThrowAnyException(); assertThat(hostnamesByIpSupplier.get()).isEmpty(); }
Source:
public void complete() throws InterruptedException { Preconditions.checkState(successCallback != null, "Must set a success callback before completing " + this); Preconditions.checkState(exceptionCallback != null, "Must set an exception callback before completing " + this); Preconditions.checkState(timeoutCallback != null, "Must set a timeout callback before completing " + this); for (WrappedTask wt : wrappedTasks) { try { successCallback.accept(wt.callable, wt.future.get(timeout, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { throw e; } catch (TimeoutException e) { wt.future.cancel(true); timeoutCallback.accept(wt.callable); } catch (Exception e) { exceptionCallback.accept(wt.callable, e); } } }

Target:
public void complete() throws InterruptedException { isCompleting = true; try { Preconditions.checkState(successCallback != null, "Must set a success callback before completing " + this); Preconditions.checkState(exceptionCallback != null, "Must set an exception callback before completing " + this); Preconditions.checkState(timeoutCallback != null, "Must set a timeout callback before completing " + this); int unfinished = wrappedTasks.size(); while (unfinished > 0) { WrappedTask wt = startedTasks.poll(timeoutInNanos * 2, TimeUnit.NANOSECONDS); if (wt != null) { completeTask(wt); wt.hasCompleted = true; unfinished--; } } wrappedTasks.clear(); } finally { isCompleting = false; } }
Source:
public void close() throws IOException { Set<BufferedLogChannelWithDirInfo> copyOfCurrentLogsWithDirInfo = getCopyOfCurrentLogs(); for (BufferedLogChannelWithDirInfo currentLogWithDirInfo : copyOfCurrentLogsWithDirInfo) { IOUtils.close(log, currentLogWithDirInfo.getLogChannel()); } }

Target:
public void close() throws IOException { Set<BufferedLogChannelWithDirInfo> copyOfCurrentLogsWithDirInfo = getCopyOfCurrentLogs(); for (BufferedLogChannelWithDirInfo currentLogWithDirInfo : copyOfCurrentLogsWithDirInfo) { if (currentLogWithDirInfo.getLogChannel() != null) { currentLogWithDirInfo.getLogChannel().close(); } } }
Source:
public List<TaskObject> getTaskList() { return this.TaskList; }

Target:
public ArrayList<TaskObject> getTaskList() { return mTasks; }
Source:
protected boolean validate() { if (!super.validate()) { return false; } if (!FeatureSupported.hotUnplugMemory(getVm().getCompatibilityVersion(), getVm().getClusterArch())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_MEMORY_HOT_UNPLUG_NOT_SUPPORTED_FOR_COMPAT_VERSION_AND_ARCH, ReplacementUtils.createSetVariableString( "compatibilityVersion", getVm().getCompatibilityVersion()), ReplacementUtils.createSetVariableString( "architecture", getVm().getClusterArch())); } if (getVm().getStatus() != VMStatus.Up) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_UP); } if (getDeviceToHotUnplug() == null) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_VM_MEMORY_DEVICE_DOESNT_EXIST, ReplacementUtils.createSetVariableString( "deviceId", getParameters().getDeviceId())); } if (!VmDeviceCommonUtils.getSpecParamsIntValue(getDeviceToHotUnplug(), VmDeviceCommonUtils.SPEC_PARAM_SIZE) .isPresent()) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_REQUIRED_SPEC_PARAM_IS_MISSING, ReplacementUtils.createSetVariableString("deviceId", getDeviceToHotUnplug().getId()), ReplacementUtils.createSetVariableString("specParamName", VmDeviceCommonUtils.SPEC_PARAM_SIZE)); } if (!VmDeviceCommonUtils.getSpecParamsIntValue(getDeviceToHotUnplug(), VmDeviceCommonUtils.SPEC_PARAM_NODE) .isPresent()) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_REQUIRED_SPEC_PARAM_IS_MISSING, ReplacementUtils.createSetVariableString("deviceId", getDeviceToHotUnplug().getId()), ReplacementUtils.createSetVariableString("specParamName", VmDeviceCommonUtils.SPEC_PARAM_NODE)); } return true; }

Target:
protected boolean validate() { if (!super.validate()) { return false; } if (!FeatureSupported.hotUnplugMemory(getVm().getCompatibilityVersion(), getVm().getClusterArch())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_MEMORY_HOT_UNPLUG_NOT_SUPPORTED_FOR_COMPAT_VERSION_AND_ARCH, ReplacementUtils.createSetVariableString( "compatibilityVersion", getVm().getCompatibilityVersion()), ReplacementUtils.createSetVariableString( "architecture", getVm().getClusterArch())); } if (getVm().getStatus() != VMStatus.Up) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_UP); } if (getDeviceToHotUnplug() == null) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_VM_MEMORY_DEVICE_DOESNT_EXIST, ReplacementUtils.createSetVariableString( "deviceId", getParameters().getDeviceId())); } if (!VmDeviceCommonUtils.getSpecParamsIntValue(getDeviceToHotUnplug(), SPEC_PARAM_SIZE) .isPresent()) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_REQUIRED_SPEC_PARAM_IS_MISSING, ReplacementUtils.createSetVariableString("deviceId", getDeviceToHotUnplug().getId()), ReplacementUtils.createSetVariableString("specParamName", SPEC_PARAM_SIZE)); } if (!VmDeviceCommonUtils.getSpecParamsIntValue(getDeviceToHotUnplug(), SPEC_PARAM_NODE) .isPresent()) { return failValidation( EngineMessage.ACTION_TYPE_FAILED_REQUIRED_SPEC_PARAM_IS_MISSING, ReplacementUtils.createSetVariableString("deviceId", getDeviceToHotUnplug().getId()), ReplacementUtils.createSetVariableString("specParamName", SPEC_PARAM_NODE)); } return true; }
Source:
private String getCommentGiverNameFromEmail(String giverEmail) { if (Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT.equals(giverEmail)) { return Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT; } if (commentGiverEmailToNameTable.get(giverEmail) == null) { return giverEmail; } return commentGiverEmailToNameTable.get(giverEmail); }

Target:
private String getCommentGiverNameFromEmail(String giverEmail) { if (Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT.equals(giverEmail)) { return Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT; } return commentGiverEmailToNameTable.get(giverEmail); }
Source:
public void assertHasSuperclass(AssertionInfo info, Class<?> actual, Class<?> superclass) { assertNotNull(info, actual); Class<?> actualSuperclass = actual.getSuperclass(); if (actualSuperclass == null && superclass != null || actualSuperclass != null && !actualSuperclass.equals(superclass)) { throw failures.failure(info, shouldHaveSuperclass(actual, superclass)); } }

Target:
public void assertHasSuperclass(AssertionInfo info, Class<?> actual, Class<?> superclass) { assertNotNull(info, actual); Class<?> actualSuperclass = actual.getSuperclass(); if ((actualSuperclass == null && superclass != null) || (actualSuperclass != null && !actualSuperclass.equals(superclass))) { throw failures.failure(info, shouldHaveSuperclass(actual, superclass)); } }
Source:
public void setLocale(String locale) { text.setLocale(locale); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { LayoutParams params = (LayoutParams) divider.getLayoutParams(); if (isLangRTL(locale)) { params.gravity = Gravity.RIGHT; } else { params.gravity = Gravity.LEFT; } divider.setLayoutParams(params); } }

Target:
public void setLocale(String locale) { text.setLocale(locale); LayoutParams params = (LayoutParams) divider.getLayoutParams(); if (isLangRTL(locale)) { params.gravity = Gravity.RIGHT; } else { params.gravity = Gravity.LEFT; } divider.setLayoutParams(params); }
Source:
public StreamsDatum processLine(String line) { String[] fields = line.split(hdfsConfiguration.getFieldDelimiter()); if( fields.length == 0) return null; String id = null; DateTime ts = null; Map<String, Object> metadata = null; String json = null; if( hdfsConfiguration.getFields().contains( HdfsConstants.DOC ) && fields.length > hdfsConfiguration.getFields().indexOf(HdfsConstants.DOC)) { json = fields[hdfsConfiguration.getFields().indexOf(HdfsConstants.DOC)]; } if( hdfsConfiguration.getFields().contains( HdfsConstants.ID ) && fields.length > hdfsConfiguration.getFields().indexOf(HdfsConstants.ID)) { id = fields[hdfsConfiguration.getFields().indexOf(HdfsConstants.ID)]; } if( hdfsConfiguration.getFields().contains( HdfsConstants.TS ) && fields.length > hdfsConfiguration.getFields().indexOf(HdfsConstants.TS)) { ts = parseTs(fields[hdfsConfiguration.getFields().indexOf(HdfsConstants.TS)]); } if( hdfsConfiguration.getFields().contains( HdfsConstants.META ) && fields.length > hdfsConfiguration.getFields().indexOf(HdfsConstants.META)) { metadata = parseMap(fields[hdfsConfiguration.getFields().indexOf(HdfsConstants.META)]); } StreamsDatum datum = new StreamsDatum(json); datum.setId(id); datum.setTimestamp(ts); datum.setMetadata(metadata); return datum; }

Target:
public StreamsDatum processLine(String line) { String[] expectedFields = hdfsConfiguration.getFields(); String[] parsedFields = line.split(hdfsConfiguration.getFieldDelimiter()); if( fields.length == 0) return null; String id = null; DateTime ts = null; Map<String, Object> metadata = null; String json = null; if( expectedFields.contains( HdfsConstants.DOC ) && parsedFields.length > expectedFields.indexOf(HdfsConstants.DOC)) { json = parsedFields[expectedFields.indexOf(HdfsConstants.DOC)]; } if( expectedFields.contains( HdfsConstants.ID ) && parsedFields.length > expectedFields.indexOf(HdfsConstants.ID)) { id = parsedFields[expectedFields.indexOf(HdfsConstants.ID)]; } if( expectedFields.contains( HdfsConstants.TS ) && parsedFields.length > expectedFields.indexOf(HdfsConstants.TS)) { ts = parseTs(parsedFields[expectedFields.indexOf(HdfsConstants.TS)]); } if( expectedFields.contains( HdfsConstants.META ) && parsedFields.length > expectedFields.indexOf(HdfsConstants.META)) { metadata = parseMap(parsedFields[expectedFields.indexOf(HdfsConstants.META)]); } StreamsDatum datum = new StreamsDatum(json); datum.setId(id); datum.setTimestamp(ts); datum.setMetadata(metadata); return datum; }
Source:
private void createTable() { TableRow row; List<OperationParameter> operationParameters = operation.getOperationProperties().getOperationParameters(); if (operationParameters != null) { for (OperationParameter operationParameter : operationParameters) { switch (operationParameter.getType()) { case "string": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_TEXT); break; } case "int": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER); break; } case "float": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; } default: { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_toggle, null); SwitchCompat data = (SwitchCompat) row.findViewById(R.id.data); data.setChecked(operationParameter.getDefaultValue().equals("true")); break; } } TextView name = (TextView) row.findViewById(R.id.name); name.setText(operationParameter.getName()); table.addView(row); } table.requestLayout(); } }

Target:
private void createTable() { TableRow row = null; List<OperationParameter> operationParameters = operation.getOperationProperties().getOperationParameters(); if (operationParameters != null) { for (OperationParameter operationParameter : operationParameters) { switch (operationParameter.getType()) { case "string": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_TEXT); break; } case "int": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER); break; } case "float": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(operationParameter.getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; } case "bool": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_toggle, null); SwitchCompat data = (SwitchCompat) row.findViewById(R.id.data); data.setChecked(operationParameter.getDefaultValue().equals("true")); break; } } if (row != null) { TextView name = (TextView) row.findViewById(R.id.name); name.setText(operationParameter.getName()); table.addView(row); } } table.requestLayout(); } }