auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testInvalidNumber() { SearchContext context = new SearchContext(); List<Condition> conditions = new ArrayList<>(); Condition cond = new Condition(); cond.setKey("batteryLevel"); cond.setOperator("="); cond.setValue("bbb"); cond.setState(Condition.State.OR); conditions.add(cond); context.setConditions(conditions); SearchManagerService service = new SearchManagerServiceImpl(); try { service.search(context); } catch (SearchMgtException e) { <START> String expectedException = e.getCause().getClass().getName(); <END> Assert.assertTrue(expectedException.contains("InvalidOperatorException")); } }</code><technical_language>Please throwback if unexpected exceptions encountered</technical_language>

Target:
public void testInvalidNumber() throws SearchMgtException { SearchContext context = new SearchContext(); List<Condition> conditions = new ArrayList<>(); Condition cond = new Condition(); cond.setKey("batteryLevel"); cond.setOperator("="); cond.setValue("bbb"); cond.setState(Condition.State.OR); conditions.add(cond); context.setConditions(conditions); SearchManagerService service = new SearchManagerServiceImpl(); try { service.search(context); } catch (SearchMgtException e) { if (!(e.getCause() instanceof InvalidOperatorException)) { throw e; } } }
Source:
<code>public final int getAdapterPosition() { return <START> getAdapterPositionInRecyclerView(); <END> }</code><technical_language>note discussion: default local adapter position</technical_language>

Target:
public final int getAdapterPosition() { return getAbsoluteAdapterPosition(); }
Source:
<code>public static TenantId of(String value) { <START> checkNotEmptyOrBlank(value); <END> return TenantId.newBuilder() .setValue(value) .build(); }</code><technical_language>"Tenant ID empty blank."</technical_language>

Target:
public static TenantId of(String value) { checkNotEmptyOrBlank(value, "A tenant ID cannot be empty or blank."); return TenantId.newBuilder() .setValue(value) .build(); }
Source:
<code>public int hashCode() { int result = cacheLoaderFactory != null ? cacheLoaderFactory.hashCode() : 0; result = 31 * result + listenerConfigurations.hashCode(); result = 31 * result + keyType.hashCode(); result = 31 * result + valueType.hashCode(); result = 31 * result + (cacheWriterFactory != null ? cacheWriterFactory.hashCode() : 0); result = 31 * result + (expiryPolicyFactory != null ? expiryPolicyFactory.hashCode() : 0); result = 31 * result + (isReadThrough ? 1 : 0); result = 31 * result + (isWriteThrough ? 1 : 0); result = 31 * result + (isStatisticsEnabled ? 1 : 0); result = 31 * result + (isStoreByValue ? 1 : 0); result = 31 * result + (isManagementEnabled ? 1 : 0); <START> result = 31 * result + (hotRestartConfig != null ? hotRestartConfig.hashCode() : 0); <END> result = 31 * result + (eventJournalConfig != null ? eventJournalConfig.hashCode() : 0); return result; }</code><technical_language>minor: I hotRestartConfig eventJournalConfig null</technical_language>

Target:
public int hashCode() { int result = cacheLoaderFactory != null ? cacheLoaderFactory.hashCode() : 0; result = 31 * result + listenerConfigurations.hashCode(); result = 31 * result + keyType.hashCode(); result = 31 * result + valueType.hashCode(); result = 31 * result + (cacheWriterFactory != null ? cacheWriterFactory.hashCode() : 0); result = 31 * result + (expiryPolicyFactory != null ? expiryPolicyFactory.hashCode() : 0); result = 31 * result + (isReadThrough ? 1 : 0); result = 31 * result + (isWriteThrough ? 1 : 0); result = 31 * result + (isStatisticsEnabled ? 1 : 0); result = 31 * result + (isStoreByValue ? 1 : 0); result = 31 * result + (isManagementEnabled ? 1 : 0); result = 31 * result + hotRestartConfig.hashCode(); result = 31 * result + eventJournalConfig.hashCode(); return result; }
Source:
<code>public DroolsAbstractPMMLTest() { super(); <START> Properties props = System.getProperties(); props.setProperty("drools.dump.dir", "/home/gcardosi/NotBackedUp/old_pmml_dump_dir"); <END> }</code><technical_language>removed moved a path :)</technical_language>

Target:
public DroolsAbstractPMMLTest() { super(); }
Source:
<code>public void setup(Context.OperatorContext context) { <START> updatedKeyStorage.getStore().setup(context); <END> updatedKeyStorage.setup(context); super.setup(context); }</code><technical_language>setup of updatedKeyStorage is needed if fireOnlyUpdatedPanes is false</technical_language>

Target:
public void setup(Context.OperatorContext context) { if (useUpdatedKeyStorage()) { updatedKeyStorage.getStore().setup(context); updatedKeyStorage.setup(context); } super.setup(context); }
Source:
<code>public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); for (Ord<RelNode> ord : Ord.zip(inputs)) { pw.input("input#" + ord.i, ord.e); } pw.item("invocation", rexCall) .item("rowType", rowType); if (elementType != null) { pw.item("elementType", elementType); } if (columnMappings != null) { <START> pw.item("columnMappings", columnMappings); <END> } return pw; }</code><technical_language>bring some advantages</technical_language>

Target:
public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); for (Ord<RelNode> ord : Ord.zip(inputs)) { pw.input("input#" + ord.i, ord.e); } pw.item("invocation", rexCall) .item("rowType", rowType); if (elementType != null) { pw.item("elementType", elementType); } return pw; }
Source:
<code>public void value(@NonNull File file) throws IOException { super.flush(); beforeValue(false); Reader input = null; try { FileInputStream fis = new FileInputStream(file); <START> input = new BufferedReader(new InputStreamReader(fis, "UTF-8")); <END> IOUtils.copy(input, out); } finally { IOUtils.closeQuietly(input); } out.flush(); }</code><technical_language>do of objects need closing</technical_language>

Target:
public void value(@NonNull File file) throws IOException { if (file == null || file.length() <= 0) { return; } super.flush(); beforeValue(false); Reader input = null; try { FileInputStream fis = new FileInputStream(file); input = new BufferedReader(new InputStreamReader(fis, "UTF-8")); IOUtils.copy(input, out); } finally { IOUtils.closeQuietly(input); } out.flush(); }
Source:
<code>public static void setUpBlockingChecks() { <START> new MappingJackson2HttpMessageConverter().canRead( <END> new ParameterizedTypeReference<Map<String, Object>>() { }.getType(), null, null); BlockHound.install(); }</code><technical_language>minimum this simplified Map.class.getPackage();</technical_language>

Target:
public static void setUpBlockingChecks() { Class.class.getPackage(); BlockHound.install(); }
Source:
<code>public WysiwygEditorPage() { final Form<Void> form = new Form<Void>("form"); add(form.setOutputMarkupId(true)); DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbar"); final WysiwygEditor editor = new WysiwygEditor("wysiwyg", new PropertyModel<String>(this, "text"), toolbar); form.add(toolbar, editor); final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback"); form.add(feedback); add(new AjaxButton("display", form) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> _form) { String html = editor.getModelObject(); if (html != null) { _form.info(html); } target.add(feedback); } } <START> , new WebMarkupContainer("disable").setMarkupId("disable-btn").add(new JQueryBehavior("#disable-btn", "button") <END> , new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { target.add(form.setEnabled(!form.isEnabled())); } }) ); }</code><technical_language>If intention jQuery UI button: - Button#ButtonBehavior. - (if want behavior), need JQuery**UI**Behavior</technical_language>

Target:
public WysiwygEditorPage() { final Form<Void> form = new Form<Void>("form"); add(form.setOutputMarkupId(true)); DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbar"); final WysiwygEditor editor = new WysiwygEditor("wysiwyg", new PropertyModel<String>(this, "text"), toolbar); form.add(toolbar, editor); final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback"); form.add(feedback); add(new AjaxButton("display", form) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> _form) { String html = editor.getModelObject(); if (html != null) { _form.info(html); } target.add(feedback); } } , new WebMarkupContainer("disable").setMarkupId("disable-btn").add(new ButtonBehavior("#disable-btn") , new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { target.add(form.setEnabled(!form.isEnabled())); } }) ); }
Source:
<code>public String id() { <START> return getString("id"); <END> }</code><technical_language>add getId() mark id() deprecated</technical_language>

Target:
public String id() { return getId(); }
Source:
<code>public void testSelectionNodeAndEdges() { diagram.addNode(aClassNode, new Point2D.Double(5, 5)); diagram.addNode(aInterfaceNode, new Point2D.Double(44, 44)); diagram.addNode(aPackageNode, new Point2D.Double(87, 87)); diagram.addNode(aNoteNode, new Point2D.Double(134, 132)); diagram.addEdge(aggrEdge, new Point2D.Double(8, 10), new Point2D.Double(45, 48)); diagram.addEdge(assoEdge, new Point2D.Double(47, 49), new Point2D.Double(9, 17)); diagram.addEdge(depeEdge, new Point2D.Double(90, 93), new Point2D.Double(44, 49)); <START> <END> SelectionList aList = new SelectionList(); aList.add(aClassNode); aList.add(aggrEdge); aList.add(aInterfaceNode); Rectangle2D edge1_old_bonds = aggrEdge.getBounds(); for(GraphElement element: aList) { if(element instanceof Node) { ((Node) element).translate(10, 10); } } assertTrue(15 == aClassNode.getBounds().getX()); assertTrue(15 == aClassNode.getBounds().getY()); assertTrue(54 == aInterfaceNode.getBounds().getX()); assertTrue(54 == aInterfaceNode.getBounds().getY()); assertFalse(edge1_old_bonds.getY() == aggrEdge.getBounds().getY()); assertTrue(aClassNode == aggrEdge.getStart()); assertTrue(aInterfaceNode == aggrEdge.getEnd()); }</code><technical_language>is necessary create a new selection list? this done in setup method. Plus, variable name shadows field name - avoided</technical_language>

Target:
public void testSelectionNodeAndEdges() { aDiagram.addNode(aClassNode, new Point2D.Double(5, 5)); aDiagram.addNode(aInterfaceNode, new Point2D.Double(44, 44)); aDiagram.addNode(aPackageNode, new Point2D.Double(87, 87)); aDiagram.addNode(aNoteNode, new Point2D.Double(134, 132)); aDiagram.addEdge(aAggregationEdge, new Point2D.Double(8, 10), new Point2D.Double(45, 48)); aDiagram.addEdge(aAssociationEdge, new Point2D.Double(47, 49), new Point2D.Double(9, 17)); aDiagram.addEdge(aDependencyEdge, new Point2D.Double(90, 93), new Point2D.Double(44, 49)); aList.add(aClassNode); aList.add(aAggregationEdge); aList.add(aInterfaceNode); Rectangle2D aggregationEdgeBounds = aAggregationEdge.getBounds(); for(GraphElement element: aList) { if(element instanceof Node) { ((Node) element).translate(10, 10); } } assertEquals(new Rectangle2D.Double(15, 15, 100, 60), aClassNode.getBounds()); assertEquals(new Rectangle2D.Double(54, 54, 100, 60), aInterfaceNode.getBounds()); assertFalse(aggregationEdgeBounds == aAggregationEdge.getBounds()); assertTrue(aClassNode == aAggregationEdge.getStart()); assertTrue(aInterfaceNode == aAggregationEdge.getEnd()); }
Source:
<code>public void createDatabaseWithUsers() { final String dbName = "testDB-" + UUID.randomUUID().toString(); final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions() .name(dbName) .users(Collections.singletonList(new DatabaseUsersOptions() .active(true) .username("testUser") .passwd("testPasswd") )) ); assertThat(resultCreate, is(true)); DatabaseEntity info = arangoDB.db(dbName).getInfo(); assertThat(info.getName(), is(dbName)); assertThat(arangoDB.getUsers().stream().anyMatch(it -> it.getUser().equals("testUser")), is(true)); ArangoDB arangoDBTestUser = new ArangoDB.Builder() .user("testUser") .password("testPasswd") <START> .build(); <END> ArangoCollection collection = arangoDBTestUser.db(dbName).collection("col-" + UUID.randomUUID().toString()); collection.create(); arangoDBTestUser.shutdown(); final Boolean resultDelete = arangoDB.db(dbName).drop(); assertThat(resultDelete, is(true)); }</code><technical_language>include extra in test well</technical_language>

Target:
public void createDatabaseWithUsers() { final String dbName = "testDB-" + UUID.randomUUID().toString(); final Map<String, Object> extra = Collections.singletonMap("key", "value"); final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions() .name(dbName) .users(Collections.singletonList(new DatabaseUsersOptions() .active(true) .username("testUser") .passwd("testPasswd") .extra(extra) )) ); assertThat(resultCreate, is(true)); DatabaseEntity info = arangoDB.db(dbName).getInfo(); assertThat(info.getName(), is(dbName)); Optional<UserEntity> retrievedUserOptional = arangoDB.getUsers().stream() .filter(it -> it.getUser().equals("testUser")) .findFirst(); assertThat(retrievedUserOptional.isPresent(), is(true)); UserEntity retrievedUser = retrievedUserOptional.get(); assertThat(retrievedUser.getActive(), is(true)); assertThat(retrievedUser.getExtra(), is(extra)); ArangoDB arangoDBTestUser = new ArangoDB.Builder() .user("testUser") .password("testPasswd") .build(); ArangoCollection collection = arangoDBTestUser.db(dbName).collection("col-" + UUID.randomUUID().toString()); collection.create(); arangoDBTestUser.shutdown(); final Boolean resultDelete = arangoDB.db(dbName).drop(); assertThat(resultDelete, is(true)); }
Source:
<code>private List<MotechUser> prepareMotechUsersOne() { List<MotechUser> users = new ArrayList<>(); <START> Calendar date = Calendar.getInstance(); <END> MotechUser user = new MotechUser(); user.setUserName("fooUsernameOne"); user.setEmail("foouserone@foodomain.com"); date.add(Calendar.DAY_OF_YEAR, -14); user.setLastPasswordChange(new DateTime(date.getTime())); users.add(user); user = new MotechUser(); user.setUserName("fooUsernameTwo"); user.setEmail("foousertwo@foodomain.com"); date.add(Calendar.DAY_OF_YEAR, -1); user.setLastPasswordChange(new DateTime(date.getTime())); users.add(user); return users; }</code><technical_language>calendars, plusDasy() Joda</technical_language>

Target:
private List<MotechUser> prepareMotechUsersOne() { List<MotechUser> users = new ArrayList<>(); DateTime date = DateUtil.now().minusDays(14); MotechUser user = new MotechUser(); user.setUserName("fooUsernameOne"); user.setEmail("foouserone@foodomain.com"); user.setLastPasswordChange(date); users.add(user); user = new MotechUser(); user.setUserName("fooUsernameTwo"); user.setEmail("foousertwo@foodomain.com"); user.setLastPasswordChange(date.minusDays(1)); users.add(user); user = new MotechUser(); user.setUserName("fooUsernameThree"); user.setEmail("foouserthree@foodomain.com"); user.setLastPasswordChange(date.minusDays(1)); users.add(user); user = new MotechUser(); user.setUserName("fooUsernameFour"); user.setEmail("foouserfour@foodomain.com"); user.setLastPasswordChange(date.minusDays(2)); users.add(user); return users; }
Source:
<code>public void setInstallState(@Nonnull InstallState newState) { InstallState prior = installState; installState = newState; LOGGER.info("setInstallState (Previous:" + prior + ", New: " + installState + ")"); if (!newState.equals(prior)) { newState.initializeState(); getSetupWizard().onInstallStateUpdate(newState); } <START> saveQuietly(); <END> }</code><technical_language>Is safe save entire Jenkins instance current state. IIUC fully initialized state</technical_language>

Target:
public void setInstallState(@Nonnull InstallState newState) { InstallState prior = installState; installState = newState; LOGGER.log(Main.isDevelopmentMode ? Level.INFO : Level.FINE, "Install state transitioning from: {0} to : {1}", new Object[] { prior, installState }); if (!newState.equals(prior)) { getSetupWizard().onInstallStateUpdate(newState); newState.initializeState(); } saveQuietly(); }
Source:
<code>public static ColumnMapperFactory factory() { return (type, config) -> { Class<?> rawType = getErasedType(type); if (rawType == Option.class) { <START> return Optional.of(VavrOptionMapper.of(type)); <END> } return Optional.empty(); }; }</code><technical_language>I this lambda unwrap Option<T> generic type instead of map(), of(type) receives element type T instead of Option<T>. rename of() method ofElement() remove ambiguity? side benefit of findGenericParameter(...).orElseThrow(...) instead of in map() is this code executes _before_ database statement is executed</technical_language>

Target:
static ColumnMapperFactory factory() { return (type, config) -> { Class<?> rawType = getErasedType(type); if (rawType == Option.class) { final Type nestedType = GenericTypes.findGenericParameter(type, Option.class) .orElseThrow(() -> new NoSuchMapperException("No mapper for raw Option type")); return Optional.of(new VavrOptionMapper<>(nestedType)); } return Optional.empty(); }; }
Source:
<code>private void maybePersistOldState(Map<String, String> oldState) { if (backupDirPath != null) { try { if (backupPrefixAndPath == null) { <START> backupPrefixAndPath = reserveBackupFile(); <END> } writeBackup(backupPrefixAndPath.getSecond(), oldState); } catch (Exception e) { logger.error("Could not write previous state backup file", e); accountServiceMetrics.backupErrorCount.inc(); } } }</code><technical_language>minor: do this in constructor</technical_language>

Target:
private void maybePersistOldState(Map<String, String> oldState) { if (backupPrefixAndPath != null) { try { writeBackup(backupPrefixAndPath.getSecond(), oldState); } catch (Exception e) { logger.error("Could not write previous state backup file", e); accountServiceMetrics.backupErrorCount.inc(); } } }
Source:
<code>private void runIngestJob(List<Content> datasources, IngestModuleFactory factory) { IngestModuleIngestJobSettings settings = factory.getDefaultIngestJobSettings(); IngestModuleTemplate template = new IngestModuleTemplate(factory, settings); template.setEnabled(true); ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(template); IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); try { List<IngestModuleError> errs = IngestJobRunner.runIngestJob(datasources, ingestJobSettings); <START> assertEquals(0, errs.size()); <END> } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } }</code><technical_language>assertEquals includes a message argument log a failure reason instead of exceptions stack trace</technical_language>

Target:
private void runIngestJob(List<Content> datasources, IngestModuleFactory factory) { IngestModuleIngestJobSettings settings = factory.getDefaultIngestJobSettings(); IngestModuleTemplate template = new IngestModuleTemplate(factory, settings); template.setEnabled(true); ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(template); IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); try { List<IngestModuleError> ingestModuleErrorsList = IngestJobRunner.runIngestJob(datasources, ingestJobSettings); String errorMessage = String.format("The ingest job runner produced %d error messages.", ingestModuleErrorsList.size()); assertEquals(errorMessage, 0, ingestModuleErrorsList.size()); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } }
Source:
<code>public static String getVersion(){ try { return CommCareApplication._().getCurrentVersionString(); } catch(NullPointerException e){ <START> return "Version not set."; <END> } }</code><technical_language>convinced getCurrentVersionString() throws a NullPointerException</technical_language>

Target:
public static String getVersion(){ try { return CommCareApplication._().getCurrentVersionString(); } catch(Exception e){ return "Version not set."; } }
Source:
<code>private static ByteBuffer toByteArray(InputStream in) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) != -1) { os.write(buffer, 0, len); } <START> <END> return ByteBuffer.wrap(os.toByteArray()); }</code><technical_language>this return Flux.error instead of throwing</technical_language>

Target:
private static ByteBuffer toByteArray(InputStream in) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) != -1) { os.write(buffer, 0, len); } return ByteBuffer.wrap(os.toByteArray()); } catch (IOException e) { throw LOGGER.logExceptionAsError(new RuntimeException(e)); } }
Source:
<code>public void onMapReady(@NonNull final MapboxMap mapboxMap) { mapboxMap.setStyle(Style.LIGHT, new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { attributionView = mapView.findViewById(R.id.attributionView); findViewById(R.id.switch_attribution_color_fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (index == attributionColors.length - 1) { <START> <END> mapboxMap.setStyle(Style.LIGHT); index = 0; } if (index == 2) { mapboxMap.setStyle(Style.DARK); } if (index == 4) { mapboxMap.setStyle(new Style.Builder().fromUri("mapbox://styles/appsatmapboxcom/ck0cyq1lt0bbo1cmwkpf2w7g9")); } attributionView.setColorFilter(attributionColors[index]); index++; } }); } }); }</code><technical_language>Remove empty line</technical_language>

Target:
public void onMapReady(@NonNull final MapboxMap mapboxMap) { mapboxMap.setStyle(Style.LIGHT, new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) { attributionView = mapView.findViewById(R.id.attributionView); findViewById(R.id.switch_attribution_color_fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (index == attributionColors.length - 1) { mapboxMap.setStyle(Style.LIGHT); index = 0; } if (index == 2) { mapboxMap.setStyle(Style.DARK); } if (index == 4) { mapboxMap.setStyle(new Style.Builder() .fromUri(CUSTOM_GREEN_MONOCHROME_STYLE_URI)); } attributionView.setColorFilter(attributionColors[index]); index++; } }); } }); }
Source:
<code>public void deployPartial(String name, Set<TargetExtensions> targetExtensions) throws Exception { Bundle bundle = new BundleImpl(osgi, lookupBundle(name), null); <START> RuntimeContext ctx = new OSGiRuntimeContext(runtime, bundle); <END> listBundleComponents(bundle).map(URLStreamRef::new).forEach(component -> { try { this.deployPartialComponent(ctx, targetExtensions, component); } catch (IOException e) { log.error("PartialBundle: " + name + " failed to load: " + component, e); } }); }</code><technical_language>ctx is returned method, destroyed use</technical_language>

Target:
public RuntimeContext deployPartial(String name, Set<TargetExtensions> targetExtensions) throws Exception { Bundle bundle = new BundleImpl(osgi, lookupBundle(name), null); RuntimeContext ctx = new OSGiRuntimeContext(runtime, bundle); listBundleComponents(bundle).map(URLStreamRef::new).forEach(component -> { try { this.deployPartialComponent(ctx, targetExtensions, component); } catch (IOException e) { log.error("PartialBundle: " + name + " failed to load: " + component, e); } }); return ctx; }
Source:
<code>public void testConfigManual() { final Injector injector = createInjector(); final String propertyPrefix = "druid.query.scheduler"; final JsonConfigProvider<QuerySchedulerProvider> provider = JsonConfigProvider.of( propertyPrefix, QuerySchedulerProvider.class ); final Properties properties = new Properties(); properties.put(propertyPrefix + ".numThreads", "10"); properties.put(propertyPrefix + ".laning.strategy", "manual"); properties.put(propertyPrefix + ".laning.lanes.one", "1"); properties.put(propertyPrefix + ".laning.lanes.two", "2"); provider.inject(properties, injector.getInstance(JsonConfigurator.class)); final QueryScheduler scheduler = provider.get().get().get(); Assert.assertEquals(10, scheduler.getTotalAvailableCapacity()); Assert.assertEquals(1, scheduler.getLaneAvailableCapacity("one")); <START> Assert.assertEquals(2, scheduler.getLaneAvailableCapacity("two")); <END> }</code><technical_language>test negative case (like lane name "three") get NO_CAPACITY</technical_language>

Target:
public void testConfigManual() { final Injector injector = createInjector(); final String propertyPrefix = "druid.query.scheduler"; final JsonConfigProvider<QuerySchedulerProvider> provider = JsonConfigProvider.of( propertyPrefix, QuerySchedulerProvider.class ); final Properties properties = new Properties(); properties.put(propertyPrefix + ".numThreads", "10"); properties.put(propertyPrefix + ".laning.strategy", "manual"); properties.put(propertyPrefix + ".laning.lanes.one", "1"); properties.put(propertyPrefix + ".laning.lanes.two", "2"); provider.inject(properties, injector.getInstance(JsonConfigurator.class)); final QueryScheduler scheduler = provider.get().get().get(); Assert.assertEquals(10, scheduler.getTotalAvailableCapacity()); Assert.assertEquals(1, scheduler.getLaneAvailableCapacity("one")); Assert.assertEquals(2, scheduler.getLaneAvailableCapacity("two")); Assert.assertEquals(QueryScheduler.UNAVAILABLE, scheduler.getLaneAvailableCapacity("non-existent")); }
Source:
<code>public void badReplicationLocationTest() throws Exception { <START> processor = new ReplicationProcessor(repository, "/some/bad/location", 3, 100L); <END> URI contentBase = createBaseContainer(RepositoryPathConstants.CONTENT_BASE); URI binaryUri = determineRepositoryPath(contentBase); String filename = "src/test/resources/external_file.txt"; File testFile = new File(filename); InputStream contentStream = new FileInputStream(testFile); String badChecksum = "9db3fcbaec92b9ccf9aa16f820184813080e77d2"; BinaryObject externalObj = repository.createBinary(binaryUri, "external_binary_test", contentStream, filename, MIMETYPE, null, null); when(message.getHeader(CdrBinaryChecksum)).thenReturn(badChecksum); when(message.getHeader(CdrBinaryUri)).thenReturn(externalObj.getUri().toString()); processor.process(exchange); }</code><technical_language>this line is executed ReplicationDestinationUnavailableException is immediate. For clarity remove rest of method</technical_language>

Target:
public void badReplicationLocationTest() throws Exception { processor = new ReplicationProcessor(repository, "/some/bad/location", 3, 100L); }
Source:
<code>private boolean radiologyReportNeedsToBeCreated(ModelAndView modelAndView, Order order) { if (order.isActive()) { <START> RadiologyOrder radiologyOrder = radiologyService.getRadiologyOrderByOrderId(order.getOrderId()); <END> if (radiologyService.hasRadiologyOrderClaimedRadiologyReport(radiologyOrder)) { modelAndView.addObject("radiologyReportNeedsToBeCreated", false); modelAndView.addObject("radiologyReport", radiologyService .getRadiologyReportsByRadiologyOrderAndRadiologyReportStatus(radiologyOrder, RadiologyReportStatus.CLAIMED).get(0)); return true; } if (radiologyService.hasRadiologyOrderCompletedRadiologyReport(radiologyOrder)) { modelAndView.addObject("radiologyReportNeedsToBeCreated", false); modelAndView.addObject("radiologyReport", radiologyService .getRadiologyReportsByRadiologyOrderAndRadiologyReportStatus(radiologyOrder, RadiologyReportStatus.COMPLETED).get(0)); return true; } modelAndView.addObject("radiologyReportNeedsToBeCreated", true); modelAndView.addObject("radiologyReport", new RadiologyReport(radiologyOrder)); return true; } return false; }</code><technical_language>@thomas-burko this simplified in view. top down. do want achieve in UI --> I need API do for me. need a RadiologyService method "active" report. getActiveRadiologyReport() return a RadiologyReport is **completed** **claimed**. if is report a discontinued returns null. this simplifies this entire method. put "active" RadiologyReport model view. In view check radiologyReport.radiologyReportStatus show a hyperlink name. if CLAIMED = "Resume work report" if COMPLETED = "Show completed report" it. this simplifies API DAO. get RadiologyReport matching RadiologyOrder, a radiologyReportStatus equal DISCONTINUED. if I missing here, me. this complicated me</technical_language>

Target:
private boolean radiologyReportNeedsToBeCreated(ModelAndView modelAndView, Order order) { if (order.isActive()) { RadiologyOrder radiologyOrder = radiologyService.getRadiologyOrderByOrderId(order.getOrderId()); RadiologyReport radiologyReport = radiologyService.getActiveRadiologyReportByRadiologyOrder(radiologyOrder); if (radiologyReport == null) { modelAndView.addObject("radiologyReportNeedsToBeCreated", true); } else { modelAndView.addObject("radiologyReportNeedsToBeCreated", false); } modelAndView.addObject("radiologyReport", radiologyReport); return true; } return false; }
Source:
<code><START> @Test public void testAggregateRollUp2() { <END> String mv = "" + "select \"empid\", stddev_pop(\"deptno\") " + "from \"emps\" " + "group by \"empid\", \"deptno\""; String query = "" + "select \"empid\", stddev_pop(\"deptno\") " + "from \"emps\" " + "group by \"empid\""; sql(mv, query).noMat(); }</code><technical_language>public is needed. Please remove</technical_language>

Target:
@Test void testAggregateRollUp2() { final String mv = "" + "select \"empid\", stddev_pop(\"deptno\") " + "from \"emps\" " + "group by \"empid\", \"deptno\""; final String query = "" + "select \"empid\", stddev_pop(\"deptno\") " + "from \"emps\" " + "group by \"empid\""; sql(mv, query).noMat(); }
Source:
<code>public ConversionResult convert( final Path path ) { ConversionResult result = new ConversionResult(); if ( !( xlsDTableType.accept( path ) || xlsxDTableType.accept( path ) ) ) { <START> result.addMessage( "Source Asset is not an XLS Decision Table.", <END> ConversionMessageType.ERROR ); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel( path ); final GuidedDecisionTableGeneratorListener listener = parseAssets( path, result, dmo ); final Path context = Paths.convert( Paths.convert( path ).getParent() ); createNewImports( context, listener.getImports(), result ); createNewFunctions( context, listener.getImports(), listener.getFunctions(), result ); createNewQueries( context, listener.getImports(), listener.getQueries(), result ); makeNewJavaTypes( context, listener.getTypeDeclarations(), result ); createNewGlobals( context, listener.getImports(), listener.getGlobals(), result ); createNewDecisionTables( context, listener.getImports(), listener.getGuidedDecisionTables(), result ); return result; }</code><technical_language>a minor thing, in error message mentioned XLS XLSX extension</technical_language>

Target:
public ConversionResult convert( final Path path ) { ConversionResult result = new ConversionResult(); if ( !( xlsDTableType.accept( path ) || xlsxDTableType.accept( path ) ) ) { result.addMessage( "Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR ); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel( path ); final GuidedDecisionTableGeneratorListener listener = parseAssets( path, result, dmo ); final Path context = Paths.convert( Paths.convert( path ).getParent() ); createNewImports( context, listener.getImports(), result ); createNewFunctions( context, listener.getImports(), listener.getFunctions(), result ); createNewQueries( context, listener.getImports(), listener.getQueries(), result ); makeNewJavaTypes( context, listener.getTypeDeclarations(), result ); createNewGlobals( context, listener.getImports(), listener.getGlobals(), result ); createNewDecisionTables( context, listener.getImports(), listener.getGuidedDecisionTables(), result ); return result; }
Source:
<code>private ForwardIndexReader<?> getForwardIndexReader(ColumnMetadata columnMetadata, SegmentDirectory.Writer segmentWriter) throws IOException { PinotDataBuffer buffer = segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); int numRows = columnMetadata.getTotalDocs(); int numBitsPerValue = columnMetadata.getBitsPerElement(); if (columnMetadata.isSingleValue()) { if (columnMetadata.hasDictionary()) { return new FixedBitSVForwardIndexReader(buffer, numRows, numBitsPerValue); } else { return new FixedByteChunkSVForwardIndexReader(buffer, columnMetadata.getDataType()); } } else { if (columnMetadata.hasDictionary()) { return new FixedBitMVForwardIndexReader(buffer, numRows, columnMetadata.getTotalNumberOfEntries(), numBitsPerValue); } else { <START> throw new RuntimeException("Range indexing is not supported for multi value non-dictionary columns"); <END> } } }</code><technical_language>suggestion throw new RuntimeException("Raw index multi-value column is supported");</technical_language>

Target:
private ForwardIndexReader<?> getForwardIndexReader(ColumnMetadata columnMetadata, SegmentDirectory.Writer segmentWriter) throws IOException { PinotDataBuffer buffer = segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); int numRows = columnMetadata.getTotalDocs(); int numBitsPerValue = columnMetadata.getBitsPerElement(); if (columnMetadata.isSingleValue()) { if (columnMetadata.hasDictionary()) { return new FixedBitSVForwardIndexReader(buffer, numRows, numBitsPerValue); } else { return new FixedByteChunkSVForwardIndexReader(buffer, columnMetadata.getDataType()); } } else { if (columnMetadata.hasDictionary()) { return new FixedBitMVForwardIndexReader(buffer, numRows, columnMetadata.getTotalNumberOfEntries(), numBitsPerValue); } else { throw new IllegalStateException("Raw index on multi-value column is not supported"); } } }
Source:
<code>private void restartRmAndCheckFinalState(boolean nodesShouldBeRecreated) throws Exception { rmHelper = new RMTHelper(); startRmWithConfig(RESTART_CONFIG); <START> Assert.assertFalse("Nodes preservation should not be activated on RM restart for the test", <END> PAResourceManagerProperties.RM_PRESERVE_NODES_ON_EXIT.getValueAsBoolean()); assertThat(rmHelper.isRMStarted()).isTrue(); RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager; ArrayList<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSource(); assertThat(nodeSourceEvent.size()).isEqualTo(1); assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME); if (nodesShouldBeRecreated) { rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, NODE_NUMBER); } Set<String> allNodes = resourceManagerMonitor.getState().getAllNodes(); assertThat(allNodes.size()).isEqualTo(NODE_NUMBER); Set<String> nodeSourceNames = new HashSet<>(); nodeSourceNames.add(NODE_SOURCE_NAME); Set<String> aliveNodeUrls = resourceManager.listAliveNodeUrls(nodeSourceNames); assertThat(aliveNodeUrls.size()).isEqualTo(NODE_NUMBER); BooleanWrapper lockSucceeded = resourceManager.lockNodes(allNodes); assertThat(lockSucceeded).isEqualTo(new BooleanWrapper(true)); BooleanWrapper unlockSucceeded = resourceManager.unlockNodes(allNodes); assertThat(unlockSucceeded).isEqualTo(new BooleanWrapper(true)); }</code><technical_language>Replace Assert.assertFalse assertThat library in class</technical_language>

Target:
private void restartRmAndCheckFinalState(boolean nodesShouldBeRecreated) throws Exception { rmHelper = new RMTHelper(); startRmWithConfig(RESTART_CONFIG); assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_EXIT.getValueAsBoolean()).isFalse(); assertThat(rmHelper.isRMStarted()).isTrue(); RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager; ArrayList<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSource(); assertThat(nodeSourceEvent.size()).isEqualTo(1); assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME); if (nodesShouldBeRecreated) { rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, NODE_NUMBER); } Set<String> allNodes = resourceManagerMonitor.getState().getAllNodes(); assertThat(allNodes.size()).isEqualTo(NODE_NUMBER); Set<String> nodeSourceNames = new HashSet<>(); nodeSourceNames.add(NODE_SOURCE_NAME); Set<String> aliveNodeUrls = resourceManager.listAliveNodeUrls(nodeSourceNames); assertThat(aliveNodeUrls.size()).isEqualTo(NODE_NUMBER); BooleanWrapper lockSucceeded = resourceManager.lockNodes(allNodes); assertThat(lockSucceeded).isEqualTo(new BooleanWrapper(true)); BooleanWrapper unlockSucceeded = resourceManager.unlockNodes(allNodes); assertThat(unlockSucceeded).isEqualTo(new BooleanWrapper(true)); }
Source:
<code>public void testIsValid() { <START> LocalTime now = LocalTime.now(); <END> int currentHour = now.getHour(); int currentMinute = now.getMinute(); LocalTime future = now.plusMinutes( 1 ); LocalTime past = now.minusMinutes( 1 ); assertTrue( constraint.isValid( null, null ) ); if (!(currentHour == 23 && currentMinute == 59)) { assertTrue( constraint.isValid( future, null ) ); } if (!(currentHour == 0 && currentMinute == 0)) { assertFalse( constraint.isValid( past, null ) ); } }</code><technical_language>considered now(Clock)? This helpful avoid "false negatives" a specific time/clock for testing</technical_language>

Target:
public void testIsValid() { LocalTime now = LocalTime.now(); int currentHour = now.getHour(); int currentMinute = now.getMinute(); LocalTime future = now.plusMinutes( 1 ); LocalTime past = now.minusMinutes( 1 ); assertTrue( constraint.isValid( null, null ), "null fails validation." ); if (!(currentHour == 23 && currentMinute == 59)) { assertTrue( constraint.isValid( future, null ), "Future LocalTime '" + future + "' fails validation."); } if (!(currentHour == 0 && currentMinute == 0)) { assertFalse( constraint.isValid( past, null ), "Past LocalTime '" + past + "' validated as future."); } }
Source:
<code>static Region merge(Region a, Region b) { <START> Region resultRegion; Region otherRegion; if (a.resultStart < b.resultStart) { resultRegion = a.deepCopy(); otherRegion = b.deepCopy(); } else { resultRegion = b.deepCopy(); otherRegion = a.deepCopy(); } <END> final Region result = resultRegion; while (otherRegion != null) { if (resultRegion.next != null && resultRegion.resultStart < otherRegion.resultStart && resultRegion.next.resultStart < otherRegion.resultStart) { resultRegion = resultRegion.next; } else { Region otherNext = otherRegion.next; otherRegion.next = resultRegion.next; resultRegion.next = otherRegion; resultRegion = otherRegion; otherRegion = otherNext; } } return result; }</code><technical_language>This shorter: a = a.deepCopy(); b = b.deepCopy(); if (a.resultStart > b.resultStart) { Region o = a; a = b; b = o; } OK overwriting parameters entering a method, especially parameter again. a b dead function starts. confusing overwrite reuse names</technical_language>

Target:
static Region merge(Region a, Region b) { if (a.resultStart > b.resultStart) { Region o = a; a = b; b = o; } final Region result = a; while (b != null) { if (a.next != null && a.resultStart < b.resultStart && a.next.resultStart < b.resultStart) { a = a.next; } else { Region bNext = b.next; b.next = a.next; a.next = b; a = b; b = bNext; } } return result; }
Source:
<code>public static ArrayList<Dish> parseDishes(String dishesRespStr) throws JSONException { if (dishesRespStr == null) { return null; } ArrayList<Dish> resultList = null; JSONObject dishes = new JSONObject(dishesRespStr); <START> resultList = new ArrayList<Dish>(); <END> JSONArray dishArray = dishes.getJSONArray("dishes"); int length = dishArray.length(); for (int i = 0; i < length; i++) { Dish dish = new Dish(); JSONObject dishObj = dishArray.getJSONObject(i); dish.setDishId(dishObj.getLong("_id")); dish.setName(dishObj.getString("name")); dish.setPrice(dishObj.getInt("price")); dish.setDescription(dishObj.getString("description")); dish.setImageServer(dishObj.getString("image_url")); long createTimeValue = dishObj.getLong("create_time"); long updateTimeValue = dishObj.getLong("update_time"); Date createTime = new Date(createTimeValue); Date updateTime = new Date(updateTimeValue); dish.setCreateTime(createTime); dish.setUpdateTime(updateTime); resultList.add(dish); } return resultList; }</code><technical_language>statement create arraylist instead of separated two. for parseXXX methods</technical_language>

Target:
public static ArrayList<Dish> parseDishes(String dishesRespStr) throws JSONException { if (dishesRespStr == null) { return null; } ArrayList<Dish> resultList = new ArrayList<Dish>(); JSONObject dishes = new JSONObject(dishesRespStr); JSONArray dishArray = dishes.getJSONArray("dishes"); int length = dishArray.length(); for (int i = 0; i < length; i++) { Dish dish = new Dish(); JSONObject dishObj = dishArray.getJSONObject(i); dish.setDishId(dishObj.getLong("_id")); dish.setName(dishObj.getString("name")); dish.setPrice(dishObj.getInt("price")); dish.setDescription(dishObj.getString("description")); dish.setImageServer(dishObj.getString("image_url")); long createTimeValue = dishObj.getLong("create_time"); long updateTimeValue = dishObj.getLong("update_time"); Date createTime = new Date(createTimeValue); Date updateTime = new Date(updateTimeValue); dish.setCreateTime(createTime); dish.setUpdateTime(updateTime); resultList.add(dish); } return resultList; }
Source:
<code>public boolean equals(Object obj) { if (obj instanceof Histogram) { Histogram other = (Histogram) obj; <START> return getLastAnalyzed().equals(other.getLastAnalyzed()) <END> && TUtil.checkEquals(this.buckets, other.buckets); } else { return false; } }</code><technical_language>'isReady' variable is missing</technical_language>

Target:
public boolean equals(Object obj) { if (obj instanceof Histogram) { Histogram other = (Histogram) obj; return getLastAnalyzed().equals(other.getLastAnalyzed()) && TUtil.checkEquals(getDataType(), other.getDataType()) && TUtil.checkEquals(this.buckets, other.buckets); } else { return false; } }
Source:
<code>protected DiskSnapshots mapCollection(List<org.ovirt.engine.core.common.businessentities.Disk> entities) { DiskSnapshots collection = new DiskSnapshots(); for (org.ovirt.engine.core.common.businessentities.Disk disk : entities) { <START> DiskSnapshot diskSnapshot = DiskSnapshotMapper.map(disk, null); <END> collection.getDiskSnapshots().add(addLinks(populate(diskSnapshot, disk))); } return collection; }</code><technical_language>Consider mapping locator: getMapper(org.ovirt.engine.core.common.businessentities.Disk.class, DiskSnapshot.class).map(disk, null); Client code asks for a mapper maps X.class Y.class, infrasctructure provides it, saving client need in mapper class (DiskSnapshotMapper in this case) mapping is implemented. a must</technical_language>

Target:
protected DiskSnapshots mapCollection(List<org.ovirt.engine.core.common.businessentities.Disk> entities) { DiskSnapshots collection = new DiskSnapshots(); for (org.ovirt.engine.core.common.businessentities.Disk disk : entities) { DiskSnapshot diskSnapshot = getMapper(org.ovirt.engine.core.common.businessentities.Disk.class, DiskSnapshot.class).map(disk, null); diskSnapshot.setStorageDomain(new StorageDomain()); diskSnapshot.getStorageDomain().setId(this.storageDomainId.toString()); collection.getDiskSnapshots().add(addLinks(populate(diskSnapshot, disk))); } return collection; }
Source:
<code>public String getBrokerID() { final String name = this.name; if (name != null && name.length() > 0) { return name; } else { StringBuffer b = new StringBuffer(); if (host != null) { b.append(host); } final Integer port = this.port; if (port != null) { <START> b.append(":"); <END> b.append(port.toString()); } b.append(":s"); return b.toString(); } }</code><technical_language>this removed? secure s appended</technical_language>

Target:
public String getBrokerID() { final String name = this.name; if (name != null && name.length() > 0) { return name; } else { StringBuffer b = new StringBuffer(); if (host != null) { b.append(host); } final Integer port = this.port; if (port != null) { b.append(":"); b.append(port.toString()); } if (secure) { b.append(":s"); } return b.toString(); } }
Source:
<code>public PutStatus put(final K key, final V value) throws StoreAccessException { putObserver.begin(); <START> PutOperation<K, V> operation = new PutOperation<K, V>(key, value, timeSource.getTimeMillis(), true); <END> ByteBuffer payload = codec.encode(operation); Chain chain = storeProxy.getAndAppend(key.hashCode(), payload); ResolvedChain<K, V> resolvedChain = resolver.resolve(chain, key, timeSource.getTimeMillis()); if(resolvedChain.getResolvedResult(key) == null) { putObserver.end(StoreOperationOutcomes.PutOutcome.PUT); return PutStatus.PUT; } else { putObserver.end(StoreOperationOutcomes.PutOutcome.REPLACED); return PutStatus.UPDATE; } }</code><technical_language>additional helper constructor in operation classes handle _isFirst_ flag implicitly nice</technical_language>

Target:
public PutStatus put(final K key, final V value) throws StoreAccessException { putObserver.begin(); PutOperation<K, V> operation = new PutOperation<K, V>(key, value, timeSource.getTimeMillis()); ByteBuffer payload = codec.encode(operation); Chain chain = storeProxy.getAndAppend(key.hashCode(), payload); ResolvedChain<K, V> resolvedChain = resolver.resolve(chain, key, timeSource.getTimeMillis()); if(resolvedChain.getResolvedResult(key) == null) { putObserver.end(StoreOperationOutcomes.PutOutcome.PUT); return PutStatus.PUT; } else { putObserver.end(StoreOperationOutcomes.PutOutcome.REPLACED); return PutStatus.UPDATE; } }
Source:
<code>public void servoEnable(ServoControl servo) { int deviceId = getDeviceId(servo); <START> msg.servoAttachPin(deviceId, getAddress(servo.getPin())); <END> }</code><technical_language>interface accept pin object here. no</technical_language>

Target:
public void servoEnable(ServoControl servo) { Integer deviceId = getDeviceId(servo); if (deviceId == null) { log.warn("servoEnable servo does not have a corresponding device currently - did you attach?", servo.getName()); } msg.servoAttachPin(deviceId, getAddress(servo.getPin())); }
Source:
<code><START> public static Object buildBean(Class<?> beanClass, Map<String, String> values) { <END> try { Object obj = null; if (beanClass.isInterface()) { obj = ekbService.createModelObject(beanClass); } else { obj = beanClass.newInstance(); } BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (propertyDescriptor.getWriteMethod() == null || !Modifier.isPublic(propertyDescriptor.getWriteMethod().getModifiers())) { continue; } String value = values.get(propertyDescriptor.getName()); Object ob = convertToCorrectClass(propertyDescriptor.getPropertyType(), value); propertyDescriptor.getWriteMethod().invoke(obj, ob); } return obj; } catch (Exception e) { throw new IllegalArgumentException(e); } }</code><technical_language>is way</technical_language>

Target:
public static Object buildBean(Class<?> beanClass, Map<String, String> values) { try { Object obj = null; if (beanClass.isInterface()) { @SuppressWarnings("unchecked") Class<? extends OpenEngSBModel> model = (Class<? extends OpenEngSBModel>) beanClass; obj = ekbService.createEmptyModelObject(model); } else { obj = beanClass.newInstance(); } BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (propertyDescriptor.getWriteMethod() == null || !Modifier.isPublic(propertyDescriptor.getWriteMethod().getModifiers())) { continue; } String value = values.get(propertyDescriptor.getName()); Object ob = convertToCorrectClass(propertyDescriptor.getPropertyType(), value); propertyDescriptor.getWriteMethod().invoke(obj, ob); } return obj; } catch (Exception e) { throw new IllegalArgumentException(e); } }