auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void show() { super.show(); float dp = getContext().getResources().getDimension(R.dimen.bottom_sheet_dialog_width); if (dp > 0) { DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); int px = (int) ((dp * displayMetrics.density) + 0.5); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = px; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; getWindow().setAttributes(lp); } }

Target:
public void show() { super.show(); int dp = (int)getContext().getResources().getDimension(R.dimen.bottom_sheet_dialog_width); if (dp > 0) { int px = DisplayUtils.dpToPx(getContext(), dp); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = px; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; getWindow().setAttributes(lp); } }
Source:
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult result) { }

Target:
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult result) { redirectToYoutubeDialog(); }
Source:
private void setupFields(ReorientRequest request) { this.oppositeEnd = null; this.oppositePartWithPort = null; if (getElementToEdit() instanceof Connector) { ConnectorEnd source = ((Connector) getElementToEdit()).getEnds().get(0); ConnectorEnd target = ((Connector) getElementToEdit()).getEnds().get(1); this.oppositeEnd = isSourceReorient() ? target.getRole() : source.getRole(); this.oppositePartWithPort = isSourceReorient() ? target.getPartWithPort() : source.getPartWithPort(); } initFields(); }

Target:
private void setupFields(ReorientRequest request) { this.oppositeEnd = null; this.oppositePartWithPort = null; if (getElementToEdit() instanceof Connector) { ConnectorEnd source = getLink().getEnds().get(0); ConnectorEnd target = getLink().getEnds().get(1); this.oppositeEnd = isSourceRedirect() ? target.getRole() : source.getRole(); this.oppositePartWithPort = isSourceRedirect() ? target.getPartWithPort() : source.getPartWithPort(); } initFields(); }
Source:
public NinjaRule parseNinjaRule() throws GenericParsingException { parseExpected(NinjaToken.RULE); String name = asString(parseExpected(NinjaToken.IDENTIFIER)); ImmutableSortedMap.Builder<NinjaRuleVariable, NinjaVariableValue> variablesBuilder = ImmutableSortedMap.naturalOrder(); variablesBuilder.put(NinjaRuleVariable.NAME, NinjaVariableValue.createPlainText(name)); parseExpected(NinjaToken.NEWLINE); while (parseIndentOrFinishDeclaration()) { String variableName = asString(parseExpected(ImmutableSet.of(NinjaToken.IDENTIFIER, NinjaToken.POOL))); parseExpected(NinjaToken.EQUALS); NinjaVariableValue value = parseVariableValue(); NinjaRuleVariable ninjaRuleVariable = NinjaRuleVariable.nullOrValue(variableName); if (ninjaRuleVariable == null) { throw new GenericParsingException(String.format("Unexpected variable '%s'", variableName)); } variablesBuilder.put(ninjaRuleVariable, value); if (lexer.hasNextToken()) { parseExpected(NinjaToken.NEWLINE); } } return new NinjaRule(variablesBuilder.build()); }

Target:
public NinjaRule parseNinjaRule() throws GenericParsingException { parseExpected(NinjaToken.RULE); String name = asString(parseExpected(NinjaToken.IDENTIFIER)); ImmutableSortedMap.Builder<NinjaRuleVariable, NinjaVariableValue> variablesBuilder = ImmutableSortedMap.naturalOrder(); variablesBuilder.put(NinjaRuleVariable.NAME, NinjaVariableValue.createPlainText(name)); parseExpected(NinjaToken.NEWLINE); lexer.interpretPoolAsVariable(); while (parseIndentOrFinishDeclaration()) { String variableName = asString(parseExpected(NinjaToken.IDENTIFIER)); parseExpected(NinjaToken.EQUALS); NinjaVariableValue value = parseVariableValue(); NinjaRuleVariable ninjaRuleVariable = NinjaRuleVariable.nullOrValue(variableName); if (ninjaRuleVariable == null) { throw new GenericParsingException(String.format("Unexpected variable '%s'", variableName)); } variablesBuilder.put(ninjaRuleVariable, value); if (lexer.hasNextToken()) { parseExpected(NinjaToken.NEWLINE); } } return new NinjaRule(variablesBuilder.build()); }
Source:
public void create(Username currentUser, ElasticProfile elasticProfile, LocalizedOperationResult result) { ElasticAgentProfileCreateCommand command = new ElasticAgentProfileCreateCommand(goConfigService, elasticProfile, elasticAgentExtension, currentUser, result); validatePluginProperties(command, elasticProfile); update(currentUser, elasticProfile, result, command); }

Target:
public void create(Username currentUser, ElasticProfile elasticProfile, LocalizedOperationResult result) { ElasticAgentProfileCreateCommand command = new ElasticAgentProfileCreateCommand(goConfigService, elasticProfile, elasticAgentExtension, currentUser, result); update(currentUser, elasticProfile, result, command); }
Source:
private UpdateAccountResponse updateAccount(URL updateAccountUrl, String requestBody) throws Exception { RealmLog.debug("Network request (updateAccount): " + updateAccountUrl); Request request = newAuthRequest(updateAccountUrl) .post(RequestBody.create(JSON, requestBody)) .build(); RealmLog.error(updateAccountUrl.toString()); RealmLog.error(requestBody); Call call = client.newCall(request); Response response = call.execute(); return UpdateAccountResponse.from(response); }

Target:
private UpdateAccountResponse updateAccount(URL updateAccountUrl, String requestBody) throws Exception { RealmLog.debug("Network request (updateAccount): " + updateAccountUrl); Request request = newAuthRequest(updateAccountUrl) .post(RequestBody.create(JSON, requestBody)) .build(); Call call = client.newCall(request); Response response = call.execute(); return UpdateAccountResponse.from(response); }
Source:
public void rootTestGetVariantsByVariantCoreString() throws URISyntaxException { String url = "/v2/variants/20:60100:A:T?species=mmusculus&assembly=grcm38"; List<VariantWithSamplesAndAnnotation> variantWithSamplesAndAnnotations = WSTestHelpers.testRestTemplateHelper( url,restTemplate); assertTrue(variantWithSamplesAndAnnotations.size() == 1); assertTrue(variantWithSamplesAndAnnotations.get(0).getSourceEntries().isEmpty()); assertNull(variantWithSamplesAndAnnotations.get(0).getAnnotation()); assertTrue(variantWithSamplesAndAnnotations.get(0).getIds().size() > 0); }

Target:
public void rootTestGetVariantsByVariantCoreString() throws URISyntaxException { String url = "/v2/variants/20:60100:A:T?species=mmusculus&assembly=grcm38"; List<VariantWithSamplesAndAnnotation> variantWithSamplesAndAnnotations = WSTestHelpers.testRestTemplateHelper( url, restTemplate); assertEquals(1, variantWithSamplesAndAnnotations.size()); assertTrue(variantWithSamplesAndAnnotations.get(0).getSourceEntries().isEmpty()); assertNull(variantWithSamplesAndAnnotations.get(0).getAnnotation()); assertTrue(variantWithSamplesAndAnnotations.get(0).getIds().size() > 0); }
Source:
public Response intercept(Chain chain) throws IOException { try { return chain.proceed(chain.request()); } catch (IOException | RuntimeException | Error t) { if (t instanceof IOException) { throw (IOException) t; } throw new SafeIoException("Caught a non-IOException. " + "This is a serious bug and requires investigation. Rethrowing " + "as an IOException in order to avoid blocking a Dispatcher thread", t); } }

Target:
public Response intercept(Chain chain) throws IOException { try { return chain.proceed(chain.request()); } catch (Throwable t) { if (t instanceof IOException) { throw (IOException) t; } throw new SafeIoException("Caught a non-IOException. " + "This is a serious bug and requires investigation. Rethrowing " + "as an IOException in order to avoid blocking a Dispatcher thread", t); } }
Source:
public static void writeLinkUrl(final Response response, final CharSequence url, final CharSequence media, final String markupId, final String rel) { HeaderItemAttributeMap attributes = new HeaderItemAttributeMap(); if (Strings.isEmpty(rel) == false) { attributes.add(HeaderItemAttribute.LINK_REL, rel); } else { attributes.add(HeaderItemAttribute.LINK_REL, "stylesheet"); } attributes.add(HeaderItemAttribute.LINK_HREF, String.valueOf(Strings.escapeMarkup(url))); if (Strings.isEmpty(media) == false) { attributes.add(HeaderItemAttribute.LINK_MEDIA, media.toString()); } if (Strings.isEmpty(markupId) == false) { attributes.add(HeaderItemAttribute.ID, markupId); } writeLinkUrl(response, attributes); }

Target:
public static void writeLinkUrl(final Response response, final CharSequence url, final CharSequence media, final String markupId, final String rel) { AttributeMap attributes = new AttributeMap(); attributes.put(ATTR_LINK_REL, Strings.isEmpty(rel) ? "stylesheet" : rel); attributes.put(ATTR_TYPE, "text/css"); attributes.put(ATTR_LINK_HREF, UrlEncoder.FULL_URL_INSTANCE.encode(String.valueOf(url),"UTF-8")); if (Strings.isEmpty(media) == false) { attributes.put(ATTR_LINK_MEDIA, media.toString()); } if (Strings.isEmpty(markupId) == false) { attributes.put(ATTR_ID, markupId); } writeLink(response, attributes); }
Source:
public ConfigOrigin withLineNumber(int lineNumber) { if (this.originType == OriginType.GENERIC) { throw new UnsupportedOperationException(); } return this.setLineNumber(lineNumber); }

Target:
public SimpleConfigOrigin withLineNumber(int lineNumber) { if (lineNumber == this.lineNumber && lineNumber == this.endLineNumber) { return this; } else { return new SimpleConfigOrigin(this.description, lineNumber, lineNumber, this.originType, this.urlOrNull, this.commentsOrNull); } }
Source:
public synchronized void stop() { handle.cancel(true); }

Target:
public void stop() { ScheduledFuture<?> f = handle; if (f != null) { handle = null; f.cancel(true); } }
Source:
protected synchronized Properties getProps() { if (properties == null) { properties = new Properties(); loadProps(properties, -1); } return properties; }

Target:
protected synchronized Properties getProps() { if (properties == null) { properties = new Properties(); loadProps(properties, 0, true); } return properties; }
Source:
private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); } } if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference writeAnswersDisable = (CheckBoxPreference) screen.findPreference("writeAnswersDisable"); CheckBoxPreference useInputTag = (CheckBoxPreference) screen.findPreference("useInputTag"); CheckBoxPreference inputWorkaround = (CheckBoxPreference) screen.findPreference("inputWorkaround"); CheckBoxPreference longclickWorkaround = (CheckBoxPreference) screen.findPreference("textSelectionLongclickWorkaround"); CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CheckBoxPreference safeDisplayMode = (CheckBoxPreference) screen.findPreference("safeDisplay"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); workarounds.removePreference(longclickWorkaround); workarounds.removePreference(safeDisplayMode); workarounds.removePreference(writeAnswersDisable); workarounds.removePreference(inputWorkaround); if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }

Target:
private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); } } if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CheckBoxPreference safeDisplayMode = (CheckBoxPreference) screen.findPreference("safeDisplay"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); if (!CompatHelper.isNook()) { workarounds.removePreference(safeDisplayMode); } if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }
Source:
public OverthereProcess startProcess(final CmdLine cmd) { checkNotNull(cmd, "Cannot execute null command line"); checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line"); final String obfuscatedCmd = cmd.toCommandLine(os, true); logger.info("Starting command on [{}]", obfuscatedCmd, this); final CmdLine winrsCmd = new CmdLine(); winrsCmd.addArgument("winrs"); winrsCmd.addArgument("-remote:" + address + ":" + port); winrsCmd.addArgument("-username:" + username); winrsCmd.addRaw("-password:" + password); if (workingDirectory != null) { winrsCmd.addArgument("-directory:" + workingDirectory.getPath()); } if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) { winrsCmd.addArgument("-noecho"); } if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) { winrsCmd.addArgument("-noprofile"); } if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) { winrsCmd.addArgument("-allowdelegate"); } if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) { winrsCmd.addArgument("-compression"); } if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) { winrsCmd.addArgument("-unencrypted"); } if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) { winrsCmd.addArgument("-usessl"); } winrsCmd.add(cmd.getArguments()); return winrsProxyConnection.startProcess(winrsCmd); }

Target:
public OverthereProcess startProcess(final CmdLine cmd) { checkNotNull(cmd, "Cannot execute null command line"); checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line"); final String obfuscatedCmd = cmd.toCommandLine(os, true); logger.info("Starting command on [{}]", obfuscatedCmd, this); final CmdLine winrsCmd = new CmdLine(); winrsCmd.addArgument("winrs"); winrsCmd.addArgument("-remote:" + address + ":" + port); winrsCmd.addArgument("-username:" + username); winrsCmd.addPassword("-password:" + password); if (workingDirectory != null) { winrsCmd.addArgument("-directory:" + workingDirectory.getPath()); } if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) { winrsCmd.addArgument("-noecho"); } if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) { winrsCmd.addArgument("-noprofile"); } if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) { winrsCmd.addArgument("-allowdelegate"); } if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) { winrsCmd.addArgument("-compression"); } if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) { winrsCmd.addArgument("-unencrypted"); } if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) { winrsCmd.addArgument("-usessl"); } winrsCmd.add(cmd.getArguments()); return winrsProxyConnection.startProcess(winrsCmd); }
Source:
protected void onPause() { super.onPause(); if (playerSkinLayoutController != null) { playerSkinLayoutController.onPause(); } Log.d(TAG, "Player Activity Paused"); if (null != player) { player.suspend(); } }

Target:
protected void onPause() { super.onPause(); if (null != playerSkinLayoutController) { playerSkinLayoutController.onPause(); } Log.d(TAG, "Player Activity Paused"); if (null != player) { player.suspend(); } }
Source:
public void advanceIfNeeded(int i) { if (mark < i) { baseIterator.skipAllBefore(i); if (baseIterator.hasNext()) { mark = baseIterator.next(); } } }

Target:
public void advanceIfNeeded(int i) { if (mark < i) { baseIterator.skipAllBefore(i); if (baseIterator.hasNext()) { mark = baseIterator.next(); } else { mark = NOT_SET; } } }
Source:
public int read() throws IOException { prepare(); if (buf.remaining() > 0) { return buf.get(); } buf.rewind(); position += buf.capacity(); int nr = os.read(position, buf); if (nr < 0) { buf.limit(0); return -1; } buf.flip(); return buf.get(); }

Target:
public int read() throws IOException { byte[] b = new byte[1]; int n = read(b); return n == 1 ? b[0] & 0xff : -1; }
Source:
public JsonObject getRawJson() { return rawJson; }

Target:
public String getRawJson() { return rawJson; }
Source:
private @Nullable ByteBuffer skipNRBBlockUntilDataPacket(int blockType, SeekableByteChannel fileChannel) throws BadPcapFileException { final String errorMsg = "A pcapng file is invalid"; ByteBuffer pcapNgBlockHeader = null; int blockLength = 0; int typeBlock = 0; pcapNgBlockHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); pcapNgBlockHeader.clear(); ByteOrder byteOrder = getByteOrder(); pcapNgBlockHeader.order(byteOrder); try { fileChannel.read(pcapNgBlockHeader); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader.flip(); typeBlock = pcapNgBlockHeader.getInt(); blockLength = pcapNgBlockHeader.getInt(); while (typeBlock != PcapFileValues.PCAPNG_EPB && typeBlock != PcapFileValues.PCAPNG_PB && typeBlock == blockType && typeBlock != PcapFileValues.PCAPNG_SPB) { try { fileChannel.position(fileChannel.position() + blockLength - PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); pcapNgBlockHeader.clear(); pcapNgBlockHeader.order(getByteOrder()); try { fileChannel.read(pcapNgBlockHeader); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader.flip(); typeBlock = pcapNgBlockHeader.getInt(); blockLength = pcapNgBlockHeader.getInt(); } setBlockLength(blockLength); setBlocType(typeBlock); return pcapNgBlockHeader; }

Target:
private @Nullable ByteBuffer skipNRBBlockUntilDataPacket(int blockType, SeekableByteChannel fileChannel) throws BadPcapFileException { final String errorMsg = "A pcapng file is invalid"; ByteBuffer pcapNgBlockHeader = null; int blockLength = 0; int typeBlock = 0; try { if (fileChannel.size() - fileChannel.position() < PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE) { return null; } } catch (IOException e1) { e1.printStackTrace(); } pcapNgBlockHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); ByteOrder byteOrder = getByteOrder(); pcapNgBlockHeader.order(byteOrder); try { fileChannel.read(pcapNgBlockHeader); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader.flip(); typeBlock = pcapNgBlockHeader.getInt(); blockLength = pcapNgBlockHeader.getInt(); while (typeBlock != PcapFileValues.PCAPNG_EPB && typeBlock != PcapFileValues.PCAPNG_PB && typeBlock == blockType && typeBlock != PcapFileValues.PCAPNG_SPB) { try { fileChannel.position(fileChannel.position() + blockLength - PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_BLOCK_HEADER_SIZE); pcapNgBlockHeader.order(getByteOrder()); try { fileChannel.read(pcapNgBlockHeader); } catch (IOException e) { throw new BadPcapFileException(errorMsg, e); } pcapNgBlockHeader.flip(); typeBlock = pcapNgBlockHeader.getInt(); blockLength = pcapNgBlockHeader.getInt(); } setBlockLength(blockLength); setBlocType(typeBlock); return pcapNgBlockHeader; }
Source:
public boolean nodeExists( long id ) { if ( hasTxStateWithChanges() ) { TransactionState txState = txState(); if ( txState.nodeIsDeletedInThisTx( id ) ) { return false; } else if ( txState.nodeIsAddedInThisTx( id ) ) { return true; } } return storeReadLayer.nodeExists( id ); }

Target:
public boolean nodeExists( long id ) { assertOpen.assertOpen(); if ( hasTxStateWithChanges() ) { TransactionState txState = txState(); if ( txState.nodeIsDeletedInThisTx( id ) ) { return false; } else if ( txState.nodeIsAddedInThisTx( id ) ) { return true; } } return storeReadLayer.nodeExists( id ); }
Source:
private static boolean checkEOF(final Version version, final SeekableStream seekableStream) throws IOException { if (version.compatibleWith(CramVersions.CRAM_v3)) { return streamEndsWith(seekableStream, CRAMv3_EOF_MARKER); } if (version.compatibleWith(CramVersions.CRAM_v2_1)) { return streamEndsWith(seekableStream, CRAMv21_EOF_MARKER); } return false; }

Target:
private static boolean checkEOF(final Version version, final SeekableStream seekableStream) throws IOException { final byte[] eof = CramVersions.eofForVersion(version); if (eof.length == 0) { return false; } else { return streamEndsWith(seekableStream, eof); } }
Source:
public boolean otherNotificationsAreIndirectlyConcerned(Notification notification, Collection<Notification> notifications) { if (NotationPackage.Literals.ROUTING_STYLE__ROUTING == notification.getFeature() || DiagramPackage.Literals.EDGE_STYLE__CENTERED == notification.getFeature()) { for (Notification currentNotification : notifications) { if (currentNotification != notification && !INTERESTING_FEATURES_BIS.contains(currentNotification.getFeature())) { return false; } } return true; } else { return notifications.size() == 1; } }

Target:
public boolean otherNotificationsAreIndirectlyConcerned(Notification notification, Collection<Notification> notifications) { if (NotationPackage.Literals.ROUTING_STYLE__ROUTING == notification.getFeature() || DiagramPackage.Literals.EDGE_STYLE__CENTERED == notification.getFeature()) { for (Notification currentNotification : notifications) { if (currentNotification != notification && !INDIRECT_INTERESTING_FEATURES.contains(currentNotification.getFeature())) { return false; } } return true; } else { return notifications.size() == 1; } }
Source:
public void runScenario(PickleEvent pickle) throws Throwable { runtime.runPickle(pickle); }

Target:
public void runScenario(PickleEvent pickle) throws Throwable { testCaseResultListener.startPickle(); runtime.getRunner().runPickle(pickle); if (!testCaseResultListener.isPassed()) { throw testCaseResultListener.getError(); } }
Source:
public void call(final SingleSubscriber<? super T> child) { final SingleSubscriber<? super T> parent = new SingleSubscriber<T>() { @Override public void onSuccess(T value) { child.onSuccess(value); } @Override public void onError(Throwable error) { RxJavaPlugins.getInstance().getErrorHandler().handleError(error); try { unsubscribe(); resumeFunctionInCaseOfError.call(error).subscribe(child); } catch (Throwable innerError) { Exceptions.throwOrReport(innerError, child); } } }; child.add(parent); originalSingle.subscribe(parent); }

Target:
public void call(final SingleSubscriber<? super T> child) { final SingleSubscriber<? super T> parent = new SingleSubscriber<T>() { @Override public void onSuccess(T value) { child.onSuccess(value); } @Override public void onError(Throwable error) { try { resumeFunctionInCaseOfError.call(error).subscribe(child); } catch (Throwable innerError) { Exceptions.throwOrReport(innerError, child); } } }; child.add(parent); originalSingle.subscribe(parent); }
Source:
public void waitClose() { webDriverWaitFactory .get() .until( ExpectedConditions.invisibilityOfElementLocated( By.xpath(Locators.RESET_TO_COMMIT_FORM))); }

Target:
public void waitClose() { seleniumWebDriverHelper.waitInvisibility(By.xpath(Locators.RESET_TO_COMMIT_FORM)); }
Source:
public boolean canCreateChildren() { try { if (canCreateChildrenHandler == null) { return true; } return canCreateChildrenHandler.test(this); } catch (Exception e) { throw handleErrorInCallback(e, "canCreateChildrenHandler"); } }

Target:
public boolean canCreateChildren() { try { if (canCreateChildrenHandler != null) { return canCreateChildrenHandler.test(this); } return true; } catch (Exception e) { throw handleErrorInCallback(e, "canCreateChildrenHandler"); } }
Source:
protected View newView(LayoutInflater inflater, ViewGroup viewContainer) { View view = inflater.inflate(R.layout.layout_list_item_token_with_menu, viewContainer, false); view.setTag(new ViewHolder(view)); return view; }

Target:
protected View newView(LayoutInflater inflater, ViewGroup viewContainer) { View view = inflater.inflate(R.layout.layout_list_item_with_menu, viewContainer, false); view.setTag(new ViewHolder(view)); return view; }
Source:
public static void init(int max_traces) throws TmfTraceException { File parentDir = new File(TRACES_ROOT_PATH); File[] traceFiles = parentDir.listFiles(); traces = new CtfTmfTrace[Math.min(max_traces, traceFiles.length)]; fExperiment = new TmfExperimentStub[1]; for (int i = 0; i < traces.length; i++) { traces[i] = new CtfTmfTrace(); } fExperiment[0] = new TmfExperimentStub("MegaExperiment", traces, 100); int j = 0; for (int i = 0; i < traces.length; i++) { String absolutePath = traceFiles[j].getAbsolutePath(); if (traces[i].validate(null, absolutePath).isOK()) { traces[i].initTrace(null, absolutePath, ITmfEvent.class); } else { i--; } j++; } }

Target:
private void init(int max_traces) throws TmfTraceException { File parentDir = new File(TRACES_ROOT_PATH); File[] traceFiles = parentDir.listFiles(); traces = new CtfTmfTrace[Math.min(max_traces, traceFiles.length)]; fExperiment = new TmfExperimentStub[1]; for (int i = 0; i < traces.length; i++) { traces[i] = new CtfTmfTrace(); } fExperiment[0] = new TmfExperimentStub("MegaExperiment", traces, 100); int j = 0; for (int i = 0; i < (traces.length) && (j < traces.length); i++) { String absolutePath = traceFiles[j].getAbsolutePath(); if (traces[i].validate(null, absolutePath).isOK()) { traces[i].initTrace(null, absolutePath, ITmfEvent.class); } else { i--; } j++; } if (traces[traces.length].getPath() == null) { throw new TmfTraceException("Insufficient valid traces in directory"); } }
Source:
public int compareTo(InetAddressAndPort o) { int retval = ByteBuffer.wrap(address.getAddress()).compareTo(ByteBuffer.wrap(o.address.getAddress())); if (retval != 0) { return retval; } return Integer.compare(port, o.port); }

Target:
public int compareTo(InetAddressAndPort o) { int retval = FastByteOperations.compareUnsigned(addressBytes, 0, addressBytes.length, o.addressBytes, 0, o.addressBytes.length); if (retval != 0) { return retval; } return Integer.compare(port, o.port); }
Source:
private void commitOffsetsForAckedTuples(Set<TopicPartition> assignedPartitions) { final Map<TopicPartition, OffsetManager> assignedOffsetManagers = offsetManagers.entrySet().stream() .filter(entry -> assignedPartitions.contains(entry.getKey())) .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue())); final Map<TopicPartition, OffsetAndMetadata> nextCommitOffsets = new HashMap<>(); for (Map.Entry<TopicPartition, OffsetManager> tpOffset : assignedOffsetManagers.entrySet()) { final OffsetAndMetadata nextCommitOffset = tpOffset.getValue().findNextCommitOffset(); if (nextCommitOffset != null) { nextCommitOffsets.put(tpOffset.getKey(), nextCommitOffset); } } if (!nextCommitOffsets.isEmpty()) { kafkaConsumer.commitSync(nextCommitOffsets); LOG.debug("Offsets successfully committed to Kafka [{}]", nextCommitOffsets); for (Map.Entry<TopicPartition, OffsetAndMetadata> tpOffset : nextCommitOffsets.entrySet()) { final TopicPartition tp = tpOffset.getKey(); long position = kafkaConsumer.position(tp); long committedOffset = tpOffset.getValue().offset(); if (position < committedOffset) { LOG.debug("Consumer fell behind committed offset. Catching up. Position was [{}], skipping to [{}]", position, committedOffset); kafkaConsumer.seek(tp, committedOffset); waitingToEmit = null; } final OffsetManager offsetManager = assignedOffsetManagers.get(tp); offsetManager.commit(tpOffset.getValue()); LOG.debug("[{}] uncommitted offsets for partition after commit", offsetManager.getNumUncommittedOffsets(), tp); } } else { LOG.trace("No offsets to commit. {}", this); } }

Target:
private void commitOffsetsForAckedTuples(Set<TopicPartition> assignedPartitions) { final Map<TopicPartition, OffsetManager> assignedOffsetManagers = offsetManagers.entrySet().stream() .filter(entry -> assignedPartitions.contains(entry.getKey())) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); final Map<TopicPartition, OffsetAndMetadata> nextCommitOffsets = new HashMap<>(); for (Map.Entry<TopicPartition, OffsetManager> tpOffset : assignedOffsetManagers.entrySet()) { final OffsetAndMetadata nextCommitOffset = tpOffset.getValue().findNextCommitOffset(); if (nextCommitOffset != null) { nextCommitOffsets.put(tpOffset.getKey(), nextCommitOffset); } } if (!nextCommitOffsets.isEmpty()) { kafkaConsumer.commitSync(nextCommitOffsets); LOG.debug("Offsets successfully committed to Kafka [{}]", nextCommitOffsets); for (Map.Entry<TopicPartition, OffsetAndMetadata> tpOffset : nextCommitOffsets.entrySet()) { final TopicPartition tp = tpOffset.getKey(); long position = kafkaConsumer.position(tp); long committedOffset = tpOffset.getValue().offset(); if (position < committedOffset) { LOG.debug("Consumer fell behind committed offset. Catching up. Position was [{}], skipping to [{}]", position, committedOffset); kafkaConsumer.seek(tp, committedOffset); waitingToEmit = null; } final OffsetManager offsetManager = assignedOffsetManagers.get(tp); offsetManager.commit(tpOffset.getValue()); LOG.debug("[{}] uncommitted offsets for partition after commit", offsetManager.getNumUncommittedOffsets(), tp); } } else { LOG.trace("No offsets to commit. {}", this); } }
Source:
private boolean testngXmlExistsInJar(File jarFile, List<String> classes) throws IOException { boolean foundTestngXml = false; try (JarFile jf = new JarFile(jarFile)) { Enumeration<JarEntry> entries = jf.entries(); while (entries.hasMoreElements()) { JarEntry je = entries.nextElement(); if (matchesXmlPathInJar(je)) { Collection<XmlSuite> parsedSuites = Parser.parse(jf.getInputStream(je), processor); for (XmlSuite suite : parsedSuites) { if (testNames != null) { XmlSuiteUtils.cloneIfContainsTestsWithNamesMatchingAny(suite, testNames); List<String> missMatchedTestname = XmlSuiteUtils.getMissMatchedTestNames(testNames); if (CollectionUtils.hasElements(missMatchedTestname)) { XmlSuiteUtils.resetField(); throw new TestNGException("The test(s) <" + Arrays.toString(missMatchedTestname.toArray())+ "> cannot be found."); } suites.addAll(XmlSuiteUtils.getCloneSuite()); XmlSuiteUtils.resetField(); } else { suites.add(suite); } } return true; } else if (isJavaClass(je)) { classes.add(constructClassName(je)); } } } return foundTestngXml; }

Target:
private boolean testngXmlExistsInJar(File jarFile, List<String> classes) throws IOException { boolean foundTestngXml = false; try (JarFile jf = new JarFile(jarFile)) { Enumeration<JarEntry> entries = jf.entries(); File file = java.nio.file.Files.createTempDirectory("testngXmlPathInJar-").toFile(); String suitePath = null; while (entries.hasMoreElements()) { JarEntry je = entries.nextElement(); String jeName = je.getName(); if (Parser.canParse(jeName.toLowerCase())){ InputStream inputStream = jf.getInputStream(je); File copyFile = new File(file, jeName); Files.copyFile(inputStream, copyFile); if (matchesXmlPathInJar(je)) { suitePath = copyFile.toString(); } } else if (isJavaClass(je)) { classes.add(constructClassName(je)); } } if (Strings.isNullOrEmpty(suitePath)) { return foundTestngXml; } Collection<XmlSuite> parsedSuites = Parser.parse(suitePath, processor); for (XmlSuite suite : parsedSuites) { if (testNames != null) { TestNamesMatcher testNamesMatcher = new TestNamesMatcher(suite, testNames); List<String> missMatchedTestname = testNamesMatcher.getMissMatchedTestNames(); if (!missMatchedTestname.isEmpty()) { throw new TestNGException("The test(s) <" + missMatchedTestname+ "> cannot be found."); } suites.addAll(testNamesMatcher.getSuitesMatchingTestNames()); } else { suites.add(suite); } return true; } } return foundTestngXml; }
Source:
private void deleteSelectedForms() { if (backgroundTasks.deleteFormsTask == null) { progressDialog = new ProgressDialog(getContext()); progressDialog.setMessage(getResources().getString(R.string.form_delete_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); backgroundTasks.deleteFormsTask = new DeleteFormsTask(); backgroundTasks.deleteFormsTask .setContentResolver(getActivity().getContentResolver()); backgroundTasks.deleteFormsTask.setDeleteListener(this); backgroundTasks.deleteFormsTask.execute(getCheckedIdObjects()); } else { ToastUtils.showLongToast(R.string.file_delete_in_progress); } }

Target:
private void deleteSelectedForms() { if (backgroundTasks.deleteFormsTask == null) { Bundle args = new Bundle(); args.putSerializable(ProgressDialogFragment.MESSAGE, getResources().getString(R.string.form_delete_message)); args.putBoolean(ProgressDialogFragment.CANCELABLE, false); DialogUtils.showIfNotShowing(ProgressDialogFragment.class, args, getActivity().getSupportFragmentManager()); backgroundTasks.deleteFormsTask = new DeleteFormsTask(); backgroundTasks.deleteFormsTask .setContentResolver(getActivity().getContentResolver()); backgroundTasks.deleteFormsTask.setDeleteListener(this); backgroundTasks.deleteFormsTask.execute(getCheckedIdObjects()); } else { ToastUtils.showLongToast(R.string.file_delete_in_progress); } }
Source:
public void request(IRestfulClient theClient, IHttpRequest theRequest) { String tenantId = getTenantId(); if (isBlank(tenantId)) { return; } String requestUri = theRequest.getUri(); String serverBase = theClient.getServerBase(); if (serverBase.endsWith("/")) { serverBase = serverBase.substring(0, serverBase.length() - 1); } Validate.isTrue(requestUri.startsWith(serverBase), "Request URI %s does not start with server base %s", requestUri, serverBase); if (requestUri.startsWith(serverBase + "/" + tenantId)) { return; } String newUri = serverBase + "/" + tenantId + requestUri.substring(serverBase.length()); theRequest.setUri(newUri); }

Target:
public void request(IRestfulClient theClient, IHttpRequest theRequest) { String tenantId = getTenantId(); if (isBlank(tenantId)) { return; } String requestUri = theRequest.getUri(); String serverBase = theClient.getServerBase(); if (serverBase.endsWith("/")) { serverBase = serverBase.substring(0, serverBase.length() - 1); } Validate.isTrue(requestUri.startsWith(serverBase), "Request URI %s does not start with server base %s", requestUri, serverBase); if (theRequest.getUrlSource() == UrlSourceEnum.EXPLICIT) { return; } String newUri = serverBase + "/" + tenantId + requestUri.substring(serverBase.length()); theRequest.setUri(newUri); }
Source:
private void createMasterFile(boolean isActive) throws IOException { String fileName = masterName.replaceAll(":", "_"); Path path = null; if (isActive) { path = new Path(activePath, fileName); } else { path = new Path(backupPath, fileName); } StringBuilder sb = new StringBuilder(); InetSocketAddress address = getHostAddress(HAConstants.MASTER_CLIENT_RPC_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.RESOURCE_TRACKER_RPC_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.CATALOG_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.MASTER_INFO_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()); FSDataOutputStream out = fs.create(path); try { out.writeUTF(sb.toString()); out.hflush(); out.close(); } catch (FileAlreadyExistsException e) { createMasterFile(false); } if (isActive) { isActiveStatus = true; } else { isActiveStatus = false; } startPingChecker(); }

Target:
private void createMasterFile(boolean isActive) throws IOException { String fileName = masterName.replaceAll(":", "_"); Path path = null; if (isActive) { path = new Path(activePath, fileName); } else { path = new Path(backupPath, fileName); } StringBuilder sb = new StringBuilder(); InetSocketAddress address = getHostAddress(HAConstants.MASTER_CLIENT_RPC_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.RESOURCE_TRACKER_RPC_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.CATALOG_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()).append("_"); address = getHostAddress(HAConstants.MASTER_INFO_ADDRESS); sb.append(address.getAddress().getHostAddress()).append(":").append(address.getPort()); FSDataOutputStream out = fs.create(path); try { out.writeUTF(sb.toString()); out.hsync(); out.close(); } catch (FileAlreadyExistsException e) { createMasterFile(false); } if (isActive) { isActiveStatus = true; } else { isActiveStatus = false; } startPingChecker(); }
Source:
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { Promise<ByteBuf> promise = ctx.channel().attr(Http2BlockingChannel.RESPONSE_PROMISE).get(); if (promise != null) { promise.setSuccess(msg.content().retainedDuplicate()); releaseStreamChannel(ctx); } }

Target:
protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { Promise<ByteBuf> promise = ctx.channel().attr(Http2BlockingChannel.RESPONSE_PROMISE).getAndSet(null); if (promise != null) { promise.setSuccess(msg.content().retainedDuplicate()); releaseStreamChannel(ctx); } }
Source:
public ImmutableList<InfoInsightCards> getAllGenericInsightCards() { final ImmutableList<Optional<InfoInsightCards>> OptionalInfoInsightCards = this.getAllGenericOptionalInsightCards(); final List<InfoInsightCards> InfoInsightCards = Lists.newArrayList(); for (Optional<InfoInsightCards> optionalInsightCard : OptionalInfoInsightCards) { if (!optionalInsightCard.isPresent()) { continue; } InfoInsightCards.add(optionalInsightCard.get()); } return ImmutableList.copyOf(InfoInsightCards); }

Target:
public ImmutableList<InfoInsightCards> getAllGenericInsightCards() { final List<Optional<InfoInsightCards>> optionalInfoInsightCards = this.getAllGenericOptionalInsightCards(); final List<InfoInsightCards> InfoInsightCards = filterAbsentCards(optionalInfoInsightCards); return ImmutableList.copyOf(InfoInsightCards); }
Source:
Simulation createSimulation(Path context, String value) throws Exception; Background createBackground(Path context, String dmnFilePath) throws Exception; Settings createSettings(String value) throws Exception; default <T extends AbstractScesimData, E extends ScesimDataWithIndex<T>> E createScesimDataWithIndex(AbstractScesimModel<T> abstractScesimModel, ScesimModelDescriptor simulationDescriptor, Class<E> toInstantiate) throws Exception { simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); T scenario = abstractScesimModel.addData(); scenario.setDescription(null); int index = abstractScesimModel.getUnmodifiableData().indexOf(scenario) + 1; return toInstantiate.getConstructor(int.class, scenario.getClass()).newInstance(index, scenario) ; }

Target:
Simulation createSimulation(Path context, String value) throws Exception; Settings createSettings(Path context, String value) throws Exception; default <T extends AbstractScesimData, E extends ScesimDataWithIndex<T>> E createScesimDataWithIndex(AbstractScesimModel<T> abstractScesimModel, ScesimModelDescriptor simulationDescriptor, Class<E> toInstantiate) throws Exception { simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); T scenario = abstractScesimModel.addData(); scenario.setDescription(null); int index = abstractScesimModel.getUnmodifiableData().indexOf(scenario) + 1; return toInstantiate.getConstructor(int.class, scenario.getClass()).newInstance(index, scenario); }
Source:
public void testInterceptors() throws Exception { Map<Class<?>, SortedSet<MessageHandlingMember<? super A>>> interceptors = inspector.getAllInterceptors(); assertEquals(5, interceptors.size()); assertEquals(1, interceptors.get(pA.class).size()); assertEquals(1, interceptors.get(A.class).size()); assertEquals(2, interceptors.get(B.class).size()); assertEquals(1, interceptors.get(C.class).size()); assertEquals(2, interceptors.get(D.class).size()); MessageHandlerInterceptorMemberChain<A> chain = inspector.chainedInterceptor(B.class); chain.handle(asEventMessage("Hello"), new D(), inspector.getHandlers(pA.class).findFirst().get()); assertThrows(MockException.class, () -> chain.handle(asEventMessage(1), new D(), inspector.getHandlers(pA.class).findFirst().get()) ); }

Target:
void testInterceptors() throws Exception { D testTarget = new D(); EventMessage<Object> testEvent = asEventMessage("Hello"); EventMessage<Object> testEventTwo = asEventMessage(1); Map<Class<?>, SortedSet<MessageHandlingMember<? super A>>> interceptors = inspector.getAllInterceptors(); assertEquals(5, interceptors.size()); assertEquals(1, interceptors.get(pA.class).size()); assertEquals(1, interceptors.get(A.class).size()); assertEquals(2, interceptors.get(B.class).size()); assertEquals(1, interceptors.get(C.class).size()); assertEquals(2, interceptors.get(D.class).size()); MessageHandlerInterceptorMemberChain<A> chain = inspector.chainedInterceptor(B.class); Optional<MessageHandlingMember<? super A>> optionalHandler = inspector.getHandlers(pA.class).findFirst(); assertTrue(optionalHandler.isPresent()); MessageHandlingMember<? super A> resultHandler = optionalHandler.get(); chain.handle(testEvent, testTarget, resultHandler); assertThrows(MockException.class, () -> chain.handle(testEventTwo, testTarget, resultHandler)); }
Source:
public Response getSamlResponse( @QueryParam(SAML_RESPONSE) String deflatedSamlResponse, @QueryParam(RELAY_STATE) String relayState, @QueryParam(SIG_ALG) String signatureAlgorithm, @QueryParam(SIGNATURE) String signature) { LOGGER.warn("HTTP-Redirect binding should not be used for Single Sign-On responses"); if (validateSignature(deflatedSamlResponse, relayState, signatureAlgorithm, signature)) { try { return (StringUtils.isNotBlank(deflatedSamlResponse) && StringUtils.isNotBlank(relayState) && StringUtils.isNotBlank(signatureAlgorithm)) ? processSamlResponse( RestSecurity.inflateBase64(deflatedSamlResponse), relayState, signature != null) : Response.serverError().entity("SAML is in a bad state.").build(); } catch (IOException e) { String msg = "Unable to decode and inflate AuthN response."; LOGGER.info(msg, e); return Response.serverError().entity(msg).build(); } } else { return Response.serverError().entity("Invalid AuthN response signature.").build(); } }

Target:
public Response getSamlResponse( @QueryParam(SAML_RESPONSE) String deflatedSamlResponse, @QueryParam(RELAY_STATE) String relayState, @QueryParam(SIG_ALG) String signatureAlgorithm, @QueryParam(SIGNATURE) String signature) { LOGGER.warn("HTTP-Redirect binding should not be used for Single Sign-On responses"); if (StringUtils.isBlank(deflatedSamlResponse)) { return Response.serverError().entity("SAML is in a bad state.").build(); } if (!validateSignature(deflatedSamlResponse, relayState, signatureAlgorithm, signature)) { return Response.serverError().entity("Invalid AuthN response signature.").build(); } try { return processSamlResponse( RestSecurity.inflateBase64(deflatedSamlResponse), relayState, signature != null); } catch (IOException e) { String msg = "Unable to decode and inflate AuthN response."; LOGGER.info(msg, e); return Response.serverError().entity(msg).build(); } }
Source:
public void testValidationWithWhiteSpaceAfterAndBeforeDomainClassName() { TreeIterator<EObject> elements = modelerForDomainClassValidation.eAllContents(); int rand = 0; while (elements.hasNext()) { EObject current = elements.next(); for (EAttribute attribute : current.eClass().getEAllAttributes()) { if ("domainClass".equals(attribute.getName())) { addSpaceInDomainClassValue(current, attribute, rand); if (rand < 2) { rand++; } else { rand = 0; } } } } Diagnostician diagnostician = new Diagnostician(); Diagnostic diagnostic = diagnostician.validate(modelerForDomainClassValidation); assertEquals("The VSM is valid, it should not have popup error message", Diagnostic.OK, diagnostic.getSeverity()); }

Target:
public void testValidationWithWhiteSpaceAfterAndBeforeDomainClassName() { TreeIterator<EObject> elements = modelerForDomainClassValidation.eAllContents(); int i = 0; while (elements.hasNext()) { EObject current = elements.next(); for (EAttribute attribute : current.eClass().getEAllAttributes()) { if ("domainClass".equals(attribute.getName())) { addSpaceInDomainClassValue(current, attribute, i); if (i < 2) { i++; } else { i = 0; } } } } Diagnostician diagnostician = new Diagnostician(); Diagnostic diagnostic = diagnostician.validate(modelerForDomainClassValidation); assertEquals("The VSM is valid, it should not have popup error message", Diagnostic.OK, diagnostic.getSeverity()); }
Source:
private String[] getAllCompatibleFieldNames(DocumentBuilderIndexedEntity<?> documentBuilder) { Collection<DocumentFieldMetadata> allFieldMetadata = documentBuilder.getTypeMetadata().getAllDocumentFieldMetadata(); List<String> fieldNames = new ArrayList<String>( allFieldMetadata.size() ); for ( DocumentFieldMetadata fieldMetadata : allFieldMetadata ) { if ( ( fieldMetadata.getTermVector() != Field.TermVector.NO || fieldMetadata.getStore() != org.hibernate.search.annotations.Store.NO ) && ! ( fieldMetadata.isId() || fieldMetadata.isIdInEmbedded() ) ) { fieldNames.add( fieldMetadata.getName() ); } } if ( fieldNames.size() == 0 ) { throw log.noFieldCompatibleForMoreLikeThis( documentBuilder.getBeanClass() ); } return fieldNames.toArray( new String[fieldNames.size()] ); }

Target:
private String[] getAllCompatibleFieldNames(DocumentBuilderIndexedEntity<?> documentBuilder) { Collection<DocumentFieldMetadata> allFieldMetadata = documentBuilder.getTypeMetadata().getAllDocumentFieldMetadata(); List<String> fieldNames = new ArrayList<String>( allFieldMetadata.size() ); for ( DocumentFieldMetadata fieldMetadata : allFieldMetadata ) { boolean hasTermVector = fieldMetadata.getTermVector() != Field.TermVector.NO; boolean isStored = fieldMetadata.getStore() != Store.NO; boolean isIdOrEmbeddedId = fieldMetadata.isId() || fieldMetadata.isIdInEmbedded(); if ( ( hasTermVector || isStored ) && !isIdOrEmbeddedId ) { fieldNames.add( fieldMetadata.getName() ); } } if ( fieldNames.size() == 0 ) { throw log.noFieldCompatibleForMoreLikeThis( documentBuilder.getBeanClass() ); } return fieldNames.toArray( new String[fieldNames.size()] ); }
Source:
private HTInterval getRelevantInterval(long t, int key) throws TimeRangeException, ClosedChannelException { checkValidTime(t); LinkedList<HTNode> queue = new LinkedList<>(); queue.add(fSht.getRootNode()); HTInterval interval = null; while(interval == null && !queue.isEmpty()){ HTNode currentNode = queue.pop(); if ((currentNode.getNodeType() == HTNode.NodeType.CORE)) { queue.addAll(fSht.selectNextChildren((CoreNode) currentNode, t)); } interval = currentNode.getRelevantInterval(key, t); } return interval; }

Target:
private HTInterval getRelevantInterval(long t, int key) throws TimeRangeException, ClosedChannelException { checkValidTime(t); Deque<HTNode> queue = new LinkedList<>(); queue.add(fSht.getRootNode()); HTInterval interval = null; while (interval == null && !queue.isEmpty()) { HTNode currentNode = queue.pop(); if ((currentNode.getNodeType() == HTNode.NodeType.CORE)) { queue.addAll(fSht.selectNextChildren((CoreNode) currentNode, t)); } interval = currentNode.getRelevantInterval(key, t); } return interval; }