auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static boolean isValidAlarms(final List<Alarm> alarms, final DateTime now, final DateTimeZone timeZone){ final Set<Integer> alarmDays = new HashSet<Integer>(); for(final Alarm alarm: alarms){ <START> if(alarm.isSmart) { <END> if(alarm.isRepeated) { for (final Integer dayOfWeek : alarm.dayOfWeek) { if (alarmDays.contains(dayOfWeek)) { return false; } else { alarmDays.add(dayOfWeek); } } }else{ if (!isValidNoneRepeatedAlarm(alarm)) { return false; } final DateTime expectedRingTime = new DateTime(alarm.year, alarm.month, alarm.day, alarm.hourOfDay, alarm.minuteOfHour, timeZone); if(alarmDays.contains(expectedRingTime.getDayOfWeek())){ return false; }else{ alarmDays.add(expectedRingTime.getDayOfWeek()); } } }else{ if(!alarm.isRepeated) { if (!isValidNoneRepeatedAlarm(alarm)) { return false; } } } } return true; }</code><technical_language>a lot of nested ifs, simplify</technical_language>

Target:
public static boolean isValidAlarms(final List<Alarm> alarms, final DateTime now, final DateTimeZone timeZone){ final Set<Integer> alarmDays = new HashSet<Integer>(); for(final Alarm alarm: alarms){ if(!alarm.isRepeated){ if (!isValidNoneRepeatedAlarm(alarm)) { return false; } if(alarm.isSmart){ final DateTime expectedRingTime = new DateTime(alarm.year, alarm.month, alarm.day, alarm.hourOfDay, alarm.minuteOfHour, timeZone); if(alarmDays.contains(expectedRingTime.getDayOfWeek())){ return false; } alarmDays.add(expectedRingTime.getDayOfWeek()); } }else{ if(!alarm.isSmart) { continue; } for (final Integer dayOfWeek : alarm.dayOfWeek) { if (alarmDays.contains(dayOfWeek)) { return false; } alarmDays.add(dayOfWeek); } } } return true; }
Source:
<code>void imageIncoming(ImageReaderProxy imageReader) { synchronized (mLock) { if (mClosed) { return; } ImageProxy image = null; try { image = imageReader.acquireNextImage(); } catch (IllegalStateException e) { Log.e(TAG, "Failed to acquire latest image.", e); } finally { if (image != null) { <START> Object tag = image.getImageInfo().getTag(); <END> if (tag instanceof List && !((List<Object>) tag).isEmpty()) { for (Integer captureId: mCaptureIdList) { for (Object intObj: (List<Object>) tag) { if ((Integer) intObj == captureId) { mSettableImageProxyBundle.addImageProxy(image, captureId); } } } } else if (tag instanceof Integer) { if (!mCaptureIdList.contains(tag)) { Log.w(TAG, "ImageProxyBundle does not contain this id: " + tag); image.close(); return; } mSettableImageProxyBundle.addImageProxy(image); } else { Log.w(TAG, "ImageProxyBundle does not contain this id: " + tag); image.close(); return; } } } } }</code><technical_language>Yep, Leo is I meant</technical_language>

Target:
void imageIncoming(ImageReaderProxy imageReader) { synchronized (mLock) { if (mClosed) { return; } ImageProxy image = null; try { image = imageReader.acquireNextImage(); } catch (IllegalStateException e) { Log.e(TAG, "Failed to acquire latest image.", e); } finally { if (image != null) { Object tag = image.getImageInfo().getTag(); if (tag instanceof List && !((List<Object>) tag).isEmpty()) { for (Integer captureId: mCaptureIdList) { if (((List<Object>) tag).contains(captureId)) { mSettableImageProxyBundle.addImageProxy(image, captureId); } else { image.close(); return; } } } else if (tag instanceof Integer) { if (!mCaptureIdList.contains(tag)) { Log.w(TAG, "ImageProxyBundle does not contain this id: " + tag); image.close(); return; } mSettableImageProxyBundle.addImageProxy(image); } else { Log.w(TAG, "ImageProxyBundle does not contain this id: " + tag); image.close(); return; } } } } }
Source:
<code>public void shouldGenerateVepAnnotations() throws Exception { String databaseName = mongoRule.restoreDumpInTemporaryDatabase(getResourceUrl(MONGO_DUMP)); String outputDirAnnot = temporaryFolderRule.getRoot().getAbsolutePath(); File vepOutput = new File(URLHelper.resolveVepOutput(outputDirAnnot, STUDY_ID, FILE_ID)); JobParameters jobParameters = new EvaJobParameterBuilder() .collectionVariantsName("variants") .databaseName(databaseName) .inputFasta("") .inputStudyId(STUDY_ID) .inputVcfId(FILE_ID) .outputDirAnnotation(outputDirAnnot) .vepCachePath("") .vepCacheSpecies("") .vepCacheVersion("") .vepNumForks("") .vepPath(getResource(MOCKVEP).getPath()) .vepTimeout("60") .toJobParameters(); JobExecution jobExecution = jobLauncherTestUtils .launchStep(BeanNames.GENERATE_VEP_ANNOTATION_STEP, jobParameters); assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); assertTrue(vepOutput.exists()); int EXTRA_ANNOTATIONS = 1; assertEquals(300 + EXTRA_ANNOTATIONS, <START> JobTestUtils.getLines(new GZIPInputStream(new FileInputStream(vepOutput)))); <END> }</code><technical_language>please explain this number changed drastically</technical_language>

Target:
public void shouldGenerateVepAnnotations() throws Exception { String databaseName = mongoRule.restoreDumpInTemporaryDatabase(getResourceUrl(MONGO_DUMP)); String outputDirAnnot = temporaryFolderRule.getRoot().getAbsolutePath(); File vepOutput = new File(URLHelper.resolveVepOutput(outputDirAnnot, STUDY_ID, FILE_ID)); JobParameters jobParameters = new EvaJobParameterBuilder() .collectionVariantsName("variants") .databaseName(databaseName) .inputFasta("") .inputStudyId(STUDY_ID) .inputVcfId(FILE_ID) .outputDirAnnotation(outputDirAnnot) .vepCachePath("") .vepCacheSpecies("") .vepCacheVersion("") .vepNumForks("4") .vepPath(getResource(MOCKVEP).getPath()) .vepTimeout("60") .toJobParameters(); JobExecution jobExecution = jobLauncherTestUtils .launchStep(BeanNames.GENERATE_VEP_ANNOTATION_STEP, jobParameters); assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); assertTrue(vepOutput.exists()); assertEquals(300 + EXTRA_ANNOTATIONS, JobTestUtils.getLines(new GZIPInputStream(new FileInputStream(vepOutput)))); }
Source:
<code>public Boolean getBoolean() { if (byteBuffer.position() + 1 > limit) { throw new LimitReachedException(); } <START> return byteBuffer.get() == 0 ? Boolean.FALSE : Boolean.TRUE; <END> }</code><technical_language>need a cast byte: "byteBuffer.get() == (byte) 0"</technical_language>

Target:
public Boolean getBoolean() { if (byteBuffer.position() + 1 > limit) { throw new LimitReachedException(); } return byteBuffer.get() == (byte) 0 ? Boolean.FALSE : Boolean.TRUE; }
Source:
<code>public AnalysisResult<IRevision> analyze(IRevision revision) { List<IRevisionPair> javaFiles = revision.getChildren(); Map<String, Diff> diffOfFiles = new HashMap<>(); log.info("\n*****\nCommit: " + revision.getName()); for (IRevisionPair<String> fileFromRevision : javaFiles) { String left = fileFromRevision.getPreviousVersion(); String right = fileFromRevision.getNextVersion(); String leftName = fileFromRevision.getPreviousName(); String rightName = fileFromRevision.getName(); Diff diff = compare(left, right, leftName, rightName); if (diff != null) { diffOfFiles.put(fileFromRevision.getName(), diff); } DiffRowGenerator generator = DiffRowGenerator.create() .showInlineDiffs(true) .inlineDiffByWord(true) .oldTag(f -> "~") .newTag(f -> "**") .build(); List<DiffRow> rows = null; try { rows = generator.generateDiffRows( Arrays.asList("This is a test senctence.", "This is the second line.", "And here is the finish."), Arrays.asList("This is a test for diffutils.", "This is the second line.")); } catch (DiffException e) { e.printStackTrace(); } <START> System.out.println("|original|new|"); <END> System.out.println("|--------|---|"); for (DiffRow row : rows) { System.out.println("|" + row.getOldLine() + "|" + row.getNewLine() + "|"); } } return new DiffResult<IRevision, Diff>(revision, diffOfFiles); }</code><technical_language>this snippet good</technical_language>

Target:
public AnalysisResult analyze(IRevision revision) { List<IRevisionPair> javaFiles = revision.getChildren(); Map<String, Diff> diffOfFiles = new HashMap<>(); List<DiffRow> rows = null; log.info("\n*****\nCommit: " + revision.getName()); for (IRevisionPair<String> fileFromRevision : javaFiles) { String left = fileFromRevision.getPreviousVersion(); String right = fileFromRevision.getNextVersion(); String leftName = fileFromRevision.getPreviousName(); String rightName = fileFromRevision.getName(); Diff diff = compare(left, right, leftName, rightName); if (diff != null) { diffOfFiles.put(fileFromRevision.getName(), diff); } DiffRowGenerator generator = DiffRowGenerator.create() .showInlineDiffs(false) .inlineDiffByWord(false) .ignoreWhiteSpaces(true) .build(); try { rows = generator.generateDiffRows( Arrays.stream(fileFromRevision.getPreviousVersion().split("\n")).collect(Collectors.toList()), Arrays.stream(fileFromRevision.getNextVersion().split("\n")).collect(Collectors.toList())); } catch (DiffException e) { e.printStackTrace(); } } return (new DiffResult<IRevision, Diff>(revision, diffOfFiles,rows)); }
Source:
<code>private void verifyLowVersionLogsError(String lowVersion) { Logger log = Mockito.mock(Logger.class); String expectedMessage = "The minimum supported version is " + PostgresVersionCheck.MIN_POSTGRES_VERSION; try { <START> PostgresVersionCheck.checkDatabaseVersion(lowVersion, log); <END> Assert.fail("Expected an AssertionError"); } catch (AssertionError error) { Assert.assertTrue("Error did not contain expected message. Actual error: " + error, error.getMessage().contains(expectedMessage)); } Mockito.verify(log).error( eq("Assertion with exception "), contains(expectedMessage), Mockito.any(Exception.class)); Mockito.verifyNoMoreInteractions(log); }</code><technical_language>nit: this junit asserts, assertJ asserts please + if static import mockito stuff</technical_language>

Target:
private void verifyLowVersionLogsError(String lowVersion) { Logger log = mock(Logger.class); String expectedMessage = "The minimum supported version is " + PostgresVersionCheck.MIN_POSTGRES_VERSION; assertThatThrownBy(() -> PostgresVersionCheck.checkDatabaseVersion(lowVersion, log)) .isInstanceOf(AssertionError.class) .hasMessageContaining(expectedMessage); verify(log).error( eq("Assertion with exception "), contains(expectedMessage), Mockito.any(Exception.class)); verifyNoMoreInteractions(log); }
Source:
<code>private SubPlan buildFragment(PlanNode root, FragmentProperties properties, PlanFragmentId fragmentId) { List<PlanNodeId> schedulingOrder = scheduleOrder(root); checkArgument( properties.getPartitionedSources().equals(ImmutableSet.copyOf(schedulingOrder)), "Expected scheduling order (%s) to contain an entry for all partitioned sources (%s)", schedulingOrder, properties.getPartitionedSources()); Map<Symbol, Type> fragmentSymbolTypes = filterKeys(symbolAllocator.getTypes().allTypes(), in(extractOutputSymbols(root))); planSanityChecker.validatePlanFragment(root, session, metadata, sqlParser, TypeProvider.viewOf(fragmentSymbolTypes), warningCollector); Set<PlanNodeId> tableWriterNodeIds = getTableWriterNodeIds(root); boolean outputTableWriterFragment = tableWriterNodeIds.stream().anyMatch(outputTableWriterNodeIds::contains); if (outputTableWriterFragment) { verify( outputTableWriterNodeIds.containsAll(tableWriterNodeIds), <START> "outputTableWriterNodeIds %s must include all tableWriterNodeIds %s", <END> outputTableWriterNodeIds, tableWriterNodeIds); } PlanFragment fragment = new PlanFragment( fragmentId, root, fragmentSymbolTypes, properties.getPartitioningHandle(), schedulingOrder, properties.getPartitioningScheme(), StageExecutionDescriptor.ungroupedExecution(), outputTableWriterFragment, statsAndCosts.getForSubplan(root), Optional.of(jsonFragmentPlan(root, fragmentSymbolTypes, metadata.getFunctionManager(), session))); return new SubPlan(fragment, properties.getChildren()); }</code><technical_language>nit: "outputTableWriterNodeIds %s include of tableWriterNodeIds %s"</technical_language>

Target:
private SubPlan buildFragment(PlanNode root, FragmentProperties properties, PlanFragmentId fragmentId) { List<PlanNodeId> schedulingOrder = scheduleOrder(root); checkArgument( properties.getPartitionedSources().equals(ImmutableSet.copyOf(schedulingOrder)), "Expected scheduling order (%s) to contain an entry for all partitioned sources (%s)", schedulingOrder, properties.getPartitionedSources()); Map<Symbol, Type> fragmentSymbolTypes = filterKeys(symbolAllocator.getTypes().allTypes(), in(extractOutputSymbols(root))); planSanityChecker.validatePlanFragment(root, session, metadata, sqlParser, TypeProvider.viewOf(fragmentSymbolTypes), warningCollector); Set<PlanNodeId> tableWriterNodeIds = getTableWriterNodeIds(root); boolean outputTableWriterFragment = tableWriterNodeIds.stream().anyMatch(outputTableWriterNodeIds::contains); if (outputTableWriterFragment) { verify( outputTableWriterNodeIds.containsAll(tableWriterNodeIds), "outputTableWriterNodeIds %s must include either all or none of tableWriterNodeIds %s", outputTableWriterNodeIds, tableWriterNodeIds); } PlanFragment fragment = new PlanFragment( fragmentId, root, fragmentSymbolTypes, properties.getPartitioningHandle(), schedulingOrder, properties.getPartitioningScheme(), StageExecutionDescriptor.ungroupedExecution(), outputTableWriterFragment, statsAndCosts.getForSubplan(root), Optional.of(jsonFragmentPlan(root, fragmentSymbolTypes, metadata.getFunctionManager(), session))); return new SubPlan(fragment, properties.getChildren()); }
Source:
<code>public void processEvent(EventSummary summary) { if (this.enabled) { <START> int eventSev = summary.getOccurrence(0).getSeverity().getNumber(); <END> if( eventSev >= this.minSeverity.getNumber()) { this.processEventSummary(summary); } } }</code><technical_language>Consider this.minSeverity.compareTo(summary.getOccurrence(0).getSeverity())</technical_language>

Target:
public void processEvent(EventSummary summary) { if (this.enabled) { EventSeverity sev = summary.getOccurrence(0).getSeverity(); if (sev.compareTo(this.minSeverity) >= 0 ) { this.processEventSummary(summary); } else { this.irrelevantSeverityCounter.inc(); } } }
Source:
<code>protected boolean loadNextFromDisk() { <START> return fromDisk; <END> }</code><technical_language>Is a clearer do this? :)</technical_language>

Target:
protected boolean loadNextFromDisk() { return true; }
Source:
<code>private static void refreshBorderedStyle(final StyledFigure styledFigure, final BorderedStyle borderedStyle) { if (borderedStyle.getBorderSize().intValue() == 0) { styledFigure.setBorder(null); } else { LineBorder lineBorder = null; if (styledFigure.getBorder() instanceof LineBorder) { lineBorder = (LineBorder) styledFigure.getBorder(); } else { lineBorder = new LineBorder(); styledFigure.setBorder(lineBorder); } if (styledFigure instanceof Shape) { ((Shape) styledFigure).setLineWidth(0); } int <START> borderedSize = <END> 0; if (borderedStyle.getBorderSize() != null) { borderedSize = borderedStyle.getBorderSize().intValue(); } lineBorder.setWidth(borderedSize); if (borderedStyle.getBorderColor() != null) { lineBorder.setColor(VisualBindingManager.getDefault().getColorFromRGBValues(borderedStyle.getBorderColor())); } if (borderedStyle.getBorderSize() != null && borderedStyle.getBorderSize().intValue() == 0) { styledFigure.setBorder(null); } } }</code><technical_language>name borderSize</technical_language>

Target:
private static void refreshBorderedStyle(final StyledFigure styledFigure, final BorderedStyle borderedStyle) { if (borderedStyle.getBorderSize().intValue() == 0) { styledFigure.setBorder(null); } else { LineBorder lineBorder = null; if (styledFigure.getBorder() instanceof LineBorder) { lineBorder = (LineBorder) styledFigure.getBorder(); } else { lineBorder = new LineBorder(); styledFigure.setBorder(lineBorder); } if (styledFigure instanceof Shape) { ((Shape) styledFigure).setLineWidth(0); } int borderSize = 0; if (borderedStyle.getBorderSize() != null) { borderSize = borderedStyle.getBorderSize().intValue(); } lineBorder.setWidth(borderSize); if (borderedStyle.getBorderColor() != null) { lineBorder.setColor(VisualBindingManager.getDefault().getColorFromRGBValues(borderedStyle.getBorderColor())); } if (borderedStyle.getBorderSize() != null && borderSize == 0) { styledFigure.setBorder(null); } } }
Source:
<code>public List<Field> getLayoutFieldsToCreateOrUpdate() { try { if (notStrictFieldLayoutRowSyntaxValidator == null) { notStrictFieldLayoutRowSyntaxValidator = new NotStrictFieldLayoutRowSyntaxValidator(this.contentType, this.fields); notStrictFieldLayoutRowSyntaxValidator.validate(); } return notStrictFieldLayoutRowSyntaxValidator.getLayoutFieldsToCreateOrUpdate(); <START> } catch (FieldLayoutValidationException e) { <END> throw new DotRuntimeException(e); } }</code><technical_language>log Identifier name of Content Type in error</technical_language>

Target:
public List<Field> getLayoutFieldsToCreateOrUpdate() { try { if (notStrictFieldLayoutRowSyntaxValidator == null) { notStrictFieldLayoutRowSyntaxValidator = new NotStrictFieldLayoutRowSyntaxValidator(this.contentType, this.fields); notStrictFieldLayoutRowSyntaxValidator.validate(); } return notStrictFieldLayoutRowSyntaxValidator.getLayoutFieldsToCreateOrUpdate(); } catch (FieldLayoutValidationException e) { Logger.error(FieldLayout.class, e.getMessage()); throw new DotRuntimeException(e); } }
Source:
<code>private int copyRecursive(QuantileDigest other, int otherNode) { int node = createNode(other.values[otherNode], other.levels[otherNode], other.counts[otherNode]); if (other.lefts[otherNode] != -1) { <START> int left = copyRecursive(other, other.lefts[otherNode]); <END> lefts[node] = left; } if (other.rights[otherNode] != -1) { int right = copyRecursive(other, other.rights[otherNode]); rights[node] = right; } return node; }</code><technical_language>add note variable</technical_language>

Target:
private int copyRecursive(QuantileDigest other, int otherNode) { checkArgument(otherNode != -1, "otherNode is -1"); int node = createNode(other.values[otherNode], other.levels[otherNode], other.counts[otherNode]); if (other.lefts[otherNode] != -1) { int left = copyRecursive(other, other.lefts[otherNode]); lefts[node] = left; } if (other.rights[otherNode] != -1) { int right = copyRecursive(other, other.rights[otherNode]); rights[node] = right; } return node; }
Source:
<code>public void run() { try (PickledGraphite pickledGraphite = new PickledGraphite( graphiteEmitterConfig.getHostname(), graphiteEmitterConfig.getPort(), graphiteEmitterConfig.getBatchSize() )) { if (!pickledGraphite.isConnected()) { log.info("trying to connect to graphite server"); pickledGraphite.connect(); } while (eventsQueue.size() > 0 && !exec.isShutdown()) { try { final GraphiteEvent graphiteEvent = eventsQueue.poll( graphiteEmitterConfig.getWaitForEventTime(), TimeUnit.MILLISECONDS ); if (graphiteEvent != null) { log.debug( "sent [%s] with value [%s] and time [%s]", graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); pickledGraphite.send( graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); } } catch (InterruptedException | IOException e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } else if (e instanceof SocketException) { pickledGraphite.close(); <START> log.info("had exception [%s] trying to re-connect to graphite server", e.getMessage()); <END> pickledGraphite.connect(); } } } } catch (Exception e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } } }</code><technical_language>exception is logged a lines above, this logging statement "trying re-connect.."</technical_language>

Target:
public void run() { try (PickledGraphite pickledGraphite = new PickledGraphite( graphiteEmitterConfig.getHostname(), graphiteEmitterConfig.getPort(), graphiteEmitterConfig.getBatchSize() )) { if (!pickledGraphite.isConnected()) { log.info("trying to connect to graphite server"); pickledGraphite.connect(); } while (eventsQueue.size() > 0 && !exec.isShutdown()) { try { final GraphiteEvent graphiteEvent = eventsQueue.poll( graphiteEmitterConfig.getWaitForEventTime(), TimeUnit.MILLISECONDS ); if (graphiteEvent != null) { log.debug( "sent [%s] with value [%s] and time [%s]", graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); pickledGraphite.send( graphiteEvent.getEventPath(), graphiteEvent.getValue(), graphiteEvent.getTimestamp() ); } } catch (InterruptedException | IOException e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); break; } else if (e instanceof SocketException) { pickledGraphite.close(); log.warn("Trying to re-connect to graphite server"); pickledGraphite.connect(); } } } } catch (Exception e) { log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } } }
Source:
<code>protected ITextViewer getTextViewerForTarget(String name) throws Exception { IFile targetFile = project.getFile(name + ".target"); targetFile.create( <START> GenericEditorExtenionTestsPlugin.getBundleContext().getBundle() <END> .getEntry("testing-files/target-files/" + name + ".txt").openStream(), true, new NullProgressMonitor()); IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), targetFile, "org.eclipse.ui.genericeditor.GenericEditor"); return (ITextViewer) editor.getAdapter(ITextOperationTarget.class); }</code><technical_language>replace this FrameworkUtil.getBundle(Class) remove activator some penalty bundle loading time</technical_language>

Target:
protected ITextViewer getTextViewerForTarget(String name) throws Exception { IFile targetFile = project.getFile(name + ".target"); targetFile.create(FrameworkUtil.getBundle(this.getClass()) .getEntry("testing-files/target-files/" + name + ".txt").openStream(), true, new NullProgressMonitor()); IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), targetFile, "org.eclipse.ui.genericeditor.GenericEditor"); return (ITextViewer) editor.getAdapter(ITextOperationTarget.class); }
Source:
<code>public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(WAP_PUSH_RECEIVED_ACTION)) { String mimeType = intent.getType(); if (mimeType.equals(CONTENT_MIME_TYPE_B_EMN)) { byte[] wbxml = intent.getByteArrayExtra("data"); if (wbxml == null) { return; } String emailAddress = decode(wbxml); <START> if (emailAddress!=null && !TextUtils.isEmpty(emailAddress)) { <END> if (Email.DEBUG) { Log.d(Email.LOG_TAG, "CONTENT_MIME_TYPE_B_EMN " + "received for email " + emailAddress); } MailService.actionCheckMail(context, emailAddress); } } } }</code><technical_language>TextUtils.isEmpty is nice null check for you. need is if (!TextUtils.isEmpty(...)) {</technical_language>

Target:
public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(WAP_PUSH_RECEIVED_ACTION)) { String mimeType = intent.getType(); if (mimeType.equals(CONTENT_MIME_TYPE_B_EMN)) { byte[] wbxml = intent.getByteArrayExtra("data"); if (wbxml == null) { return; } String emailAddress = decode(wbxml); if (!TextUtils.isEmpty(emailAddress)) { if (Email.DEBUG) { Log.d(Email.LOG_TAG, "CONTENT_MIME_TYPE_B_EMN " + "received for email " + emailAddress); } MailService.actionCheckMail(context, emailAddress); } } } }
Source:
<code>public void handleStateTransferState(XSiteStatePushCommand cmd) throws Exception { if (local) { LocalInvocation.newInstanceFromCache(cache, cmd).call(); return; } final ClusteringDependentLogic clusteringDependentLogic = cache.getAdvancedCache().getComponentRegistry() .getComponent(ClusteringDependentLogic.class); <START> final Map<Address, List<XSiteState>> primaryOwnersChunks = new HashMap<Address, List<XSiteState>>(); <END> for (XSiteState state : cmd.getChunk()) { final Address primaryOwner = clusteringDependentLogic.getPrimaryOwner(state.key()); List<XSiteState> primaryOwnerList = primaryOwnersChunks.get(primaryOwner); if (primaryOwnerList == null) { primaryOwnerList = new LinkedList<XSiteState>(); primaryOwnersChunks.put(primaryOwner, primaryOwnerList); } primaryOwnerList.add(state); } final List<XSiteState> localChunks = primaryOwnersChunks.remove(clusteringDependentLogic.getAddress()); final List<Future<?>> remoteFutures = new ArrayList<Future<?>>(primaryOwnersChunks.size()); for (Map.Entry<Address, List<XSiteState>> entry : primaryOwnersChunks.entrySet()) { sendStateTo(entry.getKey(), entry.getValue(), remoteFutures); } if (localChunks != null) { LocalInvocation.newInstanceFromCache(cache, newStatePushCommand(localChunks)).call(); localChunks.clear(); } primaryOwnersChunks.clear(); for (Future<?> future : remoteFutures) { future.get(); } }</code><technical_language>I giving node entries for is a primary owner is ok, is guarantee node primary owner receives state. I instead start transactions site master - slower, safer</technical_language>

Target:
public void handleStateTransferState(XSiteStatePushCommand cmd) throws Exception { final ClusteringDependentLogic clusteringDependentLogic = cache.getAdvancedCache().getComponentRegistry() .getComponent(ClusteringDependentLogic.class); final Map<Address, List<XSiteState>> primaryOwnersChunks = new HashMap<Address, List<XSiteState>>(); for (XSiteState state : cmd.getChunk()) { final Address primaryOwner = clusteringDependentLogic.getPrimaryOwner(state.key()); List<XSiteState> primaryOwnerList = primaryOwnersChunks.get(primaryOwner); if (primaryOwnerList == null) { primaryOwnerList = new LinkedList<XSiteState>(); primaryOwnersChunks.put(primaryOwner, primaryOwnerList); } primaryOwnerList.add(state); } final List<XSiteState> localChunks = primaryOwnersChunks.remove(clusteringDependentLogic.getAddress()); final List<Future<?>> remoteFutures = new ArrayList<Future<?>>(primaryOwnersChunks.size()); for (Map.Entry<Address, List<XSiteState>> entry : primaryOwnersChunks.entrySet()) { sendStateTo(entry.getKey(), entry.getValue(), remoteFutures); } if (localChunks != null) { LocalInvocation.newInstanceFromCache(cache, newStatePushCommand(localChunks)).call(); localChunks.clear(); } primaryOwnersChunks.clear(); for (Future<?> future : remoteFutures) { future.get(); } }
Source:
<code><START> public boolean isDomainController() { <END> Result res = getASConnection().execute(new ReadAttribute(new Address("/"), "process-type")); if (res.isSuccess()) { return res.getResult().toString().equals("Domain Controller"); } return false; }</code><technical_language>iirc a HC spontaneously a DC, I if cache this data. Otoh, this is a light-weight call done often, warrant hassle of cache invalidation checks</technical_language>

Target:
public synchronized boolean isDomainController() { return domainController; }
Source:
<code>public void setup() { when(gridWidget.getModel()).thenReturn(gridData); when(gridWidget.getRendererHelper()).thenReturn(baseGridRendererHelperMock); when(baseGridRendererHelperMock.getRenderingInformation()).thenReturn(baseGridRendererInformationMock); when(gridData.getColumns()).thenReturn(Collections.singletonList(gridColumn)); when(gridColumn.getIndex()).thenReturn(0); when(gridWidget.getRenderer()).thenReturn(gridRenderer); when(layer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, BOUNDS_WIDTH, BOUNDS_HEIGHT)); baseKeyboardOperationSpy = spy(new BaseKeyboardOperation(layer) { @Override public int getKeyCode() { return currentKeyCode; } @Override <START> public TriStateBoolean isControlKeyDown() { <END> return super.isControlKeyDown(); } @Override public boolean perform(GridWidget gridWidget, boolean isShiftKeyDown, boolean isControlKeyDown) { return false; } }); }</code><technical_language>Is this override needed</technical_language>

Target:
public void setup() { when(gridWidget.getModel()).thenReturn(gridData); when(gridWidget.getRendererHelper()).thenReturn(baseGridRendererHelperMock); when(baseGridRendererHelperMock.getRenderingInformation()).thenReturn(baseGridRendererInformationMock); when(gridData.getColumns()).thenReturn(Collections.singletonList(gridColumn)); when(gridColumn.getIndex()).thenReturn(0); when(gridWidget.getRenderer()).thenReturn(gridRenderer); when(layer.getViewport()).thenReturn(viewport); when(layer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, BOUNDS_WIDTH, BOUNDS_HEIGHT)); transform = spy(new Transform()); when(viewport.getTransform()).thenReturn(transform); baseKeyboardOperationSpy = spy(new BaseKeyboardOperation(layer) { @Override public int getKeyCode() { return currentKeyCode; } @Override public boolean perform(GridWidget gridWidget, boolean isShiftKeyDown, boolean isControlKeyDown) { return false; } }); }
Source:
<code><START> public FeedbackQuestionAttributes(FeedbackQuestionAttributes other) { <END> this.feedbackQuestionId = other.getId(); this.feedbackSessionName = other.getFeedbackSessionName(); this.courseId = other.getCourseId(); this.creatorEmail = other.getCreatorEmail(); this.questionMetaData = other.getQuestionMetaData(); this.questionNumber = other.getQuestionNumber(); this.questionType = other.getQuestionType(); this.giverType = other.getGiverType(); this.recipientType = other.getRecipientType(); this.numberOfEntitiesToGiveFeedbackTo = other.getNumberOfEntitiesToGiveFeedbackTo(); this.showResponsesTo = new ArrayList<FeedbackParticipantType>(other.getShowResponsesTo()); this.showGiverNameTo = new ArrayList<FeedbackParticipantType>(other.getShowGiverNameTo()); this.showRecipientNameTo = new ArrayList<FeedbackParticipantType>(other.getShowRecipientNameTo()); this.createdAt = other.getCreatedAt(); this.updatedAt = other.getUpdatedAt(); removeIrrelevantVisibilityOptions(); }</code><technical_language>a thought, if a getCopy method copy-constructor private? like: java public FeedbackQuestionAttributes getCopy() { return new FeedbackQuestionAttributes(this); } private FeedbackQuestionAttributes(FeedbackQuestionAttributes other) { // this method }</technical_language>

Target:
private FeedbackQuestionAttributes(FeedbackQuestionAttributes other) { this.feedbackQuestionId = other.getId(); this.feedbackSessionName = other.getFeedbackSessionName(); this.courseId = other.getCourseId(); this.creatorEmail = other.getCreatorEmail(); this.questionMetaData = other.getQuestionMetaData(); this.questionNumber = other.getQuestionNumber(); this.questionType = other.getQuestionType(); this.giverType = other.getGiverType(); this.recipientType = other.getRecipientType(); this.numberOfEntitiesToGiveFeedbackTo = other.getNumberOfEntitiesToGiveFeedbackTo(); this.showResponsesTo = new ArrayList<FeedbackParticipantType>(other.getShowResponsesTo()); this.showGiverNameTo = new ArrayList<FeedbackParticipantType>(other.getShowGiverNameTo()); this.showRecipientNameTo = new ArrayList<FeedbackParticipantType>(other.getShowRecipientNameTo()); this.createdAt = other.getCreatedAt(); this.updatedAt = other.getUpdatedAt(); removeIrrelevantVisibilityOptions(); }
Source:
<code>@Test public void testForEachStreamCopy() throws IOException, TimeoutException, ExecutionException, InterruptedException { final QueueFile queueFile = new QueueFile(file); queueFile.add(new byte[] {1, 2}); queueFile.add(new byte[] {3, 4, 5}); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final byte[] buffer = new byte[8]; final QueueFile.ElementReader elementReader = new QueueFile.ElementReader() { @Override public void read(InputStream in, int length) throws IOException { int count; while ((count = in.read(buffer)) != -1) { baos.write(buffer, 0, count); } } }; <START> final ExecutorService executor = Executors.newSingleThreadExecutor(); <END> try { executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { queueFile.forEach(elementReader); return null; } }).get(5, TimeUnit.SECONDS); assertThat(baos.toByteArray()).isEqualTo(new byte[] {1, 2, 3, 4, 5}); } finally { executor.shutdown(); } }</code><technical_language>strive avoid threading in tests. escape hatch in ElementReader impl above? For example, if a count of 0, throw exception, right? work for InputStream, works for this -- expect get a 0, right? change means longer get 0s back</technical_language>

Target:
@Test public void testForEachStreamCopy() throws IOException { final QueueFile queueFile = new QueueFile(file); queueFile.add(new byte[] {1, 2}); queueFile.add(new byte[] {3, 4, 5}); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final byte[] buffer = new byte[8]; final QueueFile.ElementReader elementReader = new QueueFile.ElementReader() { @Override public void read(InputStream in, int length) throws IOException { int count; while ((count = in.read(buffer)) != -1) { if (count == 0) { fail("This test should never receive a result of 0 from InputStream.read(byte[])"); } baos.write(buffer, 0, count); } } }; queueFile.forEach(elementReader); assertThat(baos.toByteArray()).isEqualTo(new byte[] {1, 2, 3, 4, 5}); }
Source:
<code>public List<SurveyQuestionSummary> listByResponse(String questionId, String questionResponse) { String answer = questionResponse; <START> if (answer.length() > Constants.MAX_LENGTH) { <END> answer = answer.substring(0, Constants.MAX_LENGTH); } List<SurveyQuestionSummary> result = null; String cacheKey = null; try { cacheKey = getCacheKey(questionId + "-" + answer); if (MemCacheUtils.containsKey(cache, cacheKey)) { SurveyQuestionSummary sqs = (SurveyQuestionSummary)cache.get(cacheKey); if (sqs != null) { result = new ArrayList<SurveyQuestionSummary>(); result.add(sqs); return result; } } } catch (CacheException e) { log.log(Level.WARNING, e.getMessage()); } PersistenceManager pm = PersistenceFilter.getManager(); javax.jdo.Query query = pm.newQuery(SurveyQuestionSummary.class); StringBuilder filterString = new StringBuilder(); StringBuilder paramString = new StringBuilder(); Map<String, Object> paramMap = null; paramMap = new HashMap<String, Object>(); appendNonNullParam("questionId", filterString, paramString, "String", questionId, paramMap); appendNonNullParam("response", filterString, paramString, "String", answer, paramMap); query.setFilter(filterString.toString()); query.declareParameters(paramString.toString()); result = (List<SurveyQuestionSummary>) query.executeWithMap(paramMap); cache(result); return result; }</code><technical_language>previously do want check answer is null</technical_language>

Target:
public List<SurveyQuestionSummary> listByResponse(String questionId, String questionResponse) { if (questionResponse == null) { return Collections.emptyList(); } String answer = questionResponse; if (answer.length() > Constants.MAX_LENGTH) { answer = answer.substring(0, Constants.MAX_LENGTH); } List<SurveyQuestionSummary> result = null; String cacheKey = null; try { cacheKey = getCacheKey(questionId + "-" + answer); if (MemCacheUtils.containsKey(cache, cacheKey)) { SurveyQuestionSummary sqs = (SurveyQuestionSummary)cache.get(cacheKey); if (sqs != null) { result = new ArrayList<SurveyQuestionSummary>(); result.add(sqs); return result; } } } catch (CacheException e) { log.log(Level.WARNING, e.getMessage()); } PersistenceManager pm = PersistenceFilter.getManager(); javax.jdo.Query query = pm.newQuery(SurveyQuestionSummary.class); StringBuilder filterString = new StringBuilder(); StringBuilder paramString = new StringBuilder(); Map<String, Object> paramMap = null; paramMap = new HashMap<String, Object>(); appendNonNullParam("questionId", filterString, paramString, "String", questionId, paramMap); appendNonNullParam("response", filterString, paramString, "String", answer, paramMap); query.setFilter(filterString.toString()); query.declareParameters(paramString.toString()); result = (List<SurveyQuestionSummary>) query.executeWithMap(paramMap); cache(result); return result; }
Source:
<code>public void testInnerJoinWithFailingSpill(boolean probeHashEnabled, List<WhenSpill> whenSpill, WhenSpillFails whenSpillFails) throws Throwable { DummySpillerFactory buildSpillerFactory = new DummySpillerFactory(); DummySpillerFactory joinSpillerFactory = new DummySpillerFactory(); PartitioningSpillerFactory partitioningSpillerFactory = new GenericPartitioningSpillerFactory(joinSpillerFactory); switch (whenSpillFails) { case SPILL_HBO: buildSpillerFactory.failSpill(); break; case SPILL_LJO: joinSpillerFactory.failSpill(); break; case UNSPILL_HBO: buildSpillerFactory.failUnspill(); break; case UNSPILL_LJO: joinSpillerFactory.failUnspill(); } try { innerJoinWithSpill(probeHashEnabled, whenSpill, buildSpillerFactory, partitioningSpillerFactory); fail("Exception not thrown"); } catch (RuntimeException exception) { String expectedMessage; <START> switch (whenSpillFails) { <END> case SPILL_HBO: case SPILL_LJO: expectedMessage = "Spill failed"; break; default: expectedMessage = "Unspill failed"; } assertEquals(exception.getMessage(), expectedMessage); } }</code><technical_language>guess this is easier read if statement</technical_language>

Target:
public void testInnerJoinWithFailingSpill(boolean probeHashEnabled, List<WhenSpill> whenSpill, WhenSpillFails whenSpillFails) throws Throwable { DummySpillerFactory buildSpillerFactory = new DummySpillerFactory(); DummySpillerFactory joinSpillerFactory = new DummySpillerFactory(); PartitioningSpillerFactory partitioningSpillerFactory = new GenericPartitioningSpillerFactory(joinSpillerFactory); String expectedMessage; switch (whenSpillFails) { case SPILL_BUILD: buildSpillerFactory.failSpill(); expectedMessage = "Spill failed"; break; case SPILL_JOIN: joinSpillerFactory.failSpill(); expectedMessage = "Spill failed"; break; case UNSPILL_BUILD: buildSpillerFactory.failUnspill(); expectedMessage = "Unspill failed"; break; case UNSPILL_JOIN: joinSpillerFactory.failUnspill(); expectedMessage = "Unspill failed"; break; default: throw new IllegalArgumentException(format("Unsupported option: %s", whenSpillFails)); } try { innerJoinWithSpill(probeHashEnabled, whenSpill, buildSpillerFactory, partitioningSpillerFactory); fail("Exception not thrown"); } catch (RuntimeException exception) { assertEquals(exception.getMessage(), expectedMessage); } }
Source:
<code>public void shouldAttemptMethodAndRetry_withExceptionThrownAndRetryEnabledAndMaxAttemptsAdjusted() throws Throwable { final RetryableAspect retryableAspect = new RetryableAspect(); final ProceedingJoinPoint mockProceedingJoinPoint = setupSimpleProceedingJoinPointMock(); <START> final int retryMaxAttempts = randomIntInRange(2, 4); <END> final Retryable mockRetryable = setupMockRetryable(retryMaxAttempts, 2000); RetryableConfiguration.setRetryableEnabled(true); when(mockProceedingJoinPoint.proceed()).thenThrow(new RetryAspectTestException()); RetryAspectTestException actualException = null; try { retryableAspect.attemptMethodAndRetryIfNeeded(mockProceedingJoinPoint, mockRetryable); } catch (final RetryAspectTestException e) { actualException = e; } verify(mockProceedingJoinPoint, times(retryMaxAttempts)).proceed(); assertNotNull(actualException); }</code><technical_language>This variable is wrongly named, maxAttempts. This defines maximum number of times advised method is _attempted_. maxAttempts = 1 means method retried. maxAttempts = 2 means method retried once. maxAttempts = 3 means method retried twice,</technical_language>

Target:
public void shouldAttemptMethodAndRetry_withExceptionThrownAndRetryEnabledAndMaxAttemptsAdjusted() throws Throwable { final RetryableAspect retryableAspect = new RetryableAspect(); final ProceedingJoinPoint mockProceedingJoinPoint = setupSimpleProceedingJoinPointMock(); final int maxAttempts = randomIntInRange(2, 4); final Retryable mockRetryable = setupMockRetryable(maxAttempts, 2000); RetryableConfiguration.setRetryableEnabled(true); when(mockProceedingJoinPoint.proceed()).thenThrow(new RetryAspectTestException()); RetryAspectTestException actualException = null; try { retryableAspect.attemptMethodAndRetryIfNeeded(mockProceedingJoinPoint, mockRetryable); } catch (final RetryAspectTestException e) { actualException = e; } verify(mockProceedingJoinPoint, times(maxAttempts)).proceed(); assertNotNull(actualException); }
Source:
<code>public static void closeSession(Session session) { if (session != null) { try { session.close(); } catch (Exception e) { LOG.error("Failed to close session: ", e); } } else { <START> LOG.warn("Session is null, cannot close"); <END> } }</code><technical_language>Do need this else block</technical_language>

Target:
public static void closeSession(Session session) { if (session != null) { try { session.close(); } catch (Exception e) { LOG.error("Failed to close session: ", e); } } }
Source:
<code>public ActivateDeviceResponse activateDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ActivateDeviceRequest request) throws OsgpException { LOGGER.info("Incoming ActivateDeviceRequest for device: {}.", request.getDeviceIdentification()); try { this.deviceManagementService.activateDeviceRequest(organisationIdentification, request.getDeviceIdentification()); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: while activating device: for organisation {}.", new Object[] { e.getMessage(), request.getDeviceIdentification(), organisationIdentification }, e); <START> throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, <END> new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { LOGGER.error("Exception: while activating device: for organisation {}.", new Object[] { e.getMessage(), request.getDeviceIdentification(), organisationIdentification }, e); this.handleException(e); } final ActivateDeviceResponse response = new ActivateDeviceResponse(); response.setResult(OsgpResultType.OK); return response; }</code><technical_language>I expect COMPONENT_TYPE_WS_ADMIN instead of ComponentType.WS_CORE</technical_language>

Target:
public ActivateDeviceResponse activateDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ActivateDeviceRequest request) throws OsgpException { LOGGER.info("Incoming ActivateDeviceRequest for device: {}.", request.getDeviceIdentification()); try { this.deviceManagementService.activateDeviceRequest(organisationIdentification, request.getDeviceIdentification()); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: while activating device: for organisation {}.", new Object[] { e.getMessage(), request.getDeviceIdentification(), organisationIdentification }, e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, COMPONENT_TYPE_WS_ADMIN, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { LOGGER.error("Exception: while activating device: for organisation {}.", new Object[] { e.getMessage(), request.getDeviceIdentification(), organisationIdentification }, e); this.handleException(e); } final ActivateDeviceResponse response = new ActivateDeviceResponse(); response.setResult(OsgpResultType.OK); return response; }
Source:
<code>public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { spinnerAdapter.getItem(FORMULA_EDITOR_POSITION).setLookName(getFormulaWithBrickField(BrickField .LOOK).getDisplayString(context)); if (isTouchInDropDownView) { isTouchInDropDownView = false; if (paramInt == 0) { switchToLookFragmentFromScriptFragment(); <START> } else if (paramInt == 1) { <END> isFormulaEnabled = true; showFormulaEditorToEditFormula(view.findViewById(R.id.brick_set_look_formula)); } } return spinnerAdapter.getView(paramInt, paramView, paramViewGroup); }</code><technical_language>FORMULA_EDITOR_POSITION</technical_language>

Target:
public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { spinnerAdapter.getItem(SPINNER_POSITION_FORMULA_EDITOR).setLookName(getFormulaWithBrickField(BrickField .LOOK).getDisplayString(context)); if (isTouchInDropDownView) { isTouchInDropDownView = false; if (paramInt == SPINNER_POSITION_NEW_LOOK) { switchToLookFragmentFromScriptFragment(); } else if (paramInt == SPINNER_POSITION_FORMULA_EDITOR) { isFormulaEnabled = true; showFormulaEditorToEditFormula(view.findViewById(R.id.brick_set_look_formula)); } } return spinnerAdapter.getView(paramInt, paramView, paramViewGroup); }
Source:
<code>public void initialize() { for (DoubleSolenoid solenoid : solenoids) { try { <START> solenoid.set(DoubleSolenoid.Value.kForward); <END> } catch (Exception e) { updateStatus(solenoid.getName(), SystemStatus.FAIL, e); } } }</code><technical_language>repeat this set reverse well? Also, important notice this actively fires pistons, want bind check a button</technical_language>

Target:
public void initialize() { for (DoubleSolenoid solenoid : solenoids) { try { solenoid.set(DoubleSolenoid.Value.kForward); } catch (Exception e) { updateStatusFail(solenoid.getName(), e); } } }
Source:
<code>protected Result check() throws Exception { try { <START> dockerClient.info(); <END> return Result.healthy(); } catch (final Exception ex) { return Result.unhealthy(ex); } }</code><technical_language>is a dockerClient.ping()</technical_language>

Target:
protected Result check() throws Exception { try { dockerClient.ping(); return Result.healthy(); } catch (final Exception ex) { return Result.unhealthy(ex); } }
Source:
<code>static Map<String, Object> getAttributes(ManifestElement element, String[] definedAttrs) { Enumeration<String> keys = element.getKeys(); Map<String, Object> arbitraryAttrs = null; if (keys == null) return null; while (keys.hasMoreElements()) { boolean definedAttr = false; String key = keys.nextElement(); for (String <START> definedAttr1 : <END> definedAttrs) { if (definedAttr1.equals(key)) { definedAttr = true; break; } } String value = element.getAttribute(key); int colonIndex = key.indexOf(':'); String type = ATTR_TYPE_STRING; if (colonIndex > 0) { type = key.substring(colonIndex + 1).trim(); key = key.substring(0, colonIndex).trim(); } if (!definedAttr) { if (arbitraryAttrs == null) arbitraryAttrs = new HashMap<>(); arbitraryAttrs.put(key, convertValue(type, value)); } } return arbitraryAttrs; }</code><technical_language>name definedAttr</technical_language>

Target:
static Map<String, Object> getAttributes(ManifestElement element, String[] definedAttrs) { Enumeration<String> keys = element.getKeys(); Map<String, Object> arbitraryAttrs = null; if (keys == null) return null; while (keys.hasMoreElements()) { boolean definedAttr = false; String key = keys.nextElement(); for (String attr : definedAttrs) { if (attr.equals(key)) { definedAttr = true; break; } } String value = element.getAttribute(key); int colonIndex = key.indexOf(':'); String type = ATTR_TYPE_STRING; if (colonIndex > 0) { type = key.substring(colonIndex + 1).trim(); key = key.substring(0, colonIndex).trim(); } if (!definedAttr) { if (arbitraryAttrs == null) arbitraryAttrs = new HashMap<>(); arbitraryAttrs.put(key, convertValue(type, value)); } } return arbitraryAttrs; }