auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void onModified(final ContentletPublishEvent<Persona> contentletPublishEvent) { try { final Optional<Versionable> versionable = APILocator.getVersionableAPI() .findPreviousVersion(contentletPublishEvent.getContentlet().getIdentifier()); <START> if (versionable.isPresent()) { <END> final Contentlet previousPersonaContent = APILocator.getContentletAPI().find (versionable.get().getInode(), APILocator.systemUser(), false); if (null != previousPersonaContent) { final String currentKeyTag = contentletPublishEvent.getContentlet().getKeyTag(); final String previousKeyTag = previousPersonaContent.getStringProperty(PersonaAPI.KEY_TAG_FIELD); if (UtilMethods.isSet(currentKeyTag) && UtilMethods.isSet(previousKeyTag) && !currentKeyTag.equals(previousKeyTag)) { APILocator.getMultiTreeAPI().updatePersonalization ( this.wrapPersonaScheme(previousKeyTag), this.wrapPersonaScheme(currentKeyTag)); } } } } catch (Exception e) { Logger.error(this, e.getMessage(), e); } }</code><technical_language>check if persona is live not? working version persona:ABC previous version (live) persona:DEF. Changing personalization of a working version basically remove personalization for live version</technical_language>

Target:
public void onModified(final ContentletPublishEvent<Persona> contentletPublishEvent) { try { if (null != contentletPublishEvent.getContentlet() && contentletPublishEvent.getContentlet().isLive()) { final Optional<Versionable> versionable = APILocator.getVersionableAPI() .findPreviousVersion(contentletPublishEvent.getContentlet().getIdentifier()); if (versionable.isPresent()) { final Contentlet previousPersonaContent = APILocator.getContentletAPI().find (versionable.get().getInode(), APILocator.systemUser(), false); if (null != previousPersonaContent) { final String currentKeyTag = contentletPublishEvent.getContentlet().getKeyTag(); final String previousKeyTag = previousPersonaContent.getStringProperty(PersonaAPI.KEY_TAG_FIELD); if (UtilMethods.isSet(currentKeyTag) && UtilMethods.isSet(previousKeyTag) && !currentKeyTag.equals(previousKeyTag)) { APILocator.getMultiTreeAPI().updatePersonalization( this.wrapPersonaScheme(previousKeyTag), this.wrapPersonaScheme(currentKeyTag)); } } } } } catch (Exception e) { Logger.error(this, e.getMessage(), e); } }
Source:
<code>public boolean onMediaButtonEvent(Intent mediaButtonIntent) { setCurrentControllerInfo(); boolean result = Callback.this.onMediaButtonEvent(mediaButtonIntent); clearCurrentControllerInfo(); <START> if (result) return true; else return super.onMediaButtonEvent(mediaButtonIntent); <END> }</code><technical_language>return result ? true : super.onMediaButtonEvent(mediaButtonIntent);</technical_language>

Target:
public boolean onMediaButtonEvent(Intent mediaButtonIntent) { setCurrentControllerInfo(); boolean result = Callback.this.onMediaButtonEvent(mediaButtonIntent); clearCurrentControllerInfo(); return result || super.onMediaButtonEvent(mediaButtonIntent); }
Source:
<code>public TargetReference build() { Objects.requireNonNull( method ); Objects.requireNonNull( typeFactory ); if ( targetName == null ) { return null; } String targetNameTrimmed = targetName.trim(); <START> if ( !targetName.equals( targetNameTrimmed ) && messager != null ) { <END> messager.printMessage( method.getExecutable(), annotationMirror, targetAnnotationValue, Message.PROPERTYMAPPING_WHITESPACE_TRIMMED, targetName, targetNameTrimmed ); } String[] segments = targetNameTrimmed.split( "\\." ); Parameter parameter = method.getMappingTargetParameter(); boolean foundEntryMatch; Type resultType = typeBasedOnMethod( method.getResultType() ); String[] targetPropertyNames = segments; List<PropertyEntry> entries = getTargetEntries( resultType, targetPropertyNames ); foundEntryMatch = (entries.size() == targetPropertyNames.length); if ( !foundEntryMatch && segments.length > 1 && matchesSourceOrTargetParameter( segments[0], parameter, isReversed ) ) { targetPropertyNames = Arrays.copyOfRange( segments, 1, segments.length ); entries = getTargetEntries( resultType, targetPropertyNames ); foundEntryMatch = (entries.size() == targetPropertyNames.length); } if ( !foundEntryMatch && errorMessage != null && !isReversed ) { errorMessage.report( ); } return new TargetReference( parameter, entries, foundEntryMatch ); }</code><technical_language>messager null. report</technical_language>

Target:
public TargetReference build() { Objects.requireNonNull( method ); Objects.requireNonNull( typeFactory ); Objects.requireNonNull( messager ); if ( targetName == null ) { return null; } String targetNameTrimmed = targetName.trim(); if ( !targetName.equals( targetNameTrimmed ) ) { messager.printMessage( method.getExecutable(), annotationMirror, targetAnnotationValue, Message.PROPERTYMAPPING_WHITESPACE_TRIMMED, targetName, targetNameTrimmed ); } String[] segments = targetNameTrimmed.split( "\\." ); Parameter parameter = method.getMappingTargetParameter(); boolean foundEntryMatch; Type resultType = typeBasedOnMethod( method.getResultType() ); String[] targetPropertyNames = segments; List<PropertyEntry> entries = getTargetEntries( resultType, targetPropertyNames ); foundEntryMatch = (entries.size() == targetPropertyNames.length); if ( !foundEntryMatch && segments.length > 1 && matchesSourceOrTargetParameter( segments[0], parameter, isReversed ) ) { targetPropertyNames = Arrays.copyOfRange( segments, 1, segments.length ); entries = getTargetEntries( resultType, targetPropertyNames ); foundEntryMatch = (entries.size() == targetPropertyNames.length); } if ( !foundEntryMatch && errorMessage != null && !isReversed ) { errorMessage.report( ); } return new TargetReference( parameter, entries, foundEntryMatch ); }
Source:
<code>public void testNewEpochZxidWithTxnlogOnly() throws Exception { long peerZxid; db.txnLog.add(createProposal(getZxid(1, 1))); db.txnLog.add(createProposal(getZxid(2, 1))); db.txnLog.add(createProposal(getZxid(2, 2))); db.txnLog.add(createProposal(getZxid(4, 1))); db.lastProcessedZxid = getZxid(6, 0); peerZxid = getZxid(3, 0); <START> assertTrue(learnerHandler.syncFollower(peerZxid, db, leader)); <END> reset(); peerZxid = getZxid(4, 0); assertTrue(learnerHandler.syncFollower(peerZxid, db, leader)); reset(); peerZxid = getZxid(5, 0); assertTrue(learnerHandler.syncFollower(peerZxid, db, leader)); reset(); peerZxid = getZxid(6, 0); assertFalse(learnerHandler.syncFollower(peerZxid, db, leader)); assertOpType(Leader.DIFF, getZxid(6, 0), getZxid(6, 0)); assertEquals(1, learnerHandler.getQueuedPackets().size()); reset(); }</code><technical_language>this test checking 3 times in a row. Do necessary do so</technical_language>

Target:
public void testNewEpochZxidWithTxnlogOnly() throws Exception { long peerZxid; db.txnLog.add(createProposal(getZxid(1, 1))); db.txnLog.add(createProposal(getZxid(2, 1))); db.txnLog.add(createProposal(getZxid(2, 2))); db.txnLog.add(createProposal(getZxid(4, 1))); db.lastProcessedZxid = getZxid(6, 0); peerZxid = getZxid(3, 0); assertFalse(learnerHandler.syncFollower(peerZxid, db, leader)); assertOpType(Leader.DIFF, getZxid(6, 0), getZxid(4, 1)); assertEquals(3, learnerHandler.getQueuedPackets().size()); queuedPacketMatches(new long[] { getZxid(4, 1)}); reset(); peerZxid = getZxid(4, 0); assertFalse(learnerHandler.syncFollower(peerZxid, db, leader)); assertOpType(Leader.DIFF, getZxid(6, 0), getZxid(4, 1)); assertEquals(3, learnerHandler.getQueuedPackets().size()); queuedPacketMatches(new long[] { getZxid(4, 1)}); reset(); peerZxid = getZxid(5, 0); assertFalse(learnerHandler.syncFollower(peerZxid, db, leader)); assertOpType(Leader.DIFF, getZxid(6, 0), getZxid(5, 0)); assertEquals(1, learnerHandler.getQueuedPackets().size()); reset(); peerZxid = getZxid(6, 0); assertFalse(learnerHandler.syncFollower(peerZxid, db, leader)); assertOpType(Leader.DIFF, getZxid(6, 0), getZxid(6, 0)); assertEquals(1, learnerHandler.getQueuedPackets().size()); reset(); }
Source:
<code>MkNotifications(final int quantity) { int identifier = 0; this.notifications = Collections .<Notification>nCopies( quantity, <START> new MkNotification(identifier += 1) <END> ); }</code><technical_language>@prondzyn I get quantity copies of new MkNotification(1), right? initialize this for loop</technical_language>

Target:
MkNotifications(final int quantity) { this.notifications = new ArrayList<Notification>(quantity); for (int index = 0; index < quantity; ++index) { this.notifications.add(index, new MkNotification(index)); } }
Source:
<code>public int getCardinality(FloatColumnSelector selector) { <START> return -1; <END> }</code><technical_language>pull this out a TopNColumnSelectorStrategy.CARDINALITY_UNKNOWN constant for clarity</technical_language>

Target:
public int getCardinality(FloatColumnSelector selector) { return TopNColumnSelectorStrategy.CARDINALITY_UNKNOWN; }
Source:
<code>private void renderOptimizeColumnSelection() { line("private ColumnSelection optimizeColumnSelection(ColumnSelection columns) {"); { line("if (columns.allColumnsSelected()) {"); { line("return allColumns;"); line("}"); } line("return columns;"); } line("}"); <START> } <END></code><technical_language>While code sense, I rendering code is structured. is more common: line("private ColumnSelection optimizeColumnSelection(ColumnSelection columns) {"); { line("if (columns.allColumnsSelected()) {"); { line("return allColumns;"); } line("}"); line("return columns;"); } line("}");</technical_language>

Target:
private void renderOptimizeColumnSelection() { line("private ColumnSelection optimizeColumnSelection(ColumnSelection columns) {"); { line("if (columns.allColumnsSelected()) {"); { line("return allColumns;"); } line("}"); line("return columns;"); } line("}"); }
Source:
<code>public void rejectsExecutionsIfUnderlyingExecutorRejects() throws InterruptedException, ExecutionException { MultiplexingCompletionService<String, Integer> boundedService = MultiplexingCompletionService.create( ImmutableMap.of(KEY_1, createBoundedExecutor(2), KEY_2, createBoundedExecutor(2))); Callable<Integer> sleepForFiveSeconds = getSleepCallable(5_000); <START> boundedService.submit(KEY_1, sleepForFiveSeconds); <END> boundedService.submit(KEY_2, sleepForFiveSeconds); boundedService.submit(KEY_1, sleepForFiveSeconds); boundedService.submit(KEY_2, getSleepCallable(2)); boundedService.submit(KEY_1, sleepForFiveSeconds); assertThat(boundedService.poll(1, TimeUnit.SECONDS).get()).isEqualTo(2); assertThat(boundedService.poll()).isNull(); assertThatThrownBy(() -> boundedService.submit(KEY_1, sleepForFiveSeconds)) .isInstanceOf(RejectedExecutionException.class); }</code><technical_language>do this executor? do need two? test noisy</technical_language>

Target:
public void rejectsExecutionsIfUnderlyingExecutorRejects() throws InterruptedException, ExecutionException { MultiplexingCompletionService<String, Integer> boundedService = MultiplexingCompletionService.create( ImmutableMap.of(KEY_1, createBoundedExecutor(1))); Callable<Integer> sleepForFiveSeconds = getSleepCallable(5_000); boundedService.submit(KEY_1, sleepForFiveSeconds); boundedService.submit(KEY_1, sleepForFiveSeconds); assertThat(boundedService.poll()).isNull(); assertThatThrownBy(() -> boundedService.submit(KEY_1, sleepForFiveSeconds)) .isInstanceOf(RejectedExecutionException.class); }
Source:
<code>NewRoamingGroupEntity(String name, String description, RoamingGroupType type) { this.name = name; this.description = description; this.type = type; <START> this.operatorIDs = Lists.newArrayList(); <END> }</code><technical_language>code ImmutableList.copyOf()</technical_language>

Target:
NewRoamingGroupEntity(String name, String description, RoamingGroupType type) { this.name = name; this.description = description; this.type = type; this.operatorIDs = ImmutableList.copyOf(Lists.newArrayList()); }
Source:
<code>public final void compareCommitsPatch() throws Exception { <START> final String patch = RtRepoCommitsITCase.repo().commits().patch( <END> BASE, HEAD ); MatcherAssert.assertThat( patch, Matchers.startsWith( "From 9b2e6efde94fabec5876dc481b38811e8b4e992f" ) ); MatcherAssert.assertThat( patch, Matchers.containsString( "Subject: [PATCH] Issue #430 RepoCommit interface was added" ) ); }</code><technical_language>Actually, I get commits exist in test repo</technical_language>

Target:
public final void compareCommitsPatch() throws Exception { final String patch = RtRepoCommitsITCase.repo().commits().patch( "5339b8e35b", "9b2e6efde9" ); MatcherAssert.assertThat( patch, Matchers.startsWith( "From 9b2e6efde94fabec5876dc481b38811e8b4e992f" ) ); MatcherAssert.assertThat( patch, Matchers.containsString( "Subject: [PATCH] Issue #430 RepoCommit interface was added" ) ); }
Source:
<code>public void onEditButtonClicked(final ClickEvent ignore) { <START> presenter.openEditModal();; <END> }</code><technical_language>Remove duplicated semicolon</technical_language>

Target:
public void onEditButtonClicked(final ClickEvent ignore) { presenter.openEditModal(); }
Source:
<code>private void importFlatGraph(final ElkNode elkgraph, final LGraph lgraph) { for (ElkNode child : elkgraph.getChildren()) { if (!child.getProperty(LayeredOptions.NO_LAYOUT)) { transformNode(child, lgraph); } } for (ElkEdge elkedge : elkgraph.getContainedEdges()) { ElkNode source = ElkGraphUtil.getSourceNode(elkedge); ElkNode target = ElkGraphUtil.getTargetNode(elkedge); boolean enableInsideSelfLoops = source.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE); boolean isToBeLaidOut = !elkedge.getProperty(LayeredOptions.NO_LAYOUT); boolean isInsideSelfLoop = enableInsideSelfLoops && elkedge.isSelfloop() && elkedge.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO); boolean connectsSiblings = source.getParent() == elkgraph && source.getParent() == target.getParent(); boolean connectsToGraph = (source.getParent() == elkgraph && target == elkgraph) ^ (target.getParent() == elkgraph && source == elkgraph); if (isToBeLaidOut && !isInsideSelfLoop && (connectsToGraph || connectsSiblings)) { transformEdge(elkedge, elkgraph, lgraph); } } if (elkgraph.getParent() != null) { for (ElkEdge elkedge : elkgraph.getParent().getContainedEdges()) { ElkNode source = ElkGraphUtil.getSourceNode(elkedge); if (source == elkgraph && elkedge.isSelfloop()) { boolean enableInsideSelfLoops = source.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE); <START> boolean isInsideSelfLoop = enableInsideSelfLoops && elkedge.isSelfloop() <END> && elkedge.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO); if (isInsideSelfLoop) { transformEdge(elkedge, elkgraph, lgraph); } } } } }</code><technical_language>edge is a loop (see line 239)</technical_language>

Target:
private void importFlatGraph(final ElkNode elkgraph, final LGraph lgraph) { for (ElkNode child : elkgraph.getChildren()) { if (!child.getProperty(LayeredOptions.NO_LAYOUT)) { transformNode(child, lgraph); } } for (ElkEdge elkedge : elkgraph.getContainedEdges()) { ElkNode source = ElkGraphUtil.getSourceNode(elkedge); ElkNode target = ElkGraphUtil.getTargetNode(elkedge); boolean enableInsideSelfLoops = source.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE); boolean isToBeLaidOut = !elkedge.getProperty(LayeredOptions.NO_LAYOUT); boolean isInsideSelfLoop = enableInsideSelfLoops && elkedge.isSelfloop() && elkedge.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO); boolean connectsSiblings = source.getParent() == elkgraph && source.getParent() == target.getParent(); boolean connectsToGraph = (source.getParent() == elkgraph && target == elkgraph) ^ (target.getParent() == elkgraph && source == elkgraph); if (isToBeLaidOut && !isInsideSelfLoop && (connectsToGraph || connectsSiblings)) { transformEdge(elkedge, elkgraph, lgraph); } } if (elkgraph.getParent() != null) { for (ElkEdge elkedge : elkgraph.getParent().getContainedEdges()) { ElkNode source = ElkGraphUtil.getSourceNode(elkedge); if (source == elkgraph && elkedge.isSelfloop()) { boolean isInsideSelfLoop = source.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE) && elkedge.getProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO); if (isInsideSelfLoop) { transformEdge(elkedge, elkgraph, lgraph); } } } } }
Source:
<code>public void testGetConnection() throws Exception { Subject subject = new Subject(true, ImmutableSet.<Principal>of(), <START> ImmutableSet.of("bugger"), ImmutableSet.of("PASSWORD")); <END> assertFalse(subject.equals(UserContext.get().getSubject())); adaptor.init(context); try (Connection connection = getConfigOptions().getConnection()) { assertEquals("http://localhost/", connection.getConnection().getURI()); assertTrue(subject.equals(UserContext.get().getSubject())); } assertFalse(subject.equals(UserContext.get().getSubject())); }</code><technical_language>undo this change</technical_language>

Target:
public void testGetConnection() throws Exception { Subject subject = new Subject(true, ImmutableSet.<Principal>of(), ImmutableSet.of("test"), ImmutableSet.of("PASSWORD")); assertFalse(subject.equals(UserContext.get().getSubject())); adaptor.init(context); try (Connection connection = getConfigOptions().getConnection()) { assertEquals("http://localhost/", connection.getConnection().getURI()); assertTrue(subject.equals(UserContext.get().getSubject())); } assertFalse(subject.equals(UserContext.get().getSubject())); }
Source:
<code>public List<Condition> getActiveConditions(Patient patient) { <START> System.out.println("near query in getActiveConditions in core"); <END> Query query = sessionFactory.getCurrentSession().createQuery( "from Condition c where c.patient.patientId = :patientId and c.voided = false and c.endDate is null order " + "by c.onsetDate desc"); query.setInteger("patientId", patient.getId()); return query.list(); }</code><technical_language>a good practice sysout. logs instead</technical_language>

Target:
public List<Condition> getActiveConditions(Patient patient) { Query query = sessionFactory.getCurrentSession().createQuery( "from Condition c where c.patient.patientId = :patientId and c.voided = false and c.endDate is null order " + "by c.onsetDate desc"); query.setInteger("patientId", patient.getId()); return query.list(); }
Source:
<code>private Segment parseSegment(Node n) throws TypeImportException { Segment segment = LibraryElementFactory.eINSTANCE.createSegment(); NamedNodeMap mapSegment = n.getAttributes(); CommonElementImporter.readNameCommentAttributes(segment, mapSegment); Node dx1 = mapSegment.getNamedItem(LibraryElementTags.DX1_ATTRIBUTE); if(dx1 != null){ String dx1String = dx1.getNodeValue(); double dx1double = 0.; <START> if ((null != dx1String) && dx1String.length() != 0) { <END> dx1double = CoordinateConverter.INSTANCE.convertFrom1499XML(dx1.getNodeValue()); } segment.setWidth(((int) dx1double)); } CommonElementImporter.getXandY(mapSegment, segment); Node type = mapSegment.getNamedItem(LibraryElementTags.TYPE_ATTRIBUTE); if(type != null){ PaletteEntry entry = palette.getTypeEntry(type.getNodeValue()); if (entry instanceof SegmentTypePaletteEntry) { segment.setPaletteEntry(entry); } } parseSegmentNodeChildren(segment, n.getChildNodes()); return segment; }</code><technical_language>this replicates check performed in convertFrom1499XML</technical_language>

Target:
private Segment parseSegment(Node n) throws TypeImportException { Segment segment = LibraryElementFactory.eINSTANCE.createSegment(); NamedNodeMap mapSegment = n.getAttributes(); CommonElementImporter.readNameCommentAttributes(segment, mapSegment); Node dx1 = mapSegment.getNamedItem(LibraryElementTags.DX1_ATTRIBUTE); if(dx1 != null){ segment.setWidth(CoordinateConverter.INSTANCE.convertFrom1499XML(dx1.getNodeValue())); } CommonElementImporter.getXandY(mapSegment, segment); Node type = mapSegment.getNamedItem(LibraryElementTags.TYPE_ATTRIBUTE); if(type != null){ PaletteEntry entry = palette.getTypeEntry(type.getNodeValue()); if (entry instanceof SegmentTypePaletteEntry) { segment.setPaletteEntry(entry); } } parseSegmentNodeChildren(segment, n.getChildNodes()); return segment; }
Source:
<code>protected String detect( InputStream inputStream, Metadata metadata ) { try { <START> IoUtil.closeQuietly(inputStream); <END> MediaType detectedMimeType = detector.detect(null, metadata); if (logger.isTraceEnabled()) { logger.trace("MIME type for '" + metadata.get(Metadata.RESOURCE_NAME_KEY) + "' ==> " + detectedMimeType); } return detectedMimeType.toString(); } catch (Exception e) { logger.debug(e, "Unable to extract mime-type"); return null; } }</code><technical_language>I move this a finally block in method</technical_language>

Target:
protected String detect( InputStream inputStream, Metadata metadata ) { try { MediaType detectedMimeType = detector.detect(null, metadata); if (logger.isTraceEnabled()) { logger.trace("MIME type for '" + metadata.get(Metadata.RESOURCE_NAME_KEY) + "' ==> " + detectedMimeType); } return detectedMimeType.toString(); } catch (Exception e) { logger.debug(e, "Unable to extract mime-type"); return null; } finally { IoUtil.closeQuietly(inputStream); } }
Source:
<code>public void doTestImport(StorageDomain storageDomain, Cluster cluster, boolean collapseSnapshots, boolean importAsNewEntity) throws Exception { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); setUriInfo(setUpActionExpectations(VdcActionType.ImportVm, ImportVmParameters.class, <START> new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "VdsGroupId", "CopyCollapse", "ImportAsNewEntity" }, <END> new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1], collapseSnapshots, importAsNewEntity })); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); if(collapseSnapshots){ VM vm = new VM(); vm.setSnapshots(new Snapshots()); vm.getSnapshots().setCollapseSnapshots(collapseSnapshots); action.setVm(vm); } action.setImportAsNewEntity(importAsNewEntity); verifyActionResponse(resource.doImport(action)); }</code><technical_language>name..</technical_language>

Target:
public void doTestImport(StorageDomain storageDomain, Cluster cluster, boolean collapseSnapshots, boolean importAsNewEntity) throws Exception { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); setUriInfo(setUpActionExpectations(VdcActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "VdsGroupId", "CopyCollapse", "ImportAsNewEntity" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1], collapseSnapshots, importAsNewEntity })); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); if(collapseSnapshots){ VM vm = new VM(); vm.setSnapshots(new Snapshots()); vm.getSnapshots().setCollapseSnapshots(collapseSnapshots); action.setVm(vm); } action.setClone(importAsNewEntity); verifyActionResponse(resource.doImport(action)); }
Source:
<code>public int getProjectProgress(int projectId) { String projectIdString = String.valueOf(projectId); SQLiteDatabase db = getReadableDatabase(); final String query = String.format("SELECT %s FROM %s WHERE %s=?", <START> ProjectContract.ProjectEntry.PROJECT_PROGRESS, ProjectContract.ProjectEntry.TABLE_PROJECT, ProjectContract.ProjectEntry._ID); <END> float progress = DatabaseUtils.longForQuery(db, query, new String[]{projectIdString}); db.close(); return Math.round(progress); }</code><technical_language>split arguments another line of length (and this line length issues), parameter line so: final String query = String.format( "SELECT %s %s %s=?", ProjectContract.ProjectEntry.PROJECT_PROGRESS, ProjectContract.ProjectEntry.TABLE_PROJECT, ProjectContract.ProjectEntry._ID );</technical_language>

Target:
public int getProjectProgress(int projectId) { String projectIdString = String.valueOf(projectId); SQLiteDatabase db = getReadableDatabase(); final String query = String.format("SELECT %s FROM %s WHERE %s=?", ProjectContract.ProjectEntry.PROJECT_PROGRESS, ProjectContract.ProjectEntry.TABLE_PROJECT, ProjectContract.ProjectEntry._ID ); float progress = DatabaseUtils.longForQuery(db, query, new String[]{projectIdString}); return Math.round(progress); }
Source:
<code>private void assignUnitToTemplate() { Unit unit = unitList.getSelectedValue(); currentScenario.removeUnit(unit.getId()); currentScenario.addUnit(unit.getId(), templateList.getSelectedValue().getForceName()); unit.setScenarioId(currentScenario.getId()); MekHQ.triggerEvent(new DeploymentChangedEvent(unit, currentScenario)); if (!unit.getTransportedUnits().isEmpty()) { <START> int optionChoice = JOptionPane.showConfirmDialog(null, <END> unit.getName() + " is a transport with units assigned to it. \n" + "Would you also like to deploy these units?", "Also deploy transported units?", JOptionPane.YES_NO_OPTION); if (optionChoice == JOptionPane.YES_OPTION) { for (UUID id : unit.getTransportedUnits()) { Unit cargo = unit.getCampaign().getUnit(id); if (cargo != null) { currentScenario.removeUnit(cargo.getId()); currentScenario.addUnit(cargo.getId(), templateList.getSelectedValue().getForceName()); cargo.setScenarioId(currentScenario.getId()); MekHQ.triggerEvent(new DeploymentChangedEvent(cargo, currentScenario)); } } } } refreshUnitList(); }</code><technical_language>I feel this exact dialog elsewhere. Good candidate for a worker function if identical</technical_language>

Target:
private void assignUnitToTemplate() { Unit unit = unitList.getSelectedValue(); currentScenario.removeUnit(unit.getId()); currentScenario.addUnit(unit.getId(), templateList.getSelectedValue().getForceName()); unit.setScenarioId(currentScenario.getId()); MekHQ.triggerEvent(new DeploymentChangedEvent(unit, currentScenario)); if (!unit.getTransportedUnits().isEmpty()) { deployTransportedUnitsDialog(unit); } refreshUnitList(); }
Source:
<code>public Matrix[] decompose(Matrix matrix, Factory factory) { if (matrix.rows() != matrix.columns()) { throw new IllegalArgumentException("Wrong matrix size: " + "rows != columns"); } Matrix l = factory.createMatrix(matrix.rows(), matrix.columns()); Matrix u = factory.createIdentityMatrix(matrix.rows()); <START> double s=0; <END> for (int j = 0; j < l.columns(); j++){ for (int i = j; i < l.rows(); i++){ s=0; for (int k = 0; k < j; k++){ s = s + l.get(i, k)*u.get(k, j); } l.set(i,j,matrix.get(i, j) - s); } for (int i = j; i < l.rows(); i++){ s=0; for (int k = 0; k < j; k++){ s = s + l.get(j, k)*u.get(k, i); } if (l.get(j, j) == 0) throw new IllegalArgumentException("Singular matrix!"); u.set(j,i,(matrix.get(j, i) - s)/l.get(j, j)); } } return new Matrix[] { l, u }; }</code><technical_language>Please, declare variable using</technical_language>

Target:
public Matrix[] decompose(Matrix matrix, Factory factory) { if (matrix.rows() != matrix.columns()) { throw new IllegalArgumentException("Wrong matrix size: " + "rows != columns"); } Matrix l = factory.createMatrix(matrix.rows(), matrix.columns()); Matrix u = factory.createIdentityMatrix(matrix.rows()); for (int j = 0; j < l.columns(); j++){ for (int i = j; i < l.rows(); i++){ double s = 0.0; for (int k = 0; k < j; k++){ s = s + l.get(i, k) * u.get(k, j); } l.set(i,j,matrix.get(i, j) - s); } for (int i = j; i < l.rows(); i++){ double s = 0.0; for (int k = 0; k < j; k++){ s = s + l.get(j, k) * u.get(k, i); } if (Math.abs(l.get(j, j)) < Matrices.EPS){ throw new IllegalArgumentException("Singular matrix!"); } u.set(j, i, (matrix.get(j, i) - s) / l.get(j, j)); } } return new Matrix[] { l, u }; }
Source:
<code>public Boolean getMakeRedundant() { if (makeRedundant != null) { return makeRedundant; } <START> return true; <END> }</code><technical_language>If pass anything, I false, continue normal restart instead of this blue-green deployment</technical_language>

Target:
public Boolean getMakeRedundant() { return makeRedundant; }
Source:
<code>public void loadAwardsFromStream(InputStream inputStream, String fileName){ AwardSet awardSet = null; try { JAXBContext jaxbContext = JAXBContext.newInstance(AwardSet.class, Award.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); awardSet = unmarshaller.unmarshal(MekHqXmlUtil.createSafeXmlSource(inputStream), AwardSet.class).getValue(); Map<String, Award> tempAwardMap = new HashMap<>(); <START> String currentSetName = fileName.replaceFirst("[.][^.]+$", ""); <END> for (Award award : awardSet.getAwards()){ award.setSet(currentSetName); tempAwardMap.put(award.getName(), award); } awardsMap.put(currentSetName, tempAwardMap); } catch (SAXException | ParserConfigurationException e) { MekHQ.getLogger().error(AwardsFactory.class, "loadAwards", e); } catch (JAXBException e) { MekHQ.getLogger().error(AwardsFactory.class, "loadAwards", "Error loading XML for awards", e); } }</code><technical_language>strip extension file name</technical_language>

Target:
public void loadAwardsFromStream(InputStream inputStream, String fileName){ AwardSet awardSet; try { JAXBContext jaxbContext = JAXBContext.newInstance(AwardSet.class, Award.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); awardSet = unmarshaller.unmarshal(MekHqXmlUtil.createSafeXmlSource(inputStream), AwardSet.class).getValue(); Map<String, Award> tempAwardMap = new HashMap<>(); String currentSetName = fileName.replaceFirst("[.][^.]+$", ""); int i = 0; for (Award award : awardSet.getAwards()){ award.setId(i); i++; award.setSet(currentSetName); tempAwardMap.put(award.getName(), award); } awardsMap.put(currentSetName, tempAwardMap); } catch (JAXBException e) { MekHQ.getLogger().error(AwardsFactory.class, "loadAwards", "Error loading XML for awards", e); } }
Source:
<code>private String getCollectionNameForAlias(NamedList<Object> response, String alias) { LinkedHashMap aliases = (LinkedHashMap) response.findRecursive("cluster", "aliases"); <START> Object collectionName = aliases.getOrDefault(alias, null); <END> if(collectionName != null) { return collectionName.toString(); } else { throw new RuntimeException("The alias " + alias + " does not match any collections in Solr"); } }</code><technical_language>Map::get return null if key found</technical_language>

Target:
private String getCollectionNameForAlias(NamedList<Object> response, String alias) { LinkedHashMap aliases = (LinkedHashMap) response.findRecursive("cluster", "aliases"); Object collectionName = aliases.get(alias); if(collectionName != null) { return collectionName.toString(); } else { throw new RuntimeException("The alias " + alias + " does not match any collections in Solr"); } }
Source:
<code>protected int getPatternMatchRule(String pattern, String string) { String start; try { start= string.substring(0, pattern.length()); } catch (StringIndexOutOfBoundsException e) { String message= "Error retrieving proposal text.\nDisplay string:\n" + string + "\nPattern:\n" + pattern; JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, message, e)); return -1; } if (start.equalsIgnoreCase(pattern)) { return SearchPattern.R_PREFIX_MATCH; } else if (isCamelCaseMatching() && CharOperation.camelCaseMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_CAMELCASE_MATCH; } else if (isSubstringMatching() && CharOperation.substringMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_SUBSTRING_MATCH; <START> } else if (CharOperation.subWordMatch(pattern.toCharArray(), string.toCharArray())) { <END> return SearchPattern.R_SUBWORD_MATCH; } else { return -1; } }</code><technical_language>Needs isSubwordMatching() check if is enabled similar isSubstringMatching()</technical_language>

Target:
protected int getPatternMatchRule(String pattern, String string) { String start; try { start= string.substring(0, pattern.length()); } catch (StringIndexOutOfBoundsException e) { String message= "Error retrieving proposal text.\nDisplay string:\n" + string + "\nPattern:\n" + pattern; JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, message, e)); return -1; } if (start.equalsIgnoreCase(pattern)) { return SearchPattern.R_PREFIX_MATCH; } else if (isCamelCaseMatching() && CharOperation.camelCaseMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_CAMELCASE_MATCH; } else if (isSubstringMatching() && CharOperation.substringMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_SUBSTRING_MATCH; } else if (isSubwordMatching() && CharOperation.subWordMatch(pattern.toCharArray(), string.toCharArray())) { return SearchPattern.R_SUBWORD_MATCH; } else { return -1; } }
Source:
<code>public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; case R.id.menu_clear_all_saved_pages: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.dialog_title_clear_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { app.getPersister(SavedPage.class).deleteAll(); <START> Utils.deleteRecursive(new File(SavedPage.getSavedPagesDir()), true); <END> } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); return true; default: throw new RuntimeException("Unknown menu item clicked!"); } }</code><technical_language>work, this UI thread, especially, get delete images well</technical_language>

Target:
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; case R.id.menu_clear_all_saved_pages: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.dialog_title_clear_saved_pages); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { app.getPersister(SavedPage.class).deleteAll(); (new SaneAsyncTask<Void>(SaneAsyncTask.SINGLE_THREAD) { @Override public Void performTask() throws Throwable { Utils.delete(new File(SavedPage.getSavedPagesDir()), true); return null; } }).execute(); } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); return true; default: throw new RuntimeException("Unknown menu item clicked!"); } }
Source:
<code>protected void initMatching() { <START> if (fMatches != null) { <END> fMatches.init(fTraces); } List<ITmfMatchEventDefinition> deflist = fMatchDefinitions.get(getMatchingType()); if (deflist == null) { return; } for (ITmfTrace trace : fTraces) { for (ITmfMatchEventDefinition def : deflist) { if (def.canMatchTrace(trace)) { fMatchMap.put(trace, def); break; } } } }</code><technical_language>Instead of fMatches potentially null, check constructor parameter is null? (and throw IllegalArgumentException if is)</technical_language>

Target:
protected void initMatching() { fMatches.init(fTraces); List<ITmfMatchEventDefinition> deflist = fMatchDefinitions.get(getMatchingType()); if (deflist == null) { return; } for (ITmfTrace trace : fTraces) { for (ITmfMatchEventDefinition def : deflist) { if (def.canMatchTrace(trace)) { fMatchMap.put(trace, def); break; } } } }
Source:
<code>private StreamStoreCellDeletion findCellsToPropagateDeletes( Map<GenericStreamIdentifier, StreamMetadata> streamIdentifierToMetadata) { ImmutableStreamStoreCellDeletion.Builder builder = ImmutableStreamStoreCellDeletion.builder(); for (Map.Entry<GenericStreamIdentifier, StreamMetadata> entry : streamIdentifierToMetadata.entrySet()) { GenericStreamIdentifier streamId = entry.getKey(); StreamMetadata streamMetadata = entry.getValue(); builder.addAllValueTableCellsToDelete(cellCreator.constructValueTableCellSet( <START> streamId, getNumberOfBlocksFromMetadata(entry.getValue()))); <END> builder.addMetadataTableCellsToDelete(cellCreator.constructMetadataTableCell(streamId)); builder.addHashTableCellsToDelete(cellCreator.constructHashTableCell(streamId, streamMetadata.getHash())); } return builder.build(); }</code><technical_language>nit: streamMetadata</technical_language>

Target:
private StreamStoreCellDeletion findCellsToPropagateDeletes( Map<GenericStreamIdentifier, StreamMetadata> streamIdentifierToMetadata) { ImmutableStreamStoreCellDeletion.Builder builder = ImmutableStreamStoreCellDeletion.builder(); for (Map.Entry<GenericStreamIdentifier, StreamMetadata> entry : streamIdentifierToMetadata.entrySet()) { GenericStreamIdentifier streamId = entry.getKey(); StreamMetadata streamMetadata = entry.getValue(); builder.addAllValueTableCellsToDelete(cellCreator.constructValueTableCellSet( streamId, StreamMetadatas.getNumberOfBlocksFromMetadata(streamMetadata))); builder.addMetadataTableCellsToDelete(cellCreator.constructMetadataTableCell(streamId)); builder.addHashTableCellsToDelete(cellCreator.constructHashTableCell(streamId, streamMetadata.getHash())); } return builder.build(); }
Source:
<code>public void testList() { dataCenters = dataCenterApi().list(); currentDataCenter = dataCenters.get(0); <START> assertNotNull(dataCenters); <END> assertFalse(dataCenters.isEmpty()); Assert.assertTrue(dataCenters.size() > 0); }</code><technical_language>Check this calling get</technical_language>

Target:
public void testList() { dataCenters = dataCenterApi().list(); assertNotNull(dataCenters); currentDataCenter = dataCenters.get(0); assertFalse(dataCenters.isEmpty()); Assert.assertTrue(dataCenters.size() > 0); }
Source:
<code>public Optional<URL> findFullText(BibEntry entry) throws IOException { Objects.requireNonNull(entry); Optional<DOI> doi = entry.getField(StandardField.DOI).flatMap(DOI::parse); if (!doi.isPresent()) { return Optional.empty(); } Optional<String> id = getId(doi.get().getDOI()); if (id.isPresent()) { String pdfRequestUrl = PDF_URL + id.get(); int code = Unirest.head(pdfRequestUrl).asJson().getStatus(); if (code == 200) { LOGGER.info("Fulltext PDF found @ APS."); try { return Optional.of(new URL(pdfRequestUrl)); } catch (MalformedURLException e) { <START> LOGGER.info("APS returned malformed URL, cannot find PDF."); <END> } } } return Optional.empty(); }</code><technical_language>This debug warn</technical_language>

Target:
public Optional<URL> findFullText(BibEntry entry) throws IOException { Objects.requireNonNull(entry); Optional<DOI> doi = entry.getField(StandardField.DOI).flatMap(DOI::parse); if (!doi.isPresent()) { return Optional.empty(); } Optional<String> id = getId(doi.get().getDOI()); if (id.isPresent()) { String pdfRequestUrl = PDF_URL + id.get(); int code = Unirest.head(pdfRequestUrl).asJson().getStatus(); if (code == 200) { LOGGER.info("Fulltext PDF found @ APS."); try { return Optional.of(new URL(pdfRequestUrl)); } catch (MalformedURLException e) { LOGGER.warn("APS returned malformed URL, cannot find PDF."); } } } return Optional.empty(); }
Source:
<code>public void addDynamicTemplateData(String key, Object value) { if (dynamicTemplateData == null) { dynamicTemplateData = new HashMap<String,Object>(); dynamicTemplateData.put(key, value); } else { dynamicTemplateData.put(key, value); <START> } <END> }</code><technical_language>Nitpick: save a couple lines of code if write this method like: if (dynamicTemplateData == null) { dynamicTemplateData = new HashMap<String,Object>(); } dynamicTemplateData.put(key, value);</technical_language>

Target:
public void addDynamicTemplateData(String key, Object value) { if (dynamicTemplateData == null) { dynamicTemplateData = new HashMap<String,Object>(); } dynamicTemplateData.put(key, value); }
Source:
<code>public static char getVersion(File jacocoExec) throws IOException { char version; try (DataInputStream in = new DataInputStream(new FileInputStream(jacocoExec))) { if (in.read() != ExecutionDataWriter.BLOCK_HEADER) { <START> throw new IOException("Invalid execution data file."); <END> } if (in.readChar() != ExecutionDataWriter.MAGIC_NUMBER) { throw new IOException("Invalid execution data file."); } version = in.readChar(); } return version; }</code><technical_language>give more details for debugging here</technical_language>

Target:
public static char getVersion(File jacocoExec) throws IOException { char version; try (DataInputStream in = new DataInputStream(new FileInputStream(jacocoExec))) { if (in.read() != ExecutionDataWriter.BLOCK_HEADER) { throw new IOException("Invalid execution data file. Unrecognized block header."); } if (in.readChar() != ExecutionDataWriter.MAGIC_NUMBER) { throw new IOException("Invalid execution data file. Unrecognized magic number."); } version = in.readChar(); } return version; }
Source:
<code>@Test public void emptyAdapters() throws Exception { try { Moshi moshi = new Moshi.Builder() .add(new EmptyJsonAdapter()).build(); <START> } catch (IllegalArgumentException expected){ <END> assertThat(expected.getMessage()).contains( "Expected at least one @ToJson or @FromJson method on", "EmptyJsonAdapter"); } }</code><technical_language>needs a fail() call</technical_language>

Target:
@Test public void emptyAdapters() throws Exception { Moshi.Builder builder = new Moshi.Builder(); try { builder.add(new EmptyJsonAdapter()).build(); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage( "Expected at least one @ToJson or @FromJson method on " + "com.squareup.moshi.AdapterMethodsTest$EmptyJsonAdapter"); } }
Source:
<code>public Construct exec(Target t, Env env, Construct... args) throws CancelCommandException, ConfigRuntimeException { if(args.length < 1){ <START> throw new ConfigRuntimeException("You must send at least 1 arguments to msg", ExceptionType.InsufficientArgumentsException, t); <END> } StringBuilder b = new StringBuilder(); for(int i = 0; i < args.length; i++){ b.append(args[i].val()); } Static.SendMessage(env.GetCommandSender(), b.toString(), t); return new CVoid(t); }</code><technical_language>Grammar Nazi: "You send 1 argument msg" s/arguments/argument</technical_language>

Target:
public Construct exec(Target t, Env env, Construct... args) throws CancelCommandException, ConfigRuntimeException { StringBuilder b = new StringBuilder(); for(int i = 0; i < args.length; i++){ b.append(args[i].val()); } Static.SendMessage(env.GetCommandSender(), b.toString(), t); return new CVoid(t); }
Source:
<code>public String toString() { return new StringBuilder("JavaTypeDefinition [clazz=").append(clazz) .append(", definitionType=").append(getDefinitionType()) <START> .append(", genericArgs=").append(genericArgs.stream().map(new Function<JavaTypeDefinition, String>() { <END> @Override public String apply(final JavaTypeDefinition jtd) { return jtd.shallowString(); } }).collect(Collectors.toList())) .append(", isGeneric=").append(isGeneric) .append("]\n").toString(); }</code><technical_language>stream() is a java8 feature, it? java7... wondering, ci build fail..</technical_language>

Target:
public String toString() { final StringBuilder sb = new StringBuilder("JavaTypeDefinition [clazz=").append(clazz) .append(", definitionType=").append(getDefinitionType()) .append(", genericArgs=["); for (final JavaTypeDefinition jtd : genericArgs) { sb.append(jtd.shallowString()).append(", "); } return sb.replace(sb.length() - 3, sb.length() - 1, "]") .append(", isGeneric=").append(isGeneric) .append("]\n").toString(); }
Source:
<code>public void testComponents() throws Exception { <START> final Jar jar = new Jar("jar", "testresources/gogoEntry/source.jar"); <END> final Processor p = new Processor(); final GogoPlugin e = new GogoPlugin(); final Map<String, Object> result = new HashMap<>(); e.setReporter(p); result.put(e.getProperties() .get(ReportEntryPlugin.ENTRY_NAME_PROPERTY), e.extract(jar, Locale.forLanguageTag("und"))); assertTrue(p.isOk()); final ByteArrayOutputStream s = new ByteArrayOutputStream(); new JsonReportSerializerPlugin().serialize(result, s); System.out.println(new String(s.toByteArray())); final StringBuffer ee = new StringBuffer(); for (final String l : Files.readAllLines(Paths.get("testresources/gogoEntry/result.json"), StandardCharsets.UTF_8)) { ee.append(l + "\n"); } ee.deleteCharAt(ee.length() - 1); assertEquals(ee.toString(), new String(s.toByteArray())); }</code><technical_language>close jar object. Put in a try-with-resource</technical_language>

Target:
public void testComponents() throws Exception { try (final Jar jar = new Jar("jar", "testresources/gogoEntry/source.jar"); final Processor p = new Processor()) { final GogoPlugin e = new GogoPlugin(); final Map<String, Object> result = new HashMap<>(); e.setReporter(p); result.put(e.getProperties() .get(ReportEntryPlugin.ENTRY_NAME_PROPERTY), e.extract(jar, Locale.forLanguageTag("und"))); assertTrue(p.isOk()); final ByteArrayOutputStream s = new ByteArrayOutputStream(); new JsonReportSerializerPlugin().serialize(result, s); System.out.println(new String(s.toByteArray())); final StringBuffer ee = new StringBuffer(); for (final String l : Files.readAllLines(Paths.get("testresources/gogoEntry/result.json"), StandardCharsets.UTF_8)) { ee.append(l + "\n"); } ee.deleteCharAt(ee.length() - 1); assertEquals(ee.toString(), new String(s.toByteArray())); } }
Source:
<code>private void checkPostConstructContainsParameter(final Class<?> clazz) throws ControllerValidationException { <START> List<Method> methods = ReflectionHelper.getInheritedDeclaredMethods(clazz); <END> if(null != methods) { for (Method method : methods) { if (method.isAnnotationPresent(PostConstruct.class)) { if (method.getParameterTypes().length > 0) { throw new ControllerValidationException("PostConstruct method " + method.getName() + " should not contain parameter in Controller " + clazz.getName()); } } } } }</code><technical_language>Assert.requeiesNotNull(clazz); ReflectionHelper.getInheritedDeclaredMethods(clazz).filter(m -> method.isAnnotationPresent(PostConstruct.class)).filter(m -> method.getParameterTypes().length > 0).findAny()..</technical_language>

Target:
private void checkPostConstructContainsParameter(final Class<?> clazz) throws ControllerValidationException { Assert.requireNonNull(clazz, "clazz"); final ControllerValidationException controllerValidationException = ReflectionHelper.getInheritedDeclaredMethods(clazz).stream(). filter(method -> method.isAnnotationPresent(PostConstruct.class)). filter(method -> method.getParameterTypes().length > 0). findAny().map(method ->new ControllerValidationException("PostConstruct method " + method.getName() + " should not contain parameter in Controller " + ControllerUtils.getControllerName(clazz))). orElse(null); if(controllerValidationException != null){ throw controllerValidationException; } }
Source:
<code>public static Field saveField(Field oldField) throws DotHibernateException { if (oldField.getFieldType().equals("host or folder") || oldField.getFieldType().equals("line_divider") || oldField.getFieldType().equals("tab_divider") || oldField.getFieldType().equals("categories_tab") || oldField.getFieldType().equals("permissions_tab") || oldField.getFieldType().equals( "relationships_tab") || oldField.getFieldType().equals("category") || oldField.getFieldType().equals("tag") ) { oldField.setFieldContentlet(DataTypes.SYSTEM.toString()); } <START> if(oldField.getFieldType().equals(Field.FieldType.HOST_OR_FOLDER.toString()) || oldField.getFieldType().equals(Field.FieldType.TAG.toString())){ <END> oldField.setIndexed(true); } com.dotcms.contenttype.model.field.Field field = new LegacyFieldTransformer(oldField).from(); try { return new LegacyFieldTransformer( APILocator.getContentTypeFieldAPI().save(field, APILocator.systemUser()) ).asOldField(); } catch (DotDataException | DotSecurityException e) { throw new DotHibernateException(e.getMessage(),e); } }</code><technical_language>This is good - FieldType is Enum do if(oldField.getFieldType() ==FieldType.HOST_OR_FOLDER){ }</technical_language>

Target:
public static Field saveField(Field oldField) throws DotHibernateException { if (oldField.getFieldType().equals("host or folder") || oldField.getFieldType().equals("line_divider") || oldField.getFieldType().equals("tab_divider") || oldField.getFieldType().equals("categories_tab") || oldField.getFieldType().equals("permissions_tab") || oldField.getFieldType().equals( "relationships_tab") || oldField.getFieldType().equals("category") || oldField.getFieldType().equals("tag") ) { oldField.setFieldContentlet(DataTypes.SYSTEM.toString()); } if(Field.FieldType.HOST_OR_FOLDER.toString().equals(oldField.getFieldType()) || Field.FieldType.TAG.toString().equals(oldField.getFieldType())){ oldField.setIndexed(true); } com.dotcms.contenttype.model.field.Field field = new LegacyFieldTransformer(oldField).from(); try { return new LegacyFieldTransformer( APILocator.getContentTypeFieldAPI().save(field, APILocator.systemUser()) ).asOldField(); } catch (DotDataException | DotSecurityException e) { throw new DotHibernateException(e.getMessage(),e); } }