auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public String toString() { long columnCount = getColumnCount(); String name = getName(); <START> StringBuilder stringBuilder = new StringBuilder("Table "); <END> if (name != null && !name.isEmpty()) { stringBuilder.append(getName()); stringBuilder.append(" "); } stringBuilder.append("contains "); stringBuilder.append(columnCount); stringBuilder.append(" columns: "); for (int i = 0; i < columnCount; i++) { if (i != 0) { stringBuilder.append(", "); } stringBuilder.append(getColumnName(i)); } stringBuilder.append("."); stringBuilder.append(" And "); stringBuilder.append(size()); stringBuilder.append(" rows."); return stringBuilder.toString(); }</code><technical_language>"Table" -> "The Table"</technical_language>

Target:
public String toString() { long columnCount = getColumnCount(); String name = getName(); StringBuilder stringBuilder = new StringBuilder("The Table "); if (name != null && !name.isEmpty()) { stringBuilder.append(getName()); stringBuilder.append(" "); } stringBuilder.append("contains "); stringBuilder.append(columnCount); stringBuilder.append(" columns: "); for (int i = 0; i < columnCount; i++) { if (i != 0) { stringBuilder.append(", "); } stringBuilder.append(getColumnName(i)); } stringBuilder.append("."); stringBuilder.append(" And "); stringBuilder.append(size()); stringBuilder.append(" rows."); return stringBuilder.toString(); }
Source:
<code>public void shouldReturnModifiedValuesMap() { <START> assertThat(HashMap.of(1, "1").put(2, "2").mapValues(Integer::parseInt)).isEqualTo(HashMap.of(1, 1).put(2, 2)); <END> }</code><technical_language>concrete HashMap.of is abstract Map test, base for _all_ Map implementations. Please methods empty, of ofAll implemented AbstractMapTest implementations</technical_language>

Target:
public void shouldReturnModifiedValuesMap() { assertThat(emptyIntString().put(1, "1").put(2, "2").mapValues(Integer::parseInt)).isEqualTo(emptyMap().put(1, 1).put(2, 2)); }
Source:
<code>private double getFreespeed(Map<String, String> tags, double linkLength, LinkProperties properties) { if (tags.containsKey(OsmTags.MAXSPEED)) { double maxSpeed = parseSpeedTag(tags.get(OsmTags.MAXSPEED), properties); <START> return adjustFreeSpeed ? LinkProperties.calculateSpeedIfSpeedTag(maxSpeed) : maxSpeed; <END> } else { return LinkProperties.calculateSpeedIfNoSpeedTag(linkLength, properties); } }</code><technical_language>This call is longer necessary if afterLinkCreated is usded apply urban speed factor</technical_language>

Target:
private double getFreespeed(Map<String, String> tags, double linkLength, LinkProperties properties) { if (tags.containsKey(OsmTags.MAXSPEED)) { double maxSpeed = parseSpeedTag(tags.get(OsmTags.MAXSPEED), properties); return LinkProperties.calculateSpeedIfSpeedTag(maxSpeed, freeSpeedFactor); } else { return LinkProperties.calculateSpeedIfNoSpeedTag(linkLength, properties); } }
Source:
<code>public static <T> Optional<T> findFirstPresent(Supplier<Optional<T>>... suppliers) { return Stream.of(suppliers) .flatMap(supplier -> toStream(supplier.get())) .findFirst(); <START> } <END></code><technical_language>Duplicates JdbiStreams.toStream(Optional<T>). folding method this class</technical_language>

Target:
public static <T> Optional<T> findFirstPresent(Supplier<Optional<T>>... suppliers) { return Stream.of(suppliers) .flatMap(supplier -> stream(supplier.get())) .findFirst(); }
Source:
<code>private void validateCompatibilityModeMigration(final EventType original, final EventTypeBase eventType, final List<SchemaChange> changes) throws InvalidEventTypeException { if (original.getCompatibilityMode() == CompatibilityMode.FIXED && eventType.getCompatibilityMode() == CompatibilityMode.COMPATIBLE) { final List<SchemaChange.Type> changesTypes = changes.stream().map(SchemaChange::getType) .collect(Collectors.toList()); <START> if (!FIXED_TO_COMPATIBLE_ALLOWED_CHANGES.containsAll(changesTypes)) { <END> final String errorMessage = changes.stream() .filter(change -> !FIXED_TO_COMPATIBLE_ALLOWED_CHANGES.contains(change.getType())) .map(this::formatErrorMessage) .collect(Collectors.joining(", ")); throw new InvalidEventTypeException("Invalid schema: " + errorMessage); } } }</code><technical_language>is developer do this check, avoid creating a list allMatch</technical_language>

Target:
private void validateCompatibilityModeMigration(final EventType original, final EventTypeBase eventType, final List<SchemaChange> changes) throws InvalidEventTypeException { if (original.getCompatibilityMode() == CompatibilityMode.FIXED && eventType.getCompatibilityMode() == CompatibilityMode.COMPATIBLE) { final List<SchemaChange> forbiddenChanges = changes.stream() .filter(change -> !FIXED_TO_COMPATIBLE_ALLOWED_CHANGES.contains(change.getType())) .collect(Collectors.toList()); if (!forbiddenChanges.isEmpty()) { final String errorMessage = forbiddenChanges.stream().map(this::formatErrorMessage) .collect(Collectors.joining(", ")); throw new InvalidEventTypeException("Invalid schema: " + errorMessage); } } }
Source:
<code>private StorageDomain updateStorageDomainInMemoryVolumes(List<DiskImage> disksList) { List<DiskImage> memoryDisksList = <START> MemoryUtils.createDiskDummies(VmDeviceUtils.getTotalMemorySizeInBytes(getVm()), MemoryUtils.METADATA_SIZE_IN_BYTES); <END> StorageDomain storageDomain = MemoryStorageHandler.getInstance().findStorageDomainForMemory( getParameters().getStoragePoolId(), memoryDisksList, getVmDisksDummies(), getVm()); disksList.addAll(memoryDisksList); return storageDomain; }</code><technical_language>Please, wrap line</technical_language>

Target:
private StorageDomain updateStorageDomainInMemoryVolumes(List<DiskImage> disksList) { List<DiskImage> memoryDisksList = MemoryUtils.createDiskDummies(VmUtils.getSnapshotMemorySizeInBytes(getVm()), MemoryUtils.METADATA_SIZE_IN_BYTES); StorageDomain storageDomain = MemoryStorageHandler.getInstance().findStorageDomainForMemory( getParameters().getStoragePoolId(), memoryDisksList, getVmDisksDummies(), getVm()); disksList.addAll(memoryDisksList); return storageDomain; }
Source:
<code>public boolean hasNoErrors() { <START> return !getMessages().stream().anyMatch(e -> e.getSeverity().equals(Severity.ERROR)); <END> }</code><technical_language>Sonar: Replace this negation "anyMatch()" "noneMatch()"</technical_language>

Target:
public boolean hasNoErrors() { return getMessages().stream().noneMatch(e -> e.getSeverity().equals(Severity.ERROR)); }
Source:
<code>private static SupremeCourtJudgment createScJudgmentWithRandomData(String prefix, int numericPrefix){ SupremeCourtJudgment scJudgment = new SupremeCourtJudgment(); TestInMemoryObjectFactoryHelper.fillJudgmentWithRandomData(scJudgment, prefix, numericPrefix); scJudgment.getSourceInfo().setSourceCode(SourceCode.SUPREME_COURT); scJudgment.getSourceInfo().setSourceJudgmentId(prefix+RandomStringUtils.randomAlphabetic(20)); <START> scJudgment.getSourceInfo().setSourceJudgmentUrl("<LINK_0>" + RandomStringUtils.randomAlphabetic(20)); <END> scJudgment.setPersonnelType(getRandomScPersonnelType()); SupremeCourtJudgmentForm judgmentForm = new SupremeCourtJudgmentForm(); judgmentForm.setName(RandomStringUtils.randomAlphabetic(10)); scJudgment.setScJudgmentForm(judgmentForm); return scJudgment; }</code><technical_language>moving 2 lines fillJudgmentWithRandomData</technical_language>

Target:
private static SupremeCourtJudgment createScJudgmentWithRandomData(String prefix, int numericPrefix){ SupremeCourtJudgment scJudgment = new SupremeCourtJudgment(); TestInMemoryObjectFactoryHelper.fillJudgmentWithRandomData(scJudgment, prefix, numericPrefix); scJudgment.getSourceInfo().setSourceCode(SourceCode.SUPREME_COURT); scJudgment.setPersonnelType(getRandomScPersonnelType()); SupremeCourtJudgmentForm judgmentForm = new SupremeCourtJudgmentForm(); judgmentForm.setName(RandomStringUtils.randomAlphabetic(10)); scJudgment.setScJudgmentForm(judgmentForm); return scJudgment; }
Source:
<code>private List<ValidationMessage> doValidation( final Path resourcePath, final InputStream inputStream ) throws NoProjectException { final ValidatorResultBuilder resultBuilder = new ValidatorResultBuilder(); final Builder builder = builderCache.assertBuilder( project( resourcePath ) ); if ( !builder.isBuilt() ) { builder.build(); <START> } <END> final Builder clone = builder.clone(); final IncrementalBuildResults incrementalBuildResults = clone.updateResource( Paths.convert( resourcePath ), inputStream ); if ( isIncrementalBuildPossible( resourcePath ) ) { resultBuilder.add( incrementalBuildResults.getAddedMessages() ); } else { resultBuilder.add( clone.build().getMessages() ); } return resultBuilder.results(); }</code><technical_language>I building incremental build is builder is built. avoid that</technical_language>

Target:
private List<ValidationMessage> doValidation( final Path resourcePath, final InputStream inputStream ) throws NoProjectException { final ValidatorResultBuilder resultBuilder = new ValidatorResultBuilder(); final Builder builder = builderCache.assertBuilder( project( resourcePath ) ); final org.uberfire.java.nio.file.Path nioResourcePath = Paths.convert( resourcePath ); if ( isIncrementalBuildPossible( resourcePath ) ) { if ( !builder.isBuilt() ) { builder.build(); } final Builder clone = builder.clone(); final IncrementalBuildResults incrementalBuildResults = clone.updateResource( nioResourcePath, inputStream ); resultBuilder.add( incrementalBuildResults.getAddedMessages() ); } else { final Builder clone = builder.clone(); resultBuilder.add( clone.build( nioResourcePath, inputStream ).getMessages() ); } return resultBuilder.results(); }
Source:
<code>public void fetchLocation() throws Exception { <START> Venue venue = new Venue(new VenueGroup("group"), new VenueType("type"), Lists.newArrayList(new VenueName("info", new Language("en")))); <END> CivicLocation civic = new CivicLocation("country", "city", "street", "number", "postCode"); GeoLocation geo = new GeoLocation(65.65656565, 75.75757575); CivicLocationDTO civicDTO = new CivicLocationDTO("country", "city", "street", "number", "postCode"); GeoLocationDTO geoDTO = new GeoLocationDTO(65.65656565, 75.75757575); final AccessPoint ap = new AccessPoint(new ID("id1"), "ip", new MacAddress("aa:bb"), "sn", "model", venue, geo, civic, new CapabilityList(Lists.newArrayList(new Capability(256, "a")))); context.checking(new Expectations() {{ oneOf(repository).findById("id1"); will(returnValue(Optional.of(ap))); }}); ApLocationDTO dto = new ApLocationDTO(civicDTO, geoDTO); Reply<?> reply = service.fetchLocation("id1"); assertThat(reply, containsValue(dto)); }</code><technical_language>This is unnecessary, builder for AP</technical_language>

Target:
public void fetchLocation() throws Exception { CivicLocationDTO civicDTO = new CivicLocationDTO("country", "city", "street", "number", "postCode"); GeoLocationDTO geoDTO = new GeoLocationDTO(10.0, 20.0); CivicLocation civicLocation = new CivicLocation("country", "city", "street", "number", "postCode"); GeoLocation geoLocation = new GeoLocation(10.0, 20.0); final AccessPoint ap = newAp().civicLocation(civicLocation).geoLocation(geoLocation).build(); context.checking(new Expectations() {{ oneOf(repository).findById("id1"); will(returnValue(Optional.of(ap))); }}); ApLocationDTO dto = new ApLocationDTO(civicDTO, geoDTO); Reply<?> reply = service.fetchLocation("id1"); assertThat(reply, containsValue(dto)); }
Source:
<code>public void testInnerJoinPropagatesPredicatesViaEquiConditions() { <START> ImmutableList.Builder<JoinNode.EquiJoinClause> criteriaBuilder = ImmutableList.builder(); <END> criteriaBuilder.add(new JoinNode.EquiJoinClause(A, D)); List<JoinNode.EquiJoinClause> criteria = criteriaBuilder.build(); Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C))); TableScanNode leftScan = new TableScanNode( newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(leftAssignments.keySet()), leftAssignments, Optional.empty(), TupleDomain.all(), TupleDomain.all()); Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F))); TableScanNode rightScan = new TableScanNode( newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(rightAssignments.keySet()), rightAssignments, Optional.empty(), TupleDomain.all(), TupleDomain.all()); FilterNode left = filter(leftScan, equals(AE, bigintLiteral(10))); PlanNode node = new JoinNode(newId(), JoinNode.Type.INNER, left, rightScan, criteria, ImmutableList.<Symbol>builder() .addAll(rightScan.getOutputSymbols()) .build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); Expression effectivePredicate = effectivePredicateExtractor.extract(node); assertEquals( normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(DE, bigintLiteral(10)))); }</code><technical_language>inline criteriaBuilder</technical_language>

Target:
public void testInnerJoinPropagatesPredicatesViaEquiConditions() { Map<Symbol, ColumnHandle> leftAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C))); TableScanNode leftScan = tableScanNode(leftAssignments); Map<Symbol, ColumnHandle> rightAssignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(D, E, F))); TableScanNode rightScan = tableScanNode(rightAssignments); FilterNode left = filter(leftScan, equals(AE, bigintLiteral(10))); PlanNode node = new JoinNode(newId(), JoinNode.Type.INNER, left, rightScan, ImmutableList.of(new JoinNode.EquiJoinClause(A, D)), ImmutableList.<Symbol>builder() .addAll(rightScan.getOutputSymbols()) .build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); Expression effectivePredicate = effectivePredicateExtractor.extract(node); assertEquals( normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(DE, bigintLiteral(10)))); }
Source:
<code>public void dragStart(DragSourceEvent event) { final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); <START> LocalSelectionTransfer.getTransfer().setSelection(selection); <END> }</code><technical_language>setSelection takes ISelection, need cast get viewer. do need a local variable</technical_language>

Target:
public void dragStart(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(fTreeViewer.getSelection()); }
Source:
<code>public DocumentLock getLock(DocumentReference doc) { XWikiContext context = (XWikiContext) this.execution.getContext().getProperty("xwikicontext"); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.getFamilyById(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); <START> if (xlock != null && !xlock.getUserName().equals(context.getUser())) { <END> Set<String> actions = Collections.singleton("edit"); User user = this.userManager.getUser(xlock.getUserName()); return new DocumentLock(user, xlock.getDate(), "This family is already being edited by " + user.getName(), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }</code><technical_language>context.getUser() is deprecated. this.userManager.getCurrentUser().getName() instead</technical_language>

Target:
public DocumentLock getLock(DocumentReference doc) { XWikiContext context = this.provider.get(); XWikiDocument xdoc; try { xdoc = context.getWiki().getDocument(doc, context); if (xdoc == null) { return null; } String documentId = xdoc.getDocumentReference().getName(); Family family = this.familyRepository.getFamilyById(documentId); if (family == null) { return null; } XWikiLock xlock = xdoc.getLock(context); User user = this.userManager.getUser(xlock.getUserName()); if (xlock != null && !user.getId().equals(this.userManager.getCurrentUser().getId())) { Set<String> actions = Collections.singleton("edit"); return new DocumentLock(user, xlock.getDate(), this.tm.translate("family.locks.familyInUse", user.getName()), actions, false); } } catch (XWikiException e) { this.logger.error("Failed to access the document lock: {}", e.getMessage(), e); } return null; }
Source:
<code><START> public void itemWriterWithNoEmbeddedHeaders() throws Exception { <END> AvroItemWriter avroItemWriter = new AvroItemWriter(output, plainOldUserSchemaResource,PlainOldUser.class); avroItemWriter.setEmbedHeader(false); avroItemWriter.afterPropertiesSet(); avroItemWriter.open(new ExecutionContext()); avroItemWriter.write(this.plainOldUsers()); avroItemWriter.close(); verifyRecords(outputStream.toByteArray(), this.plainOldUsers(), PlainOldUser.class, false); }</code><technical_language>a bit confused this test shouldFailWitNoSchema test, especially part: java AvroItemWriter<PlainOldUser> avroItemWriter = new AvroItemWriter<>(output, plainOldUserSchemaResource,PlainOldUser.class); avroItemWriter.setEmbedHeader(false); I provide a Schema if I set embedHeader false? For reader, read PlainOldUsers avro file a schema providing a schema. In way, able write PlainOldUsers avro file embedding schema. In case, is schema mandatory? specific, a mandatory schema option embed is confusing me</technical_language>

Target:
public void itemWriterWithNoEmbeddedHeaders() throws Exception { AvroItemWriter<PlainOldUser> avroItemWriter = new AvroItemWriter(output, PlainOldUser.class); avroItemWriter.open(new ExecutionContext()); avroItemWriter.write(this.plainOldUsers()); avroItemWriter.close(); verifyRecords(outputStream.toByteArray(), this.plainOldUsers(), PlainOldUser.class, false); }
Source:
<code>public void testEncryptionGcmCtr() throws Exception { Configuration conf = new Configuration(); <START> conf.set(SchemaCryptoPropertiesFactory.CONF_ENCRYPTION_ALGORITHM, "AES_GCM_V1"); <END> runTest(conf); }</code><technical_language>I suggest related constant instead</technical_language>

Target:
public void testEncryptionGcmCtr() throws Exception { Configuration conf = new Configuration(); conf.set(SchemaCryptoPropertiesFactory.CONF_ENCRYPTION_ALGORITHM, ParquetCipher.AES_GCM_CTR_V1.toString()); runTest(conf); }
Source:
<code>public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (interval != null ? interval.hashCode() : 0); result = 31 * result + (columns != null ? columns.hashCode() : 0); result = 31 * result + (int) (size ^ (size >>> 32)); <START> result = 31 * result + numRows; <END> return result; }</code><technical_language>reason this changed</technical_language>

Target:
public int hashCode() { return Objects.hash(id, interval, columns, size, numRows, aggregators); }
Source:
<code>public void warn() { if (!disabled) { <START> logger.warning("DNS multicast capability has been removed from Jenkins."); <END> } }</code><technical_language>suggestion LOGGER.warning("DNS multicast capability removed Jenkins.");</technical_language>

Target:
public static void warn() { if (!disabled) { LOGGER.warning("DNS multicast capability has been removed from Jenkins. More information: <LINK_0>"); } }
Source:
<code>protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 1, bytes[0]); <START> description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, marker - 1)); <END> marker += description.getTerminator().length; value = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, bytes.length - marker)); }</code><technical_language>If description zero length, marker position 0, in case copyBuffer fail. I suggest adding is done in ID3v2UrlFrameData, checks if marker >= 0 copy, sets description empty string</technical_language>

Target:
protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 1, bytes[0]); if (marker >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, marker - 1)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 1; } if (bytes.length - marker >= 0) { value = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, bytes.length - marker)); } else { value = new EncodedText(bytes[0], ""); } }
Source:
<code>boolean boxedNotEqual3(Boolean B, Boolean V) { <START> return B != V; END> }</code><technical_language>is this noncompliant</technical_language>

Target:
void boxedNotEqual3(Boolean B, Boolean V) { if (B != V) { foo(); } else { bar(); } }
Source:
<code>public static QueryTree build(List<QueryTree> children) { if (children.size() == 0) throw new IllegalArgumentException("Cannot build DisjunctionNode with no children"); if (children.size() == 1) return children.get(0); <START> List<QueryTree> anyChildren = children.stream().filter(QueryTree::isAny).collect(Collectors.toList()); <END> if (anyChildren.isEmpty() == false) { return anyChildren.get(0); } return new DisjunctionNode(children); }</code><technical_language>Alternatively this changed Optional<QueryTree> children.stream().filter(QueryTree::isAny).findAny() full list is used</technical_language>

Target:
public static QueryTree build(List<QueryTree> children) { if (children.size() == 0) throw new IllegalArgumentException("Cannot build DisjunctionNode with no children"); if (children.size() == 1) return children.get(0); Optional<QueryTree> firstAnyChild = children.stream().filter(QueryTree::isAny).findAny(); return firstAnyChild.orElseGet(() -> new DisjunctionNode(children)); }
Source:
<code>public void enableValueNotifications(Consumer<byte[]> callback) throws KuraBluetoothNotificationException { try { DeviceManager.getInstance().registerPropertyHandler(new AbstractPropertiesChangedHandler() { @Override public void handle(PropertiesChanged props) { if (props != null) { if (!props.getPath().contains(BluetoothLeGattCharacteristicImpl.this.characteristic.getDbusPath())) { return; } for (Map.Entry<String, Variant<?>> entry : props.getPropertiesChanged().entrySet()) { if (entry.getKey().equals("Value")) { Object obj = entry.getValue().getValue(); byte[] val = (byte[]) obj; callback.accept(val); } <START> } <END> } } }); this.characteristic.startNotify(); } catch (DBusException e) { throw new KuraBluetoothNotificationException(e, "Notification can't be enabled"); } }</code><technical_language>byte[] = (byte[]) props.getPropertiesChanged().get("Value").getValue(); if (value != null) { callback.accept(value); }</technical_language>

Target:
public void enableValueNotifications(Consumer<byte[]> callback) throws KuraBluetoothNotificationException { try { DeviceManager.getInstance().registerPropertyHandler(new AbstractPropertiesChangedHandler() { @Override public void handle(PropertiesChanged props) { if (props != null) { if (!props.getPath().contains(BluetoothLeGattCharacteristicImpl.this.characteristic.getDbusPath())) { return; } for (Map.Entry<String, Variant<?>> entry : props.getPropertiesChanged().entrySet()) { if (entry.getKey().equals("Value")) { byte[] value = (byte[]) props.getPropertiesChanged().get("Value").getValue(); if (value != null) { callback.accept(value); } } } } } }); this.characteristic.startNotify(); } catch (DBusException e) { throw new KuraBluetoothNotificationException(e, "Notification can't be enabled"); } }
Source:
<code>public NettyByteBufLeakHelper() { <START> cachedEnabled = Integer.parseInt(System.getProperty("io.netty.alllocator.maxCachedBufferCapacity", "0")) != 0; <END> }</code><technical_language>This allocator instead of alllocator. netty a constant for property name here</technical_language>

Target:
public NettyByteBufLeakHelper() { cachedEnabled = Integer.parseInt(System.getProperty("io.netty.allocator.maxCachedBufferCapacity", "0")) != 0; }
Source:
<code>public TestClasspathRegistry(Set<TestClasspathProvider> testClasspathProviders) { <START> System.out.println("inititilaized TestClasspathRegistry " + testClasspathProviders.size() + " wkwkwkwkwk " + <END> testClasspathProviders.toString()); testClasspathProviders.forEach(this::register); }</code><technical_language>logger if need log</technical_language>

Target:
public TestClasspathRegistry(Set<TestClasspathProvider> testClasspathProviders) { testClasspathProviders.forEach(this::register); }
Source:
<code>public void getResourcesInformation(final IDMContext dmc, final String resourceClass, final DataRequestMonitor<IResourcesInformation> rm) { <START> getExecutor().submit(new DsfRunnable() { <END> @Override public void run() { IGDBControl control = getServicesTracker().getService(IGDBControl.class); control.queueCommand(new MIInfoOs(dmc, resourceClass), new DataRequestMonitor<MIInfoOsInfo>(getExecutor(), rm) { @Override protected void handleCompleted() { rm.setData(getData().getResourcesInformation()); super.handleCompleted(); } }); } }); }</code><technical_language>This class is a DSF service called DSF executor. run code submitting executor</technical_language>

Target:
public void getResourcesInformation(final IDMContext dmc, final String resourceClass, final DataRequestMonitor<IResourcesInformation> rm) { IGDBControl control = getServicesTracker().getService(IGDBControl.class); CommandFactory factory = control.getCommandFactory(); control.queueCommand(factory.createMIInfoOS(dmc, resourceClass), new DataRequestMonitor<MIInfoOsInfo>(getExecutor(), rm) { @Override protected void handleSuccess() { rm.setData(getData().getResourcesInformation()); rm.done(); } }); }
Source:
<code>private void flushAndCheckpointState() { try { stateMgr.flush(); } catch (final ProcessorStateException e) { <START> if (e.getCause() instanceof ProducerFencedException) { <END> log.warn("Caught a retriable Kafka exception while flushing state. Initiating a rebalance to attempt recovery.", e); throw new TaskMigratedException(this, e); } } stateMgr.checkpoint(Collections.emptyMap()); }</code><technical_language>argument for GlobalStateStore apply -- StandbyTask write read, hence, ProducerFencedException happen here</technical_language>

Target:
private void flushAndCheckpointState() { stateMgr.flush(); stateMgr.checkpoint(Collections.emptyMap()); }
Source:
<code>public void testSingleCast() { Single<?> source = Single.just(1); Single<Integer> single = source.cast(Integer.class); @SuppressWarnings("unchecked") Observer<Integer> observer = mock(Observer.class); single.subscribe(observer); verify(observer, times(1)).onNext(1); <START> verify(observer, times(1)).onNext(1); <END> verify(observer, never()).onError( org.mockito.Matchers.any(Throwable.class)); verify(observer, times(1)).onCompleted(); }</code><technical_language>onNext(2), mistake in [OperatorCastTest](<LINK_0> well</technical_language>

Target:
public void testSingleCast() { Single<?> source = Single.just(1); Single<Integer> single = source.cast(Integer.class); @SuppressWarnings("unchecked") Observer<Integer> observer = mock(Observer.class); single.subscribe(observer); verify(observer, times(1)).onNext(1); verify(observer, never()).onError( org.mockito.Matchers.any(Throwable.class)); verify(observer, times(1)).onCompleted(); }
Source:
<code>private void processAttrs(AttributeSet attrs) { if (attrs != null) { mUseParentLayoutParams = attrs.getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.useParentLayoutParams, true); mLayoutManagerOrientationString = attrs.getAttributeValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerOrientation); mRtlLayout = attrs.getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerReverse, mRtlLayout); mSpanCount = attrs.getAttributeIntValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerSpanCount, 1); mInitialPrefetchCount = attrs.getAttributeIntValue(null, BindingResources.attr.BindableRecyclerView.initialPrefetchCount, 0); mLayoutManagerType = attrs.getAttributeValue(null, BindingResources.attr.BindableRecyclerView.layoutManager); <START> Boolean nestedScrollingEnabled = attrs <END> .getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.nestedScrollingEnabled, isNestedScrollingEnabled()); if (nestedScrollingEnabled != isNestedScrollingEnabled()) { setNestedScrollingEnabled(nestedScrollingEnabled); } } }</code><technical_language>object primitive type</technical_language>

Target:
private void processAttrs(AttributeSet attrs) { if (attrs != null) { mUseParentLayoutParams = attrs.getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.useParentLayoutParams, true); mLayoutManagerOrientationString = attrs.getAttributeValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerOrientation); mRtlLayout = attrs.getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerReverse, mRtlLayout); mSpanCount = attrs.getAttributeIntValue(null, BindingResources.attr.BindableRecyclerView.layoutManagerSpanCount, 1); mInitialPrefetchCount = attrs.getAttributeIntValue(null, BindingResources.attr.BindableRecyclerView.initialPrefetchCount, 0); mLayoutManagerType = attrs.getAttributeValue(null, BindingResources.attr.BindableRecyclerView.layoutManager); boolean nestedScrollingEnabled = attrs .getAttributeBooleanValue(null, BindingResources.attr.BindableRecyclerView.nestedScrollingEnabled, isNestedScrollingEnabled()); if (nestedScrollingEnabled != isNestedScrollingEnabled()) { setNestedScrollingEnabled(nestedScrollingEnabled); } } }
Source:
<code>public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, EncodingManager.Access access, long relationFlags) { if (readerWay.hasTag("toll", "yes")) tollEnc.setEnum(false, edgeFlags, Toll.ALL); if (readerWay.hasTag("toll:hgv", "yes")) <START> tollEnc.setEnum(false, edgeFlags, Toll.HGV); <END> return edgeFlags; }</code><technical_language>For edge with: toll=yes toll:hgv=yes This result in Toll.HGV Toll.ALL</technical_language>

Target:
public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, EncodingManager.Access access, long relationFlags) { if (readerWay.hasTag("toll", "yes")) tollEnc.setEnum(false, edgeFlags, Toll.ALL); else if (readerWay.hasTag("toll:hgv", "yes")) tollEnc.setEnum(false, edgeFlags, Toll.HGV); return edgeFlags; }
Source:
<code>private void unregisterAndCloseRepository(final Key location, Repository db) { synchronized (lockFor(location)) { <START> if (isExpired(db)) { <END> Repository oldDb = unregisterRepository(location); if (oldDb != null) { oldDb.doClose(); } } } }</code><technical_language>this removed</technical_language>

Target:
private void unregisterAndCloseRepository(final Key location, Repository db) { synchronized (lockFor(location)) { Repository oldDb = unregisterRepository(location); if (oldDb != null) { oldDb.doClose(); } } }
Source:
<code>default T reduceRight(BiFunction<? super T, ? super T, ? extends T> op) { <START> return reduceLeft(op); <END> }</code><technical_language>return get();</technical_language>

Target:
default T reduceRight(BiFunction<? super T, ? super T, ? extends T> op) { Objects.requireNonNull(op, "op is null"); return get(); }
Source:
<code>private void logConflictOverridesIfEnabled(String[] overrideConflicts) { if (log.isDebugEnabled()) { for (String s : overrideConflicts) { <START> log.debug("Forcing conflict if encountered: " + s); <END> } } }</code><technical_language>Log string concatenation</technical_language>

Target:
private void logConflictOverridesIfEnabled(String[] overrideConflicts) { if (log.isDebugEnabled()) { for (String s : overrideConflicts) { log.debug("Forcing conflict if encountered: {}", s); } } }
Source:
<code>private void handleEmbed(EmbedEvent event) { String mimeType = event.mimeType; if(mimeType.startsWith("text/")) { if (event.name != null) { jsFunctionCall("embedding", mimeType, new String(event.data), event.name); } else { jsFunctionCall("embedding", mimeType, new String(event.data)); } } else { String extension = MIME_TYPES_EXTENSIONS.get(mimeType); if (extension != null) { StringBuilder fileName = new StringBuilder("embedded").append(embeddedIndex++).append(".").append(extension); writeBytesToURL(event.data, toUrl(fileName.toString())); if (event.name != null) { jsFunctionCall("embedding", mimeType, fileName, event.name); } else { <START> jsFunctionCall("embedding", mimeType, fileName); <END> } } } }</code><technical_language>fix jsFunctionCall this if statement needed</technical_language>

Target:
private void handleEmbed(EmbedEvent event) { String mimeType = event.mimeType; if(mimeType.startsWith("text/")) { jsFunctionCall("embedding", mimeType, new String(event.data), event.name); } else { String extension = MIME_TYPES_EXTENSIONS.get(mimeType); if (extension != null) { StringBuilder fileName = new StringBuilder("embedded").append(embeddedIndex++).append(".").append(extension); writeBytesToURL(event.data, toUrl(fileName.toString())); jsFunctionCall("embedding", mimeType, fileName, event.name); } } }
Source:
<code>public void releaseImageReaderListWhenDeatached() { mDeferredImageReaderSurface.refresh(); mDeferredImageReaderSurface.notifySurfaceAttached(); mDeferredImageReaderSurface.refresh(); mDeferredImageReaderSurface.notifySurfaceAttached(); assertThat(mDeferredImageReaderSurface.mImageReaderToReleaseList.size()) <START> .isEqualTo(2); <END> mDeferredImageReaderSurface.notifySurfaceDetached(); assertThat(mDeferredImageReaderSurface.getAttachedCount()) .isEqualTo(2); assertThat(mDeferredImageReaderSurface.getSurface()).isNotNull(); assertThat(mDeferredImageReaderSurface.mImageReaderToReleaseList.size()) .isEqualTo(0); }</code><technical_language>need wrap line</technical_language>

Target:
public void releaseImageReaderListWhenDeatached() { mDeferredImageReaderSurface.refresh(); mDeferredImageReaderSurface.notifySurfaceAttached(); mDeferredImageReaderSurface.refresh(); mDeferredImageReaderSurface.notifySurfaceAttached(); assertThat(mDeferredImageReaderSurface.mImageReaderToReleaseList.size()) .isEqualTo(2); mDeferredImageReaderSurface.notifySurfaceDetached(); assertThat(mDeferredImageReaderSurface.getAttachedCount()).isEqualTo(2); assertThat(mDeferredImageReaderSurface.mImageReaderToReleaseList.size()) .isEqualTo(0); assertThat(mDeferredImageReaderSurface.getImageReader()).isNotNull(); }
Source:
<code>public void iSetUpADriverToAnIncorrectPort() throws Throwable { <START> try ( Driver driver = GraphDatabase.driver( "bolt://localhost:" + getFreePort() ); <END> Session session = driver.session() ) { session.run( "RETURN 1" ); } catch ( Exception e ) { exception = e; } }</code><technical_language>port 80 of some other registered port Bolt</technical_language>

Target:
public void iSetUpADriverToAnIncorrectPort() throws Throwable { try ( Driver driver = GraphDatabase.driver( "bolt://localhost:777" ); Session session = driver.session() ) { session.run( "RETURN 1" ); } catch ( Exception e ) { exception = e; } }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_widget_config); Intent configIntent = getIntent(); Bundle extras = configIntent.getExtras(); <START> if(extras != null){ <END> appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetId); setResult(RESULT_CANCELED,resultValue); if(appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID){ finish(); } opacityTextview = findViewById(R.id.widget_opacity_textView); opacitySeekbar = findViewById(R.id.widget_opacity_seekBar); opacitySeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { opacityTextview.setText(seekBar.getProgress() + "%"); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }</code><technical_language>Please add spaces if (, ) {. I want get this style consistent project. other if statements</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_widget_config); Intent configIntent = getIntent(); Bundle extras = configIntent.getExtras(); if (extras != null) { appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_CANCELED, resultValue); if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } displayDeviceBackground(); opacityTextView = findViewById(R.id.widget_opacity_textView); opacitySeekBar = findViewById(R.id.widget_opacity_seekBar); widgetPreview = findViewById(R.id.widgetLayout); findViewById(R.id.butConfirm).setOnClickListener(this::confirmCreateWidget); opacitySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { opacityTextView.setText(seekBar.getProgress() + "%"); int color = getColorWithAlpha(PlayerWidget.DEFAULT_COLOR, opacitySeekBar.getProgress()); widgetPreview.setBackgroundColor(color); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }
Source:
<code>public TypeInfo visit(CharType charType) { <START> if (charType.getLength() > HiveChar.MAX_CHAR_LENGTH || charType.getLength() < 1) { <END> if (checkPrecision) { throw new CatalogException( String.format("HiveCatalog doesn't support char type with length of '%d'. " + "The maximum length is %d", charType.getLength(), HiveChar.MAX_CHAR_LENGTH)); } else { return TypeInfoFactory.stringTypeInfo; } } return TypeInfoFactory.getCharTypeInfo(charType.getLength()); }</code><technical_language>modify varchar</technical_language>

Target:
public TypeInfo visit(CharType charType) { if (charType.getLength() > HiveChar.MAX_CHAR_LENGTH || charType.getLength() < 1) { if (checkPrecision) { throw new CatalogException( String.format("HiveCatalog doesn't support char type with length of '%d'. " + "The supported length is [%d, %d]", charType.getLength(), 1, HiveChar.MAX_CHAR_LENGTH)); } else { return TypeInfoFactory.stringTypeInfo; } } return TypeInfoFactory.getCharTypeInfo(charType.getLength()); }
Source:
<code>public List<Change.Id> changesReviewedBy(final ReviewDb db, final String userName) { UserNameProcessor processor = new UserNameProcessor(db, userName) { @Override void process(ReviewDb db, Account account, Map<Id, Change> outResultChanges) throws OrmException { ChangeApprovalAccess changes = db.changeApprovals(); ChangeAccess changeAccess = db.changes(); Iterator<ChangeApproval> changeIterator = changes.reviewedByUser(account.getId()).iterator(); while (changeIterator.hasNext()) { ChangeApproval approval = changeIterator.next(); <START> Change change = changeAccess.get(approval.getChangeId()); <END> if (change != null) { outResultChanges.put(change.getId(), change); } } } }; processor.run(); return filterResults(processor.getResult()); }</code><technical_language>this form of helper return Set<Change.Id> fall want list in searchQuery() load Change record twice</technical_language>

Target:
private List<Change.Id> changesReviewedBy(final ReviewDb db, final String userName) { UserNameProcessor processor = new UserNameProcessor(db, userName) { @Override void process(ReviewDb db, Account.Id account, Map<Id, Change> outResultChanges) throws OrmException { ChangeApprovalAccess changes = db.changeApprovals(); ChangeAccess changeAccess = db.changes(); Iterator<ChangeApproval> changeIterator = changes.reviewedByUser(account).iterator(); while (changeIterator.hasNext()) { ChangeApproval approval = changeIterator.next(); Change change = changeAccess.get(approval.getChangeId()); if (change != null) { outResultChanges.put(change.getId(), change); } } } }; return new ArrayList<Change.Id>(processor.call()); }
Source:
<code>public void customizedNamesAreBoundCorrectly() throws NoSuchFieldException { db.getJdbi().useHandle(h -> { h.createUpdate("create table enums(id int, name varchar)").execute(); h.createUpdate("insert into enums (id, name) values (1, :name)") .bind("name", Foobar.CUSTOM) .execute(); String ordinal = h.createQuery("select name from enums") .mapTo(String.class) .one(); assertThat(ordinal) .isEqualTo(Foobar.class.getField(Foobar.CUSTOM.name()) <START> .getAnnotation(DatabaseValue.class).value()); <END> }); }</code><technical_language>I for a test explicit expected values calculated values possible. This test reads more assert impl() == impl() should</technical_language>

Target:
public void customizedNamesAreBoundCorrectly() throws NoSuchFieldException { db.getJdbi().useHandle(h -> { h.createUpdate("create table enums(id int, name varchar)").execute(); h.createUpdate("insert into enums (id, name) values (1, :name)") .bind("name", Foobar.CUSTOM) .execute(); final String databaseString = h.createQuery("select name from enums") .mapTo(String.class) .one(); assertThat(databaseString) .isEqualTo("CUST"); }); }
Source:
<code>protected PageableResult doSearch(RequestContext context) { String patientUuid = context.getRequest().getParameter("patient"); if (patientUuid != null) { Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) return new EmptySearchResult(); List<Obs> obs = Context.getObsService().getObservationsByPerson(patient); return new NeedsPaging<Obs>(obs, context); } String encounterUuid = context.getRequest().getParameter("encounter"); <START> boolean includeVoided = Boolean.parseBoolean(context.getRequest().getParameter("includeAll")); <END> if (encounterUuid != null) { Encounter enc = ((EncounterResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( Encounter.class)).getByUniqueId(encounterUuid); if (enc == null) return new EmptySearchResult(); if (includeVoided) { List<Obs> obs = new ArrayList<Obs>(enc.getAllObs(includeVoided)); return new NeedsPaging<Obs>(obs, context); } else { List<Obs> obs = new ArrayList<Obs>(enc.getAllObs()); return new NeedsPaging<Obs>(obs, context); } } return new NeedsPaging<Obs>(Context.getObsService().getObservations(context.getParameter("q")), context); }</code><technical_language>try context.getIncludeAll()</technical_language>

Target:
protected PageableResult doSearch(RequestContext context) { String patientUuid = context.getRequest().getParameter("patient"); if (patientUuid != null) { Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) return new EmptySearchResult(); List<Obs> obs = Context.getObsService().getObservationsByPerson(patient); return new NeedsPaging<Obs>(obs, context); } String encounterUuid = context.getRequest().getParameter("encounter"); if (encounterUuid != null) { Encounter enc = ((EncounterResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( Encounter.class)).getByUniqueId(encounterUuid); if (enc == null) return new EmptySearchResult(); List<Obs> obs = new ArrayList<Obs>(enc.getAllObs(context.getIncludeAll())); return new NeedsPaging<Obs>(obs, context); } return new NeedsPaging<Obs>(Context.getObsService().getObservations(context.getParameter("q")), context); }
Source:
<code>public void initialise() { setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation()); WidgetUtil.trySubscribe(this, "close", button -> { final UniverseSetupScreen universeSetupScreen = getManager().createScreen(UniverseSetupScreen.ASSET_URI, UniverseSetupScreen.class); final WorldPreGenerationScreen worldPreGenerationScreen = getManager().createScreen(WorldPreGenerationScreen.ASSET_URI, WorldPreGenerationScreen.class); UIText customWorldName = find("customisedWorldName", UIText.class); boolean goBack = false; if (customWorldName.getText().isEmpty()) { getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Name Cannot Be Empty!", "Please add a name for the world"); } else if (customWorldName.getText().equalsIgnoreCase(world.getWorldName().toString())) { goBack = true; } else { boolean worldNameMatchesAnother = false; for (String worldName : universeSetupScreen.worldNames()) { if (worldName.equalsIgnoreCase(customWorldName.getText())) { worldNameMatchesAnother = true; break; } } <START> if (worldNameMatchesAnother == true) { <END> getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Name Already Used!", "Please use a different name for this world"); } else { goBack = true; } } if (goBack == true) { newWorldName = new Name(customWorldName.getText()); world.setWorldName(newWorldName); universeSetupScreen.refreshWorldDropdown(worldsDropdown); worldPreGenerationScreen.setName(newWorldName); triggerBackAnimation(); } }); }</code><technical_language>need ==true in this if statement - if (worldNameMatchesAnother) { this line</technical_language>

Target:
public void initialise() { setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation()); WidgetUtil.trySubscribe(this, "close", button -> { final UniverseSetupScreen universeSetupScreen = getManager().createScreen(UniverseSetupScreen.ASSET_URI, UniverseSetupScreen.class); final WorldPreGenerationScreen worldPreGenerationScreen = getManager().createScreen(WorldPreGenerationScreen.ASSET_URI, WorldPreGenerationScreen.class); UIText customWorldName = find("customisedWorldName", UIText.class); boolean goBack = false; if (customWorldName.getText().isEmpty()) { getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Name Cannot Be Empty!", "Please add a name for the world"); } else if (customWorldName.getText().equalsIgnoreCase(world.getWorldName().toString())) { goBack = true; } else if (universeSetupScreen.worldNameMatchesAnother(customWorldName.getText())) { getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Name Already Used!", "Please use a different name for this world"); } else { goBack = true; } if (goBack) { newWorldName = new Name(customWorldName.getText()); world.setWorldName(newWorldName); universeSetupScreen.refreshWorldDropdown(worldsDropdown); worldPreGenerationScreen.setName(newWorldName); triggerBackAnimation(); } }); }
Source:
<code>public <T> Map<Path, SortOrder> getValidSortingRules(final Class<T> entityClass, final EntityDictionary dictionary) throws InvalidValueException { Map<Path, SortOrder> returnMap = new LinkedHashMap<>(); for (Map.Entry<String, SortOrder> entry : replaceIdRule(dictionary.getIdFieldName(entityClass)).entrySet()) { String dotSeparatedPath = entry.getKey(); SortOrder order = entry.getValue(); Path path = new Path(entityClass, dictionary, dotSeparatedPath); <START> for (Path.PathElement pathElement : path.getPathElements()) { <END> if (! dictionary.isRelation(pathElement.getType(), pathElement.getFieldName())) { continue; } if (dictionary.getRelationshipType(pathElement.getType(), pathElement.getFieldName()).isToMany()) { throw new InvalidValueException("Cannot sort across a to-many relationship: " + pathElement.getTypeName() + "." + pathElement.getFieldName() ); } } returnMap.put(path, order); } return returnMap; }</code><technical_language>break this out function for readability? i.e. isValidSortingRule(Path). This reused in logic above</technical_language>

Target:
public <T> Map<Path, SortOrder> getValidSortingRules(final Class<T> entityClass, final EntityDictionary dictionary) throws InvalidValueException { Map<Path, SortOrder> returnMap = new LinkedHashMap<>(); for (Map.Entry<String, SortOrder> entry : replaceIdRule(dictionary.getIdFieldName(entityClass)).entrySet()) { String dotSeparatedPath = entry.getKey(); SortOrder order = entry.getValue(); Path path = new Path(entityClass, dictionary, dotSeparatedPath); if (! isValidSortRulePath(path, dictionary)) { throw new InvalidValueException("Cannot sort across a to-many relationship: " + path.getFieldPath()); } returnMap.put(path, order); } return returnMap; }