auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private static String writeToJSON() { final JSONObject mainObject = new JSONObject(); final JSONObject soundtracksettings = new JSONObject(); soundtracksettings.put("soundtrackEnabled", State.isSoundtrackEnabled()); mainObject.put("soundtracksettings", soundtracksettings); final JSONObject soundeffectsettings = new JSONObject(); soundeffectsettings.put("soundEffectsEnabled", State.isSoundEffectsEnabled()); mainObject.put("soundEffectssettings", soundeffectsettings); mainObject.put("playername", State.getPlayerName()); mainObject.put("coins", State.getCoins()); final JSONObject highscore = new JSONObject(); highscore.put("score", State.getHighscore()); mainObject.put("highscore", highscore); return mainObject.toJSONString(); }

Target:
private static String writeToJSON() { final JSONObject mainObject = new JSONObject(); final JSONObject settings = new JSONObject(); final JSONObject soundtracksettings = new JSONObject(); soundtracksettings.put("soundtrackEnabled", State.isSoundtrackEnabled()); settings.put("soundtracksettings", soundtracksettings); final JSONObject soundeffectsettings = new JSONObject(); soundeffectsettings.put("soundEffectsEnabled", State.isSoundEffectsEnabled()); settings.put("soundEffectssettings", soundeffectsettings); mainObject.put("playername", State.getPlayerName()); mainObject.put("coins", State.getCoins()); final JSONObject highscore = new JSONObject(); highscore.put("score", State.getHighscore()); mainObject.put("highscore", highscore); mainObject.put("settings", settings); return mainObject.toJSONString(); }
Source:
void setupInputFields() { startValue.onkeyup = this::onKeyDown; endValue.onkeyup = this::onKeyDown; }

Target:
void setupInputFields() { startValue.onkeyup = this::onKeyUp; endValue.onkeyup = this::onKeyUp; }
Source:
public List<LinkedStructure> getUplinks() { return uplinks; }

Target:
public Uplinks getUplinks() { return uplinks; }
Source:
public IndexingConfigurationBuilder autoConfig(boolean autoConfig) { enable(); attributes.attribute(AUTO_CONFIG).set(autoConfig); return this; }

Target:
public IndexingConfigurationBuilder autoConfig(boolean autoConfig) { if (autoConfig) enable(); attributes.attribute(AUTO_CONFIG).set(autoConfig); return this; }
Source:
private void writeObject(ObjectOutputStream oos) throws IOException { if (buf == null) { buf = new byte[codec.sizeof(object)]; codec.encode(object, buf); } oos.writeInt(hash); if (object == null) { oos.writeInt(buf.length); oos.write(buf); } else { oos.writeInt(codec.sizeof(object)); CodedOutputStream cos = CodedOutputStream.newInstance(oos); codec.encode(object, cos); cos.flush(); } }

Target:
private void writeObject(ObjectOutputStream oos) throws IOException { oos.writeInt(hash); Object d = data; if (d instanceof byte[]) { byte[] buf = (byte[]) d; oos.writeInt(buf.length); oos.write(buf); } else { T obj = (T) d; oos.writeInt(codec.sizeof(obj)); CodedOutputStream cos = CodedOutputStream.newInstance(oos); codec.encode(obj, cos); cos.flush(); } }
Source:
public static DownloadMigratorBuilder newInstance(Context context) { Context applicationContext = context.getApplicationContext(); String channelId = context.getResources().getString(R.string.migration_notification_channel_name); String channelDescription = context.getResources().getString(R.string.migration_notification_channel_description); NotificationCustomizer<MigrationStatus> customiser = new NotificationCustomizer<MigrationStatus>() { private static final int MAX_PROGRESS = 100; @Override public Notification customNotificationFrom(NotificationCompat.Builder builder, MigrationStatus payload) { String title = payload.status().toRawValue(); String content = payload.percentageMigrated() + "% migrated"; return builder .setProgress(MAX_PROGRESS, payload.percentageMigrated(), false) .setSmallIcon(android.R.drawable.ic_menu_gallery) .setContentTitle(title) .setContentText(content) .build(); } }; NotificationConfig<MigrationStatus> defaultNotificationConfig = new NotificationConfig<>( applicationContext, channelId, channelDescription, customiser, NotificationManagerCompat.IMPORTANCE_LOW ); Handler handler = new Handler(Looper.getMainLooper()); return new DownloadMigratorBuilder(applicationContext, handler, defaultNotificationConfig); }

Target:
public static DownloadMigratorBuilder newInstance(Context context) { Context applicationContext = context.getApplicationContext(); String channelId = context.getResources().getString(R.string.migration_notification_channel_name); String channelDescription = context.getResources().getString(R.string.migration_notification_channel_description); NotificationCustomizer<MigrationStatus> customizer = new MigrationNotificationCustomizer(); NotificationConfig<MigrationStatus> defaultNotificationConfig = new NotificationConfig<>( applicationContext, channelId, channelDescription, customizer, NotificationManagerCompat.IMPORTANCE_LOW ); Handler handler = new Handler(Looper.getMainLooper()); return new DownloadMigratorBuilder(applicationContext, handler, defaultNotificationConfig); }
Source:
public String getActionUrl(final ContentType contentType, final User user) { final HttpServletRequest request = httpServletRequestThreadLocal.getRequest(); String actionUrl = request != null? getActionUrl(request, contentType, user):null; return actionUrl; }

Target:
public String getActionUrl(final ContentType contentType, final User user) { final HttpServletRequest request = httpServletRequestThreadLocal.getRequest(); return request != null ? getActionUrl(request, contentType, user):null; }
Source:
public static List<Car> createCars() { return Arrays.asList(new Car("Jeep", "Wrangler", 2011, "Jeep"), new Car("Jeep", "Comanche", 1990, "Jeep"), new Car("Dodge", "Avenger", 2010, "Sedan"), new Car("Buick", "Cascada", 2016, "Convertible"), new Car("Ford", "Focus", 2012, "Sedan"), new Car("Chevrolet", "Geo Metro", 1992, "Convertible")); }

Target:
public static List<Car> createCars() { return Arrays.asList(new Car("Jeep", "Wrangler", 2011, Category.JEEP), new Car("Jeep", "Comanche", 1990, Category.JEEP), new Car("Dodge", "Avenger", 2010, Category.SEDAN), new Car("Buick", "Cascada", 2016, Category.CONVERTIBLE), new Car("Ford", "Focus", 2012, Category.SEDAN), new Car("Chevrolet", "Geo Metro", 1992, Category.CONVERTIBLE)); }
Source:
public static FileObject getFileObject( String vfsFilename, VariableSpace space, FileSystemOptions fsOptions ) throws KettleFileException { if ( vfsFilename == null ) { throw new KettleFileException( "Unexpected null VFS filename", new NullPointerException( "KettleVFS.getFileObject() vfsFilename is NULL" ) ); } try { FileSystemManager fsManager = getInstance().getFileSystemManager(); int timeOut = TIMEOUT_LIMIT; String[] schemes = fsManager.getSchemes(); String scheme = getScheme( schemes, vfsFilename ); if ( hasSchemePattern( vfsFilename, PROVIDER_PATTERN_SCHEME ) ) { while ( scheme == null && timeOut > 0 ) { schemes = fsManager.getSchemes(); try { Thread.sleep( TIME_TO_SLEEP_STEP ); timeOut -= TIME_TO_SLEEP_STEP; scheme = getScheme( schemes, vfsFilename ); } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); break; } } } fsOptions = getFileSystemOptions( scheme, vfsFilename, space, fsOptions ); String filename = normalizePath( vfsFilename, scheme ); return fsOptions != null ? fsManager.resolveFile( filename, fsOptions ) : fsManager.resolveFile( filename ); } catch ( IOException e ) { throw new KettleFileException( "Unable to get VFS File object for filename '" + cleanseFilename( vfsFilename ) + "' : " + e.getMessage(), e ); } }

Target:
public static FileObject getFileObject( String vfsFilename, VariableSpace space, FileSystemOptions fsOptions ) throws KettleFileException { if ( vfsFilename == null ) { throw new IllegalArgumentException( "Unexpected null VFS filename." ); } try { FileSystemManager fsManager = getInstance().getFileSystemManager(); String[] schemes = fsManager.getSchemes(); String scheme = getScheme( schemes, vfsFilename ); int timeOut = TIMEOUT_LIMIT; if ( hasSchemePattern( vfsFilename, PROVIDER_PATTERN_SCHEME ) ) { while ( scheme == null && timeOut > 0 ) { schemes = fsManager.getSchemes(); try { Thread.sleep( TIME_TO_SLEEP_STEP ); timeOut -= TIME_TO_SLEEP_STEP; scheme = getScheme( schemes, vfsFilename ); } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); break; } } } fsOptions = getFileSystemOptions( scheme, vfsFilename, space, fsOptions ); String filename = normalizePath( vfsFilename, scheme ); return fsOptions != null ? fsManager.resolveFile( filename, fsOptions ) : fsManager.resolveFile( filename ); } catch ( IOException e ) { throw new KettleFileException( "Unable to get VFS File object for filename '" + cleanseFilename( vfsFilename ) + "' : " + e.getMessage(), e ); } }
Source:
Point getPointAtOffset(int offset) { int lineIndex = content.getLineAtOffset(offset); String line = content.getLine(lineIndex); int lineOffset = content.getOffsetAtLine(lineIndex); int offsetInLine = Math.max (0, offset - lineOffset); int lineLength = line.length(); if (lineIndex < content.getLineCount() - 1) { int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1; if (lineLength < offsetInLine && offsetInLine <= endLineOffset) { offsetInLine = lineLength; } } Point point; TextLayout layout = renderer.getTextLayout(lineIndex); if (lineLength != 0 && offsetInLine <= lineLength) { if (offsetInLine == lineLength) { offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); point = layout.getLocation(offsetInLine, true); } else { switch (caretAlignment) { case OFFSET_LEADING: point = layout.getLocation(offsetInLine, false); break; case PREVIOUS_OFFSET_TRAILING: default: boolean lineBegin = offsetInLine == 0; if (wordWrap && !lineBegin && (offset != caretOffset || selection.x != selection.y)) { int[] offsets = layout.getLineOffsets(); for (int i : offsets) { if (i == offsetInLine) { lineBegin = true; break; } } } if (lineBegin) { point = layout.getLocation(offsetInLine, false); } else { offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); point = layout.getLocation(offsetInLine, true); } break; } } } else { point = new Point(layout.getIndent(), 0); } renderer.disposeTextLayout(layout); point.x += leftMargin - horizontalScrollOffset; point.y += getLinePixel(lineIndex); return point; }

Target:
Point getPointAtOffset(int offset) { int lineIndex = content.getLineAtOffset(offset); String line = content.getLine(lineIndex); int lineOffset = content.getOffsetAtLine(lineIndex); int offsetInLine = Math.max (0, offset - lineOffset); int lineLength = line.length(); if (lineIndex < content.getLineCount() - 1) { int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1; if (lineLength < offsetInLine && offsetInLine <= endLineOffset) { offsetInLine = lineLength; } } Point point; TextLayout layout = renderer.getTextLayout(lineIndex); if (lineLength != 0 && offsetInLine <= lineLength) { if (offsetInLine == lineLength) { offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); point = layout.getLocation(offsetInLine, true); } else { switch (caretAlignment) { case OFFSET_LEADING: point = layout.getLocation(offsetInLine, false); break; case PREVIOUS_OFFSET_TRAILING: default: boolean lineBegin = offsetInLine == 0; if (wordWrap && !lineBegin && (offset != caretOffset || selection.x != selection.y)) { int[] offsets = layout.getLineOffsets(); for (int i : offsets) { if (i == offsetInLine) { lineBegin = true; break; } } } if (lineBegin) { point = layout.getLocation(offsetInLine, false); } else { offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); point = layout.getLocation(offsetInLine, true); } break; } } } else { point = new Point(layout.getIndent(), layout.getVerticalIndent()); } renderer.disposeTextLayout(layout); point.x += leftMargin - horizontalScrollOffset; point.y += getLinePixel(lineIndex); return point; }
Source:
public void evaluate_shouldReturnAllPatientsThatHaveTakenAllListedDrugs() throws Exception { List drugSetList = new ArrayList<Concept>(); drugSetList.add(new Concept(88)); drugSetList.add(new Concept(792)); cohortDefinition.setDrugSets(drugSetList); cohortDefinition.setWhich("ALL"); Cohort cohort = Context.getService(CohortDefinitionService.class).evaluate(cohortDefinition, null); System.out.println("Taking Drugs ALL" + cohort.getMemberIds() + " " + cohortDefinition); Assert.assertTrue(cohort.contains(2)); Assert.assertEquals(1, cohort.size()); }

Target:
public void evaluate_shouldReturnAllPatientsThatHaveTakenAllListedDrugs() throws Exception { List drugSetList = new ArrayList<Concept>(); drugSetList.add(new Concept(88)); drugSetList.add(new Concept(792)); cohortDefinition.setDrugSets(drugSetList); cohortDefinition.setWhich("ALL"); Cohort cohort = Context.getService(CohortDefinitionService.class).evaluate(cohortDefinition, null); Assert.assertTrue(cohort.contains(2)); Assert.assertEquals(1, cohort.size()); }
Source:
<DATA_TYPE> void processBackgroundOperation(OperationAndData<DATA_TYPE> operationAndData, CuratorEvent event) { boolean isInitialExecution = (event == null); if ( isInitialExecution ) { performBackgroundOperation(operationAndData); return; } boolean doQueueOperation = false; do { final KeeperException ke = KeeperException.create(event.getResultCode()); if ( getZookeeperClient().getRetryPolicy().allowRetry(ke) ) { doQueueOperation = checkBackgroundRetry(operationAndData, event); break; } if ( operationAndData.getCallback() != null ) { sendToBackgroundCallback(operationAndData, event); break; } processEvent(event); } while ( false ); if ( doQueueOperation ) { queueOperation(operationAndData); } }

Target:
<DATA_TYPE> void processBackgroundOperation(OperationAndData<DATA_TYPE> operationAndData, CuratorEvent event) { boolean isInitialExecution = (event == null); if ( isInitialExecution ) { performBackgroundOperation(operationAndData); return; } boolean doQueueOperation = false; do { if ( getZookeeperClient().getRetryPolicy().allowRetry(KeeperException.create(event.getResultCode())) ) { doQueueOperation = checkBackgroundRetry(operationAndData, event); break; } if ( operationAndData.getCallback() != null ) { sendToBackgroundCallback(operationAndData, event); break; } processEvent(event); } while ( false ); if ( doQueueOperation ) { queueOperation(operationAndData); } }
Source:
private static Integer getPreparedStatementNumberOfParameters(@Nullable ExpressionTree tree) { if (tree != null && tree.is(Tree.Kind.METHOD_INVOCATION)) { Arguments arguments = ((MethodInvocationTree) tree).arguments(); if (!arguments.isEmpty()) { ExpressionTree methodSelect = ((MethodInvocationTree) tree).methodSelect(); String methodName = null; if (methodSelect.is(Tree.Kind.MEMBER_SELECT)) { methodName = ((MemberSelectExpressionTree) methodSelect).identifier().name(); } if (methodSelect.is(Tree.Kind.IDENTIFIER)) { methodName = ((IdentifierTree) methodSelect).name(); } if ("prepareStatement".equals(methodName)) { return getNumberQuery(arguments.get(0)); } } } return null; }

Target:
private static Integer getPreparedStatementNumberOfParameters(@Nullable ExpressionTree tree) { if (tree != null && tree.is(Tree.Kind.METHOD_INVOCATION)) { Arguments arguments = ((MethodInvocationTree) tree).arguments(); if (!arguments.isEmpty() && PREPARE_STATEMENT.matches((MethodInvocationTree) tree)) { return getNumberQuery(arguments.get(0)); } } return null; }
Source:
public LinkedHashMap<String, String> getAPIPacketParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("Phone number", new String(phoneNumber).replaceAll("\0", "")); if (data != null) parameters.put("Data", data); return parameters; }

Target:
public LinkedHashMap<String, String> getAPIPacketParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("Transmit options", HexUtils.byteToHexString((byte)transmitOptions)); parameters.put("Phone number", new String(phoneNumber).replaceAll("\0", "")); if (data != null) parameters.put("Data", data); return parameters; }
Source:
private String evaluateExpression(String expr, int iterationIndex, Object[] dataValues) { String[] exprParts = expr.split("\\."); String firstPart = exprParts[0]; Object result; switch (firstPart) { case "featureName": result = feature.getName(); break; case "iterationCount": System.err.println("WARNING: #iterationCount in unroll pattern is deprecated, use #iterationIndex instead"); case "iterationIndex": result = String.valueOf(iterationIndex); break; default: int index = feature.getDataVariables().indexOf(firstPart); if (index < 0) { if (assertUnrollExpressions) { throw new SpockAssertionError("Error in @Unroll, could not find matching variable for expression: " + expr); } return "#Error:" + expr; } result = dataValues[index]; break; } try { for (int i = 1; i < exprParts.length; i++) { String currPart = exprParts[i]; if (currPart.endsWith("()")) { result = GroovyRuntimeUtil.invokeMethod(result, currPart.substring(0, currPart.length() - 2)); } else { result = GroovyRuntimeUtil.getProperty(result, currPart); } } return GroovyRuntimeUtil.toString(result); } catch (Exception e) { if (assertUnrollExpressions) { throw new SpockAssertionError("Error in @Unroll expression: " + expr, e); } return "#Error:" + expr; } }

Target:
private String evaluateExpression(String expr, int iterationIndex, Object[] dataValues) { String[] exprParts = expr.split("\\."); String firstPart = exprParts[0]; Object result; switch (firstPart) { case "featureName": result = feature.getName(); break; case "iterationIndex": result = String.valueOf(iterationIndex); break; default: int index = feature.getDataVariables().indexOf(firstPart); if (index < 0) { if (assertUnrollExpressions) { throw new SpockAssertionError("Error in @Unroll, could not find matching variable for expression: " + expr); } return "#Error:" + expr; } result = dataValues[index]; break; } try { for (int i = 1; i < exprParts.length; i++) { String currPart = exprParts[i]; if (currPart.endsWith("()")) { result = GroovyRuntimeUtil.invokeMethod(result, currPart.substring(0, currPart.length() - 2)); } else { result = GroovyRuntimeUtil.getProperty(result, currPart); } } return toStringOrDump(result); } catch (Exception e) { if (assertUnrollExpressions) { throw new SpockAssertionError("Error in @Unroll expression: " + expr, e); } return "#Error:" + expr; } }
Source:
public void malformedInputRegexpTest() throws MSDKException { File file = new File("target/test-classes/malformed_query.mgf"); MgfFileImportMethod importMethod = new MgfFileImportMethod(file); thrown.expect(MSDKException.class); thrown.expectMessage("Incorrect data format"); List<MgfMsSpectrum> spectrums = importMethod.execute(); }

Target:
public void malformedInputRegexpTest() throws MSDKException { final String file = "malformed_query.mgf"; File inputFile = getResourcePath(file).toFile(); MgfFileImportMethod importMethod = new MgfFileImportMethod(inputFile); importMethod.execute(); }
Source:
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceFiltersBuilder filters1 = (ServiceFiltersBuilder) o; return filters.equals(filters1.filters); }

Target:
public boolean equals(Object o) { return EqualsBuilder.reflectionEquals(this, o); }
Source:
public void detectControlledResources() { final Collection<Resource> semantics = session.getSemanticResources(); final Collection<Resource> resourcesToCheck = new ArrayList<Resource>(session.getTransactionalEditingDomain().getResourceSet().getResources()); List<Resource> controlledResources = session.getControlledResources(); List<Resource> controlledResourcesBefore = new ArrayList<Resource>(session.getControlledResources()); for (final Resource resource : Iterables.filter(resourcesToCheck, Predicates.not(Predicates.in(controlledResources)))) { if (hasControlledRootInSemantics(resource, semantics)) { controlledResources.add(resource); } } ListIterator<Resource> listIterator = controlledResources.listIterator(); while (listIterator.hasNext()) { Resource resource = listIterator.next(); if (!resourcesToCheck.contains(resource)) listIterator.remove(); } if (!controlledResourcesBefore.equals(controlledResources)) { session.transfertNotification(SessionListener.SEMANTIC_CHANGE); session.resetSemanticResource(); } }

Target:
public void detectControlledResources() { final Collection<Resource> semantics = session.getSemanticResources(); final Collection<Resource> resourcesToCheck = new ArrayList<Resource>(session.getTransactionalEditingDomain().getResourceSet().getResources()); List<Resource> controlledResources = session.getControlledResources(); List<Resource> controlledResourcesBefore = new ArrayList<Resource>(session.getControlledResources()); for (final Resource resource : Iterables.filter(resourcesToCheck, Predicates.not(Predicates.in(controlledResources)))) { if (hasControlledRootInSemantics(resource, semantics)) { controlledResources.add(resource); } } ListIterator<Resource> listIterator = controlledResources.listIterator(); while (listIterator.hasNext()) { Resource resource = listIterator.next(); if (!resourcesToCheck.contains(resource)) listIterator.remove(); } if (!controlledResourcesBefore.equals(controlledResources)) { session.transfertNotification(SessionListener.SEMANTIC_CHANGE); session.setSemanticResourcesNotUptodate(); } }
Source:
public boolean isMainThread() { return looper == Looper.getMainLooper(); }

Target:
public boolean isMainThread() { return looper != null && looper == Looper.getMainLooper(); }
Source:
public void run() { ISelection selection = planViewer.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Iterator selectionIterator = structuredSelection.iterator(); while (selectionIterator.hasNext()) { Object nextSelection = selectionIterator.next(); if (!(nextSelection instanceof PlanElement)) { continue; } PlanElement planElement = (PlanElement) nextSelection; planElement.setPlanElementAction(action); } actionToolbarProvider.mapActionItemsToSelection(selection); } }

Target:
public void run() { ISelection selection = planViewer.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Object selectedRow : structuredSelection.toList()) { if (selectedRow instanceof PlanElement) { PlanElement planElement = (PlanElement) selectedRow; planElement.setPlanElementAction(action); } } actionToolbarProvider.mapActionItemsToSelection(selection); } }
Source:
private boolean provideJavaClasses(IPackageFragment packageFragment, SearchEngine engine, IJavaSearchScope searchScope, IProgressMonitor monitor) throws JavaModelException, CoreException { Requestor requestor; IJavaElement[] children = packageFragment.getChildren(); SubMonitor subMonitor = SubMonitor.convert(monitor, "", children.length); for (int j = 0; j < children.length; j++) { IType[] types = null; if (children[j] instanceof ICompilationUnit) { types = ((ICompilationUnit) children[j]).getAllTypes(); } else if (children[j] instanceof IClassFile) { types = new IType[] { ((IClassFile) children[j]).getType() }; } if (types != null) { for (int t = 0; t < types.length; t++) { requestor = new Requestor(); engine.search(SearchPattern.createPattern(types[t], IJavaSearchConstants.REFERENCES), new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, searchScope, requestor, subMonitor.newChild(1)); if (requestor.foundMatches()) { return true; } } } } return false; }

Target:
private boolean provideJavaClasses(IPackageFragment packageFragment, SearchEngine engine, IJavaSearchScope searchScope, IProgressMonitor monitor) throws JavaModelException, CoreException { Requestor requestor; IJavaElement[] children = packageFragment.getChildren(); SubMonitor subMonitor = SubMonitor.convert(monitor, children.length); for (int j = 0; j < children.length; j++) { IType[] types = null; if (children[j] instanceof ICompilationUnit) { types = ((ICompilationUnit) children[j]).getAllTypes(); } else if (children[j] instanceof IClassFile) { types = new IType[] { ((IClassFile) children[j]).getType() }; } if (types != null) { SubMonitor iterationbMonitor = subMonitor.newChild(1).setWorkRemaining(types.length); for (int t = 0; t < types.length; t++) { requestor = new Requestor(); engine.search(SearchPattern.createPattern(types[t], IJavaSearchConstants.REFERENCES), new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, searchScope, requestor, iterationbMonitor.newChild(1)); if (requestor.foundMatches()) { return true; } } } else { subMonitor.worked(1); } } return false; }
Source:
private void consumerLoop() { while (true) { try { LogEventQueueEntry entry = incomingQueue.poll(POLL_TIME, TimeUnit.MILLISECONDS); if (null != entry) { Timber.LogEvent event = entry.getLogEvent(); for (LogEventHandler handler : handlers) { handler.handle(event); if (event.getConsistencyLevel() != Timber.ConsistencyLevel.BESTEFFORT) { handler.flush(); } } maybeAcknowledgeEvent(entry); } else { if (isShutdown.get()) { if (! incomingQueue.isEmpty()) { log.info("Shutdown called but queue was not empty"); continue; } log.fine("Shutdown called and queue verified to be empty"); assert incomingQueue.isEmpty(); for (LogEventHandler handler : handlers) { log.info("Closing handler " + handler.getName()); handler.close(); } log.info("exiting consumer loop"); return; } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }

Target:
private void consumerLoop() { while (true) { LogEventQueueEntry entry = null; try { entry = incomingQueue.poll(POLL_TIME, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } if (null != entry) { processEvent(entry); continue; } if (isShutdown.get()) { if (! incomingQueue.isEmpty()) { log.info("Shutdown called but queue was not empty"); continue; } log.fine("Shutdown called and queue verified to be empty"); assert incomingQueue.isEmpty(); for (LogEventHandler handler : handlers) { log.info("Closing handler " + handler.getName()); handler.close(); } log.info("exiting consumer loop"); return; } } }
Source:
public Object execute() throws Exception { InetAddress inetAddress = InetAddress.getByName(ipAddress); CompletableFuture<SnmpAgentConfig> future = fitProfile(label, inetAddress, location, oid); while (true) { try { SnmpAgentConfig agentConfig = future.get(1, TimeUnit.SECONDS); if (agentConfig != null) { System.out.printf("Fitted IpAddress '%s' with profile '%s', agent config: \n", ipAddress, agentConfig.getProfileLabel()); System.out.println(agentConfig.toString()); if (save) { agentConfigFactory.saveAgentConfigAsDefinition(agentConfig, location, "karaf-shell"); System.out.println("***Saved above config in definitions***"); } } break; } catch (TimeoutException e1) { } System.out.print("."); } return null; }

Target:
public Object execute() throws Exception { InetAddress inetAddress = InetAddress.getByName(ipAddress); CompletableFuture<Optional<SnmpAgentConfig>> future = snmpProfileMapper.fitProfile(label, inetAddress, location, oid); while (true) { try { Optional<SnmpAgentConfig> agentConfig = future.get(1, TimeUnit.SECONDS); if (agentConfig.isPresent()) { System.out.printf("Fitted IP address '%s' with profile '%s', agent config: \n", ipAddress, agentConfig.get().getProfileLabel()); ShowConfigCommand.prettyPrint(agentConfig.get()); if (save) { agentConfigFactory.saveAgentConfigAsDefinition(agentConfig.get(), location, "karaf-shell"); System.out.println("*** Saved above config in definitions ***"); } break; } else { if (Strings.isNullOrEmpty(label)) { System.out.printf("\nDidn't find any matching profile for IP address %s \n", ipAddress); } else { System.out.printf("\nProfile with label '%s' didn't fit for IP address '%s'\n", label, ipAddress); } break; } } catch (TimeoutException e1) { } System.out.print("."); } return null; }
Source:
public Expression getBuildTargetFilter() { return buildTargetFilter; }

Target:
@Nullable public Expression getBuildTargetFilter() { return buildTargetFilter; }
Source:
public void setVirtual(final boolean virtual) { this.isVirtual = virtual; }

Target:
private void setVirtual(final boolean virtual) { this.isVirtual = virtual; }
Source:
Collection<Slice> writeDeltaDeleteFile(BitSet rowsToDelete) { if (rowsToDelete.isEmpty()) { return ImmutableList.of(); } List<Long> columnIds = ImmutableList.of(0L); List<Type> columnTypes = ImmutableList.of(BIGINT); oldDeltaDeleteShardUuid.ifPresent(oldDeltaDeleteShardUuid -> mergeToRowsToDelete(rowsToDelete, oldDeltaDeleteShardUuid)); if (rowsToDelete.cardinality() == oldShardRowCount) { return shardDeleteDelta(oldShardUuid, oldDeltaDeleteShardUuid, Optional.empty()); } BlockBuilder blockBuilder = new LongArrayBlockBuilder(null, rowsToDelete.size()); for (int i = rowsToDelete.nextSetBit(0); i >= 0; i = rowsToDelete.nextSetBit(i + 1)) { blockBuilder.writeLong(i); } Block blockToDelete = blockBuilder.build(); StoragePageSink pageSink = createStoragePageSinkFunc.apply(columnIds, columnTypes); pageSink.appendPages(ImmutableList.of(new Page(blockToDelete))); List<ShardInfo> shardInfos = getFutureValue(pageSink.commit()); ShardInfo newDeltaDeleteShard = Iterables.getOnlyElement(shardInfos); return shardDeleteDelta(oldShardUuid, oldDeltaDeleteShardUuid, Optional.of(newDeltaDeleteShard)); }

Target:
Collection<Slice> writeDeltaDeleteFile(BitSet rowsToDelete) { if (rowsToDelete.isEmpty()) { return ImmutableList.of(); } oldDeltaDeleteShardUuid.ifPresent(oldDeltaDeleteShardUuid -> mergeToRowsToDelete(rowsToDelete, oldDeltaDeleteShardUuid)); if (rowsToDelete.cardinality() == oldShardRowCount) { return shardDeleteDelta(oldShardUuid, oldDeltaDeleteShardUuid, Optional.empty()); } BlockBuilder blockBuilder = new LongArrayBlockBuilder(null, rowsToDelete.size()); for (int i = rowsToDelete.nextSetBit(0); i >= 0; i = rowsToDelete.nextSetBit(i + 1)) { blockBuilder.writeLong(i); } StoragePageSink pageSink = orcStorageManager.createStoragePageSink(fileSystemContext, transactionId, bucketNumber, ImmutableList.of(0L), ImmutableList.of(BIGINT), true); pageSink.appendPages(ImmutableList.of(new Page(blockBuilder.build()))); List<ShardInfo> shardInfos = getFutureValue(pageSink.commit()); ShardInfo newDeltaDeleteShard = Iterables.getOnlyElement(shardInfos); return shardDeleteDelta(oldShardUuid, oldDeltaDeleteShardUuid, Optional.of(newDeltaDeleteShard)); }
Source:
public void testObjectEncoder() { GenericJbossMarshallerEncoder encoder = new GenericJbossMarshallerEncoder(org.infinispan.dataconversion.DataConversionTest.class.getClassLoader()); withCacheManager(new CacheManagerCallable( createCacheManager(new ConfigurationBuilder())) { GenericJBossMarshaller marshaller = new GenericJBossMarshaller(); private byte[] marshall(Object o) { try { return marshaller.objectToByteBuffer(o); } catch (IOException | InterruptedException e) { Assert.fail("Cannot marshall content"); } return null; } @Override public void call() { GlobalComponentRegistry registry = cm.getGlobalComponentRegistry(); EncoderRegistry encoderRegistry = registry.getComponent(EncoderRegistry.class); encoderRegistry.registerEncoder(encoder); cm.getClassWhiteList().addClasses(Person.class); Cache<byte[], byte[]> cache = cm.getCache(); Person key1 = new Person("key1"); Person value1 = new Person("value1"); byte[] encodedKey1 = marshall(key1); byte[] encodedValue1 = marshall(value1); cache.put(encodedKey1, encodedValue1); assertEquals(cache.get(encodedKey1), encodedValue1); AdvancedCache<Person, Person> encodingCache = (AdvancedCache<Person, Person>) cache.getAdvancedCache().withEncoding(GenericJbossMarshallerEncoder.class); assertEquals(encodingCache.get(key1), value1); } }); }

Target:
public void testObjectEncoder() { GenericJbossMarshallerEncoder encoder = new GenericJbossMarshallerEncoder(org.infinispan.dataconversion.DataConversionTest.class.getClassLoader()); withCacheManager(new CacheManagerCallable( createCacheManager(new ConfigurationBuilder())) { GenericJBossMarshaller marshaller = new GenericJBossMarshaller(); private byte[] marshall(Object o) { try { return marshaller.objectToByteBuffer(o); } catch (IOException | InterruptedException e) { throw new AssertionError("Cannot marshall content", e); } } @Override public void call() { GlobalComponentRegistry registry = cm.getGlobalComponentRegistry(); EncoderRegistry encoderRegistry = registry.getComponent(EncoderRegistry.class); encoderRegistry.registerEncoder(encoder); cm.getClassWhiteList().addClasses(Person.class); Cache<byte[], byte[]> cache = cm.getCache(); Person key1 = new Person("key1"); Person value1 = new Person("value1"); byte[] encodedKey1 = marshall(key1); byte[] encodedValue1 = marshall(value1); cache.put(encodedKey1, encodedValue1); assertEquals(cache.get(encodedKey1), encodedValue1); AdvancedCache<Person, Person> encodingCache = (AdvancedCache<Person, Person>) cache.getAdvancedCache().withEncoding(GenericJbossMarshallerEncoder.class); assertEquals(encodingCache.get(key1), value1); } }); }
Source:
public Appendable write(Appendable appendable, Context context) throws IOException { writeAnnotations(appendable, context); writeModifiers(appendable); if (!typeVariables.isEmpty()) { appendable.append('<'); Joiner.on(", ").appendTo(appendable, typeVariables); appendable.append('>'); } returnType.write(appendable, context); appendable.append(' ').append(name).append('('); Iterator<VariableWriter> parameterWritersIterator = parameterWriters.values().iterator(); if (parameterWritersIterator.hasNext()) { parameterWritersIterator.next().write(appendable, context); } while (parameterWritersIterator.hasNext()) { appendable.append(", "); parameterWritersIterator.next().write(appendable, context); } appendable.append(")"); if (body.isPresent()) { appendable.append(" {"); body.get().write(new IndentingAppendable(appendable), context); appendable.append("}\n"); } else { appendable.append(";\n"); } return appendable; }

Target:
public Appendable write(Appendable appendable, Context context) throws IOException { writeAnnotations(appendable, context); writeModifiers(appendable); Iterator<TypeVariableName> typeVariablesIterator = typeVariables.iterator(); if (typeVariablesIterator.hasNext()) { appendable.append('<'); typeVariablesIterator.next().write(appendable, context); while (typeVariablesIterator.hasNext()) { appendable.append(", "); typeVariablesIterator.next().write(appendable, context); } appendable.append("> "); } returnType.write(appendable, context); appendable.append(' ').append(name).append('('); Iterator<VariableWriter> parameterWritersIterator = parameterWriters.values().iterator(); if (parameterWritersIterator.hasNext()) { parameterWritersIterator.next().write(appendable, context); } while (parameterWritersIterator.hasNext()) { appendable.append(", "); parameterWritersIterator.next().write(appendable, context); } appendable.append(")"); if (body.isPresent()) { appendable.append(" {"); body.get().write(new IndentingAppendable(appendable), context); appendable.append("}\n"); } else { appendable.append(";\n"); } return appendable; }
Source:
public HostSetupNetworksModel(SearchableListModel listModel, VDS host) { this.sourceListModel = listModel; setEntity(host); setTitle(ConstantsManager.getInstance().getMessages().setupHostNetworksTitle(host.getName())); setHelpTag(HelpTag.host_setup_networks); setHashName("host_setup_networks"); setNicsChangedEvent(new Event<>(NICS_CHANGED_EVENT_DEFINITION)); setOperationCandidateEvent(new Event<OperationCandidateEventArgs>(OPERATION_CANDIDATE_EVENT_DEFINITION)); setLldpChangedEvent(new Event<>(LLDP_CHANGED_EVENT_DEFINITION)); setLldpChangedEvent(new Event<>(LLDP_CHANGED_EVENT_DEFINITION)); setCheckConnectivity(new EntityModel<Boolean>()); getCheckConnectivity().setEntity(true); setConnectivityTimeout(new EntityModel<Integer>()); setCommitChanges(new EntityModel<Boolean>()); getCommitChanges().setEntity(true); setShowVf(new EntityModel<>()); getShowVf().setEntity(false); getShowVf().getPropertyChangedEvent().addListener((ev, sender, args) -> redraw()); okCommand = UICommand.createDefaultOkUiCommand("OnSetupNetworks", this); getCommands().add(okCommand); getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); newLabelModel = new NewNetworkLabelModel(this); }

Target:
public HostSetupNetworksModel(SearchableListModel listModel, VDS host) { this.sourceListModel = listModel; setEntity(host); setTitle(ConstantsManager.getInstance().getMessages().setupHostNetworksTitle(host.getName())); setHelpTag(HelpTag.host_setup_networks); setHashName("host_setup_networks"); setNicsChangedEvent(new Event<>(NICS_CHANGED_EVENT_DEFINITION)); setOperationCandidateEvent(new Event<OperationCandidateEventArgs>(OPERATION_CANDIDATE_EVENT_DEFINITION)); setLldpChangedEvent(new Event<>(LLDP_CHANGED_EVENT_DEFINITION)); setCheckConnectivity(new EntityModel<Boolean>()); getCheckConnectivity().setEntity(true); setConnectivityTimeout(new EntityModel<Integer>()); setCommitChanges(new EntityModel<Boolean>()); getCommitChanges().setEntity(true); setShowVf(new EntityModel<>()); getShowVf().setEntity(false); getShowVf().getPropertyChangedEvent().addListener((ev, sender, args) -> redraw()); okCommand = UICommand.createDefaultOkUiCommand("OnSetupNetworks", this); getCommands().add(okCommand); getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); newLabelModel = new NewNetworkLabelModel(this); }
Source:
public Response remove() { Cluster cluster = parent.getClusterEntity(); for (SupportedAdditionalClusterFeature feature : cluster.getAddtionalFeaturesSupported()) { if (feature.getFeature().getId().equals(asGuid(id))) { feature.setEnabled(false); } } return parent.updateClusterEntity(cluster); }

Target:
public Response remove() { Cluster cluster = parent.getClusterEntity(); SupportedAdditionalClusterFeature feature = cluster.getAddtionalFeaturesSupported() .stream() .filter(f -> f.getFeature().getId().equals(asGuid(id))) .findFirst() .orElse(null); if (feature != null) { feature.setEnabled(false); } return parent.updateClusterEntity(cluster); }
Source:
private String getBodyContentAsString() { if (this.body == null) { return null; } try { String contentType = (this.messageProperties != null) ? this.messageProperties.getContentType() : null; if (MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT.equals(contentType)) { return SerializationUtils.deserialize(new ByteArrayInputStream(this.body), whiteListPatterns, ClassUtils.getDefaultClassLoader()).toString(); } String encoding = this.messageProperties.getContentEncoding(); if (encoding == null) { encoding = bodyEncoding; } if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON_ALT.equals(contentType) || MessageProperties.CONTENT_TYPE_XML.equals(contentType)) { return new String(this.body, encoding); } } catch (Exception e) { } return this.body.toString() + "(byte[" + this.body.length + "])"; }

Target:
private String getBodyContentAsString() { if (this.body == null) { return null; } try { boolean nullProps = this.messageProperties == null; String contentType = nullProps ? null : this.messageProperties.getContentType(); if (MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT.equals(contentType)) { return SerializationUtils.deserialize(new ByteArrayInputStream(this.body), whiteListPatterns, ClassUtils.getDefaultClassLoader()).toString(); } String encoding = nullProps ? null : this.messageProperties.getContentEncoding(); if (encoding == null) { encoding = bodyEncoding; } if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON_ALT.equals(contentType) || MessageProperties.CONTENT_TYPE_XML.equals(contentType)) { return new String(this.body, encoding); } } catch (Exception e) { } return this.body.toString() + "(byte[" + this.body.length + "])"; }
Source:
public void clickGuestRight(Right right) { try { getDriver().executeJavascript( "window.__oldConfirm = window.confirm; window.confirm = function() { return true; };"); final By buttonLocator = By.xpath("* final WebElement button = getDriver().findElement(buttonLocator); State currentState = State.getButtonState(button); button.click(); getDriver().waitUntilCondition(webDriver -> { return webDriver.findElement(buttonLocator).getAttribute("src") .contains(currentState.getNextState().imageURL); }); } finally { getDriver().executeJavascript("window.confirm = window.__oldConfirm;"); } }

Target:
public void clickGuestRight(Right right) { try { getDriver().executeJavascript( "window.__oldConfirm = window.confirm; window.confirm = function() { return true; };"); final By buttonLocator = By.xpath("* final WebElement button = getDriver().findElement(buttonLocator); State currentState = State.getButtonState(button); button.click(); getDriver().waitUntilElementContainsAttributeValue(buttonLocator, "src", currentState.getNextState().imageURL); } finally { getDriver().executeJavascript("window.confirm = window.__oldConfirm;"); } }
Source:
public @NonNull String getName() { if (fQuark == ITmfStateSystem.ROOT_ATTRIBUTE) { return ""; } return fStateSystem.getAttributeName(fQuark); }

Target:
public @NonNull String getName() { if (fQuark == ITmfStateSystem.ROOT_ATTRIBUTE) { return StringUtils.EMPTY; } return fStateSystem.getAttributeName(fQuark); }
Source:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } JobSubjectEntity other = (JobSubjectEntity) obj; if (entityId == null) { if (other.entityId != null) { return false; } } else if (!entityId.equals(other.entityId)) { return false; } if (entityType != other.entityType) { return false; } if (jobId == null) { if (other.jobId != null) { return false; } } else if (!jobId.equals(other.jobId)) { return false; } return true; }

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof JobSubjectEntity)) { return false; } JobSubjectEntity other = (JobSubjectEntity) obj; return Objects.equals(entityId, other.entityId) && Objects.equals(jobId, other.jobId); }
Source:
public void registerIdentifier( String name, IDeclaration declaration) throws ParseException{ if (identifiers.containsKey(name)) { throw new ParseException(Messages.IdentifierAlreadyDefined + ':' + name); } identifiers.put(name, declaration); }

Target:
public void registerIdentifier(String name, IDeclaration declaration) throws ParseException { if (identifiers.containsKey(name)) { throw new ParseException("Identifier has already been defined:" + name); } identifiers.put(name, declaration); }
Source:
public void testReqPasswordNullConsole() { char[] password = new ConsolePasswordFinder(null) .reqPassword(Mockito.mock(Resource.class)); Assert.assertNull("Password should be null with null console", password); }

Target:
public void testReqPasswordNullConsole() { Resource<?> resource = Mockito.mock(Resource.class); char[] password = new ConsolePasswordFinder(null, FORMAT, 1).reqPassword(resource); Assert.assertNull("Password should be null with null console", password); Mockito.verifyNoMoreInteractions(resource); }
Source:
private DiskImage isMemoryDiskAlreadyExistsInDb(Snapshot snapshot, Guid diskId, Guid imageId) { DiskImage disk = diskImageDao.get(imageId); if (disk != null) { log.warn("Memory disk '{}'/'{}' of snapshot '{}'(id: '{}') already exists on storage domain '{}'", diskId, imageId, snapshot.getDescription(), snapshot.getId(), disk.getStoragesNames().get(0)); } return disk; }

Target:
private DiskImage isMemoryDiskAlreadyExistsInDb(Snapshot snapshot, Guid diskId, Guid imageId) { DiskImage disk = diskImageDao.get(imageId); if (disk != null) { log.info("Memory disk '{}'/'{}' of snapshot '{}'(id: '{}') already exists on storage domain '{}'", diskId, imageId, snapshot.getDescription(), snapshot.getId(), disk.getStoragesNames().get(0)); } return disk; }
Source:
public FeatureVector classify(Object __example) { if (!(__example instanceof Word)) { String type = __example == null ? "null" : __example.getClass().getName(); logger.error("Classifier 'Forms(Word)' defined on line 20 of CommonFeatures.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Word word = (Word) __example; FeatureVector __result; __result = new FeatureVector(); String __id; String __value; int i; Word w = word, last = word; for (i = 0; i <= 2 && last != null; ++i) { last = (Word) last.next; } for (i = 0; i > -2 && w.previous != null; --i) { w = (Word) w.previous; } for (; w != last; w = (Word) w.next) { __id = "" + (i++); __value = "" + (w.form); __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); } return __result; }

Target:
public FeatureVector classify(Object __example) { if (!(__example instanceof Word)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'Forms(Word)' defined on line 20 of CommonFeatures.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Word word = (Word) __example; FeatureVector __result; __result = new FeatureVector(); String __id; String __value; int i; Word w = word, last = word; for (i = 0; i <= 2 && last != null; ++i) { last = (Word) last.next; } for (i = 0; i > -2 && w.previous != null; --i) { w = (Word) w.previous; } for (; w != last; w = (Word) w.next) { __id = "" + (i++); __value = "" + (w.form); __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0)); } return __result; }
Source:
private void removeLayers(Document doc) throws XPathExpressionException { List<Layer> layers = layerService.findAll(); List<String> layerNames = new ArrayList<>(); for (Layer layer : layers) { if (layer.getSource() instanceof ImageWmsLayerDataSource) { ImageWmsLayerDataSource source = (ImageWmsLayerDataSource) layer.getSource(); layerNames.add(source.getLayerNames()); } else if (layer.getSource() instanceof WfsLayerDataSource) { WfsLayerDataSource source = (WfsLayerDataSource) layer.getSource(); layerNames.add(source.getTypeName()); layerNames.add(source.getTypeNames()); } } XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(CommonNamespaces.getNamespaceContext(). addNamespace("wfs", "<LINK_0>")); NodeList list = (NodeList) xpath.compile(" List<Element> toRemove = new ArrayList<>(); for (int i = 0; i < list.getLength(); ++i) { Element name = (Element) list.item(i); String str = name.getTextContent(); if (!layerNames.contains(str)) { toRemove.add((Element) name.getParentNode()); } } xpath.setNamespaceContext(CommonNamespaces.getNamespaceContext(). addNamespace("wfs", "<LINK_0>/2.0")); list = (NodeList) xpath.compile(" for (int i = 0; i < list.getLength(); ++i) { Element name = (Element) list.item(i); String str = name.getTextContent(); if (!layerNames.contains(str)) { toRemove.add((Element) name.getParentNode()); } } toRemove.forEach(element -> element.getParentNode().removeChild(element)); }

Target:
private void removeLayers(Document doc) throws XPathExpressionException { List<Layer> layers = layerService.findAll(); List<String> layerNames = new ArrayList<>(); for (Layer layer : layers) { if (layer.getSource() instanceof ImageWmsLayerDataSource) { ImageWmsLayerDataSource source = (ImageWmsLayerDataSource) layer.getSource(); layerNames.add(source.getLayerNames()); } else if (layer.getSource() instanceof WfsLayerDataSource) { WfsLayerDataSource source = (WfsLayerDataSource) layer.getSource(); layerNames.add(source.getTypeName()); layerNames.add(source.getTypeNames()); } } XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(CommonNamespaces.getNamespaceContext(). addNamespace("wfs", "<LINK_0>")); NodeList list = (NodeList) xpath.compile(" List<Element> toRemove = new ArrayList<>(); determineFeatureTypeNodesToRemove(layerNames, list, toRemove); xpath.setNamespaceContext(CommonNamespaces.getNamespaceContext(). addNamespace("wfs", "<LINK_0>/2.0")); list = (NodeList) xpath.compile(" determineFeatureTypeNodesToRemove(layerNames, list, toRemove); toRemove.forEach(element -> element.getParentNode().removeChild(element)); }