auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public OpenShiftProjectUIModel(IProject project) { super(); resourceModel = new OpenShiftResourceUIModel(project); <START> System.out.println(this.hashCode()); <END> }</code><technical_language>yuck</technical_language>

Target:
public OpenShiftProjectUIModel(IProject project) { super(); resourceModel = new OpenShiftResourceUIModel(project); }
Source:
<code>public void testLoadMetadataBlock_ErrorHandling() { Response createUser = UtilIT.createRandomUser(); String apiToken = UtilIT.getApiTokenFromResponse(createUser); byte[] updatedContent = null; try { updatedContent = Files.readAllBytes(Paths.get("src/test/resources/tsv/test.tsv")); } catch (IOException e) { logger.warning(e.getMessage()); assertEquals(0,1); } Response response = UtilIT.loadMetadataBlock(apiToken, updatedContent); assertEquals(500, response.getStatusCode()); response.then().assertThat().statusCode(INTERNAL_SERVER_ERROR.getStatusCode()); String body = response.getBody().asString(); String status = JsonPath.from(body).getString("status"); assertEquals("ERROR", status); String message = JsonPath.from(body).getString("message"); assertEquals( <START> "Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' cell (#5)", <END> message ); }</code><technical_language>Oh, need get latest develop branch</technical_language>

Target:
public void testLoadMetadataBlock_ErrorHandling() { Response createUser = UtilIT.createRandomUser(); String apiToken = UtilIT.getApiTokenFromResponse(createUser); byte[] updatedContent = null; try { updatedContent = Files.readAllBytes(Paths.get("src/test/resources/tsv/test.tsv")); } catch (IOException e) { logger.warning(e.getMessage()); assertEquals(0,1); } Response response = UtilIT.loadMetadataBlock(apiToken, updatedContent); assertEquals(500, response.getStatusCode()); response.then().assertThat().statusCode(INTERNAL_SERVER_ERROR.getStatusCode()); String body = response.getBody().asString(); String status = JsonPath.from(body).getString("status"); assertEquals("ERROR", status); String message = JsonPath.from(body).getString("message"); assertEquals( "Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' column (#5)", message ); }
Source:
<code>public void stateChanged(Item item, State oldState, State newState) { setState(function.calculate(members)); setGroupState(new GroupType(item.getName(),GroupChange.CHANGED)); <START> <END> }</code><technical_language>IMHO remove empty line in front of a closing bracket</technical_language>

Target:
public void stateChanged(Item item, State oldState, State newState) { }
Source:
<code>public void shouldEditAnAutoGenerationOption() throws Exception { assertEquals(LOCATION, identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).getLocation().getUuid()); <START> assertEquals(SOURCE, <END> identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).getSource().getUuid()); assertTrue( identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).isAutomaticGenerationEnabled()); assertTrue(identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).isManualEntryEnabled()); SimpleObject autoGenerationOption = new SimpleObject(); autoGenerationOption.add("location", NEW_LOCATION); autoGenerationOption.add("source", NEW_SOURCE); autoGenerationOption.add("manualEntryEnabled", false); autoGenerationOption.add("automaticGenerationEnabled", false); String json = new ObjectMapper().writeValueAsString(autoGenerationOption); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(NEW_LOCATION, identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).getLocation().getUuid()); assertEquals(NEW_SOURCE, identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).getSource().getUuid()); assertFalse( identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).isAutomaticGenerationEnabled()); assertFalse(identifierSourceService.getAutoGenerationOption(Integer.parseInt(getUuid())).isManualEntryEnabled()); }</code><technical_language>need call Integer.parseInt(getUuid()) more once</technical_language>

Target:
public void shouldEditAnAutoGenerationOption() throws Exception { AutoGenerationOption autogenerationOption = identifierSourceService.getAutoGenerationOption(getId()); assertEquals(LOCATION, autogenerationOption.getLocation().getUuid()); assertEquals(SOURCE, autogenerationOption.getSource().getUuid()); assertTrue(autogenerationOption.isAutomaticGenerationEnabled()); assertTrue(autogenerationOption.isManualEntryEnabled()); SimpleObject autoGenerationOption = new SimpleObject(); autoGenerationOption.add("location", NEW_LOCATION); autoGenerationOption.add("source", NEW_SOURCE); autoGenerationOption.add("manualEntryEnabled", false); autoGenerationOption.add("automaticGenerationEnabled", false); String json = new ObjectMapper().writeValueAsString(autoGenerationOption); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); AutoGenerationOption updatedAutogenerationOption = identifierSourceService.getAutoGenerationOption(getId()); assertEquals(NEW_LOCATION, updatedAutogenerationOption.getLocation().getUuid()); assertEquals(NEW_SOURCE, updatedAutogenerationOption.getSource().getUuid()); assertFalse(updatedAutogenerationOption.isAutomaticGenerationEnabled()); assertFalse(updatedAutogenerationOption.isManualEntryEnabled()); }
Source:
<code>public Iterable<Location> listLocations() { List<Location> locations = new ArrayList<Location>(); Location loc = Location.create("westus", "westus", "westus", 20, 20); <START> locations.add(loc); <END> return locations; }</code><technical_language>Hardcoded list of locations removed merging</technical_language>

Target:
public Iterable<Location> listLocations() { List<Location> locations = api.getLocationApi().list(); List<ResourceProviderMetaData> resources = api.getResourceProviderApi().get("Microsoft.Compute"); final List<String> vmLocations = new ArrayList<String>(); for (ResourceProviderMetaData m : resources){ if (m.resourceType().equals("virtualMachines")){ vmLocations.addAll(m.locations()); break; } } Iterable<Location> result = Iterables.filter(locations, new Predicate<Location>() { @Override public boolean apply(Location input) { return vmLocations.contains(input.displayName()); } }); return result; }
Source:
<code>List getNetworkInterfaces(VM vm){ List net = new ArrayList(); List<Device> nicDevices = vm.getDevicesByType(Device.DeviceType.NIC); for (Device device: nicDevices){ Map resultMap = new HashMap(); List templist = new ArrayList(); List templist2 = new ArrayList(); resultMap.put("name", "eth0"); templist.add("fe80::21a:4aff:fe16:2016"); templist.add("2620:52:0:2380:21a:4aff:fe16:2016"); resultMap.put("inet6", templist); templist2.add(vm.getIp()); resultMap.put("inet", templist2); resultMap.put("hw", vm.getMacAddress()); net.add(resultMap); <START> break; <END> } log.debug("network list is {}", net.toString()); return net; }</code><technical_language>do need a loop if break here</technical_language>

Target:
List getNetworkInterfaces(VM vm){ List net = new ArrayList(); Map resultMap = new HashMap(); List Inet6List = new ArrayList(); List Inet4List = new ArrayList(); resultMap.put("name", "eth0"); Inet6List.add("fe80::21a:4aff:fe16:2016"); Inet6List.add("2620:52:0:2380:21a:4aff:fe16:2016"); resultMap.put("inet6", Inet6List); Inet4List.add(vm.getIp()); resultMap.put("inet", Inet4List); resultMap.put("hw", vm.getMacAddress()); net.add(resultMap); log.debug("network list is {}", net.toString()); return net; }
Source:
<code>public void verifyPerformance() { final OnmsNode node1 = m_populator.getNode1(); final IPAddressRange ipAddresses = new IPAddressRange("10.10.0.0", "10.10.255.255"); final Iterator<IPAddress> iterator = ipAddresses.iterator(); while (iterator.hasNext()) { IPAddress address = iterator.next(); OnmsIpInterface ipInterface = new OnmsIpInterface(); ipInterface.setNode(node1); ipInterface.setIpAddress(address.toInetAddress()); m_interfaceDao.save(ipInterface); } assertThat(m_interfaceDao.countAll(), greaterThan(255 * 255)); long start = System.currentTimeMillis(); m_dao.getActiveIPAddressList("IPADDR != '0.0.0.0'"); long diff = System.currentTimeMillis() - start; start = System.currentTimeMillis(); assertThat(m_dao.isValid("10.10.0.1", "IPADDR != '0.0.0.0'"), is(true)); long diff2 = System.currentTimeMillis() - start; <START> assertThat(diff, greaterThan(diff2)); <END> }</code><technical_language>Comparing timing in this fashion flaps i.e. if JVM GC pauses 2nd measure, diff2 > diff. I print out time stamps include assertion for functional bits</technical_language>

Target:
public void verifyPerformance() { final OnmsNode node1 = m_populator.getNode1(); final IPAddressRange ipAddresses = new IPAddressRange("10.10.0.0", "10.10.255.255"); final Iterator<IPAddress> iterator = ipAddresses.iterator(); while (iterator.hasNext()) { IPAddress address = iterator.next(); OnmsIpInterface ipInterface = new OnmsIpInterface(); ipInterface.setNode(node1); ipInterface.setIpAddress(address.toInetAddress()); m_interfaceDao.save(ipInterface); } final int numberOfInterfaces = m_interfaceDao.countAll(); assertThat(numberOfInterfaces, greaterThan(255 * 255)); assertThat(m_dao.getActiveIPAddressList("IPADDR != '0.0.0.0'"), Matchers.hasSize(numberOfInterfaces)); assertThat(m_dao.isValid("10.10.0.1", "IPADDR != '0.0.0.0'"), is(true)); }
Source:
<code><START> public OutputToScreenNode(Context context) { <END> super(context); displayResolutionDependentFBOs = context.get(DisplayResolutionDependentFBOs.class); worldRenderer = context.get(WorldRenderer.class); WorldRenderer worldRenderer = context.get(WorldRenderer.class); requiresCondition(() -> worldRenderer.getCurrentRenderStage() == MONO || worldRenderer.getCurrentRenderStage() == LEFT_EYE); addDesiredStateChange(new EnableMaterial(DEFAULT_TEXTURED_MATERIAL_URN)); bindFbo = new SetInputTextureFromFbo(0, FINAL_BUFFER, ColorTexture, displayResolutionDependentFBOs, DEFAULT_TEXTURED_MATERIAL_URN, "texture"); addDesiredStateChange(bindFbo); nodeInstance = this; SwappableFBO gBufferPair = displayResolutionDependentFBOs.getGBufferPair(); lastUpdatedGBuffer = gBufferPair.getLastUpdatedFbo(); staleGBuffer = gBufferPair.getStaleFbo(); }</code><technical_language>rename PerformanceMonitor line 75: java PerformanceMonitor.startActivity("rendering/copyImageToScreen");</technical_language>

Target:
public OutputToScreenNode(Context context) { super(context); displayResolutionDependentFBOs = context.get(DisplayResolutionDependentFBOs.class); worldRenderer = context.get(WorldRenderer.class); WorldRenderer worldRenderer = context.get(WorldRenderer.class); requiresCondition(() -> worldRenderer.getCurrentRenderStage() == MONO || worldRenderer.getCurrentRenderStage() == LEFT_EYE); addDesiredStateChange(new EnableMaterial(DEFAULT_TEXTURED_MATERIAL_URN)); bindFbo = new SetInputTextureFromFbo(0, FINAL_BUFFER, ColorTexture, displayResolutionDependentFBOs, DEFAULT_TEXTURED_MATERIAL_URN, "texture"); addDesiredStateChange(bindFbo); SwappableFBO gBufferPair = displayResolutionDependentFBOs.getGBufferPair(); lastUpdatedGBuffer = gBufferPair.getLastUpdatedFbo(); staleGBuffer = gBufferPair.getStaleFbo(); }
Source:
<code>public void verifyLightboxVideo() { waitForElementByElement(videoContainer); <START> PageObjectLogging.log("verifyLightboxVideo", "verify lightbox video appeared", true); <END> }</code><technical_language>consider removing word verify logging description</technical_language>

Target:
public void verifyLightboxVideo() { waitForElementByElement(videoContainer); PageObjectLogging.log("verifyLightboxVideo", "Lightbox video appeared", true); }
Source:
<code>public void setPortNumbers(int[] portNumbers) { <START> this.portNumbers = portNumbers; <END> }</code><technical_language>This handle a null array empty array. In cases reset portNumbers new int[] { 0 } default reverted. Assuming this change is rest of class assume portNumber null entry</technical_language>

Target:
public void setPortNumbers(int[] portNumbers) { if (portNumbers == null || portNumbers.length == 0) { portNumbers = new int[] { 0 }; } this.portNumbers = Arrays.copyOf(portNumbers, portNumbers.length); }
Source:
<code>public String convert(DockerImageURI dockerImage) { String name = dockerImage.getName(); StringBuilder builder = new StringBuilder(name.length()); for(int i=0; i < name.length();++i) { char c = name.charAt(i); if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { builder.append(c); } else if (c == '_') { builder.append('-'); } } <START> if (builder.length() > 24) { <END> builder.delete(24, builder.length()); } return builder.toString(); }</code><technical_language>I suggest exposing max length validator ensure do vary independently</technical_language>

Target:
public String convert(DockerImageURI dockerImage) { String name = dockerImage.getName(); StringBuilder builder = new StringBuilder(name.length()); boolean lastSpecialChar = true; for(int i=0; i < name.length() && builder.length() < MAXLENGTH;++i) { char c = name.charAt(i); if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { if ((c >= '0') && (c <= '9') && (builder.length() == 0)) { builder.append('a'); } builder.append(c); lastSpecialChar = false; } else if (((c == '_') || (c == '-')) && !lastSpecialChar) { builder.append('-'); lastSpecialChar = true; } } if ((builder.length() > 0) && lastSpecialChar) { builder.deleteCharAt(builder.length() - 1); } return builder.toString(); }
Source:
<code>public static void register(ScalarFunctionModule module) { FunctionName name = new FunctionName(null, NAME); module.register( <START> new FuncResolver( <END> new Signature( name, FunctionInfo.Type.SCALAR, Collections.emptyList(), List.of(parseTypeSignature("text"), parseTypeSignature("text")), parseTypeSignature("text"), false), args -> new StringConcatFunction( new FunctionInfo( new FunctionIdent(NAME, args), DataTypes.STRING)) ) ); module.register( new FuncResolver( new Signature( name, FunctionInfo.Type.SCALAR, Collections.emptyList(), List.of(parseTypeSignature("text")), parseTypeSignature("text"), true), args -> new GenericConcatFunction( new FunctionInfo( new FunctionIdent(NAME, args), DataTypes.STRING)) ) ); Signature signature = new Signature( name, FunctionInfo.Type.SCALAR, List.of(typeVariable("E")), List.of(parseTypeSignature("array(E)"), parseTypeSignature("array(E)")), parseTypeSignature("array(E)"), false ); module.register( new FuncResolver( signature, args -> new ArrayCatFunction(ArrayCatFunction.createInfo(args)) ) ); }</code><technical_language>do of for module.register(signature, types -> impl), omit FuncResolver register API</technical_language>

Target:
public static void register(ScalarFunctionModule module) { module.register( Signature.builder() .name(NAME) .kind(FunctionInfo.Type.SCALAR) .argumentTypes(parseTypeSignature("text"), parseTypeSignature("text")) .returnType(parseTypeSignature("text")) .setVariableArity(false) .build(), args -> new StringConcatFunction( new FunctionInfo(new FunctionIdent(NAME, args), DataTypes.STRING) ) ); module.register( Signature.builder() .name(NAME) .kind(FunctionInfo.Type.SCALAR) .argumentTypes(parseTypeSignature("text")) .returnType(parseTypeSignature("text")) .setVariableArity(true) .build(), args -> new GenericConcatFunction( new FunctionInfo(new FunctionIdent(NAME, args), DataTypes.STRING) ) ); module.register( Signature.builder() .name(NAME) .kind(FunctionInfo.Type.SCALAR) .typeVariableConstraints(typeVariable("E")) .argumentTypes(parseTypeSignature("array(E)"), parseTypeSignature("array(E)")) .returnType(parseTypeSignature("array(E)")) .setVariableArity(false) .build(), args -> new ArrayCatFunction(ArrayCatFunction.createInfo(args)) ); }
Source:
<code>private boolean mediate(MessageContext synCtx, String format) { if (!isDoingXml(synCtx) && !isDoingJson(synCtx)) { log.error("#mediate. Could not identify the payload format of the existing payload prior to mediate."); return false; } org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); StringBuffer result = new StringBuffer(); <START> StringBuffer resultCTX = new StringBuffer(); <END> regexTransformCTX(resultCTX, synCtx, format); regexTransform(result, synCtx, resultCTX.toString()); String out = result.toString().trim(); if (log.isDebugEnabled()) { log.debug("#mediate. Transformed payload format>>> " + out); } if (mediaType.equals(XML_TYPE)) { try { JsonUtil.removeJsonPayload(axis2MessageContext); OMElement omXML = AXIOMUtil.stringToOM(out); if (!checkAndReplaceEnvelope(omXML, synCtx)) { axis2MessageContext.getEnvelope().getBody().addChild(omXML.getFirstElement().getFirstElement()); } } catch (XMLStreamException e) { handleException("Error creating SOAP Envelope from source " + out, synCtx); } } else if (mediaType.equals(JSON_TYPE)) { JsonUtil.newJsonPayload(axis2MessageContext, out, true, true); } else if (mediaType.equals(TEXT_TYPE)) { JsonUtil.removeJsonPayload(axis2MessageContext); axis2MessageContext.getEnvelope().getBody().addChild(getTextElement(out)); } setContentType(synCtx); return true; }</code><technical_language>result (StringBuffer)</technical_language>

Target:
private boolean mediate(MessageContext synCtx, String format) { if (!isDoingXml(synCtx) && !isDoingJson(synCtx)) { log.error("#mediate. Could not identify the payload format of the existing payload prior to mediate."); return false; } org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); StringBuffer result = new StringBuffer(); StringBuffer resultCTX = new StringBuffer(); regexTransformCTX(resultCTX, synCtx, format); replace(resultCTX.toString(),result, synCtx); String out = result.toString().trim(); if (log.isDebugEnabled()) { log.debug("#mediate. Transformed payload format>>> " + out); } if (mediaType.equals(XML_TYPE)) { try { JsonUtil.removeJsonPayload(axis2MessageContext); OMElement omXML = AXIOMUtil.stringToOM(out); if (!checkAndReplaceEnvelope(omXML, synCtx)) { axis2MessageContext.getEnvelope().getBody().addChild(omXML.getFirstElement()); } } catch (XMLStreamException e) { handleException("Error creating SOAP Envelope from source " + out, synCtx); } } else if (mediaType.equals(JSON_TYPE)) { JsonUtil.newJsonPayload(axis2MessageContext, out, true, true); } else if (mediaType.equals(TEXT_TYPE)) { JsonUtil.removeJsonPayload(axis2MessageContext); axis2MessageContext.getEnvelope().getBody().addChild(getTextElement(out)); } setContentType(synCtx); return true; }
Source:
<code>public static void getRootCAList(StringWriter writer) { KeyStore instance = null; try { instance = KeyStore.getInstance(KeyStore.getDefaultType()); while (instance.aliases().hasMoreElements()) { String s = instance.aliases().nextElement(); writer.append("========"); writer.append("Alias: " + s); writer.append(instance.getCertificate(s).getPublicKey().toString()); writer.append("Trusted certificate: " + instance.isCertificateEntry(s)); } } catch (KeyStoreException e) { <START> writer.write(ExceptionUtils.getFullStackTrace(e)); <END> } }</code><technical_language>is a similar method in hudson.Functions BTW</technical_language>

Target:
public static void getRootCAList(StringWriter writer) { KeyStore instance = null; try { instance = KeyStore.getInstance(KeyStore.getDefaultType()); Enumeration<String> aliases = instance.aliases(); while (aliases.hasMoreElements()) { String s = aliases.nextElement(); writer.append("========"); writer.append("Alias: " + s); writer.append(instance.getCertificate(s).getPublicKey().toString()); writer.append("Trusted certificate: " + instance.isCertificateEntry(s)); } } catch (KeyStoreException e) { writer.write(Functions.printThrowable(e)); } }
Source:
<code><START> private static Function<CompositeData, MemoryUsage> compositeDataToMemoryUsage() { <END> return new Function<CompositeData, MemoryUsage>() { @Override public MemoryUsage apply(CompositeData input) { return (input == null) ? null : MemoryUsage.from(input); } }; }</code><technical_language>times() this left public please</technical_language>

Target:
public static Function<CompositeData, MemoryUsage> compositeDataToMemoryUsage() { return new Function<CompositeData, MemoryUsage>() { @Override public MemoryUsage apply(CompositeData input) { return (input == null) ? null : MemoryUsage.from(input); } }; }
Source:
<code>private void produceCount(String brokerList, ArrayList<byte[]> monitorSet) { Properties props = new Properties(); props.put("metadata.broker.list", brokerList); props.put("producer.type", "async"); props.put("request.required.acks", "1"); props.put("request.timeout.ms", "30000"); log.debug("Broker list: " + brokerList); Producer producer = null; try { producer = createProducer(props); for (byte[] message : monitorSet) { for (int i = 0; i < NUM_TRIES_PUBLISH_COUNTS; i++) { try { KeyedMessage keyedMessage = new KeyedMessage("TrackingMonitoringEvent", message); producer.send(keyedMessage); break; } catch (Exception e) { log.error("Publishing count for topic " + topic + " to " + brokerList.toString() + " has failed " + (i + 1) + " times. " + (NUM_TRIES_PUBLISH_COUNTS - i - 1) + " more attempts will be made."); if (i == NUM_TRIES_PUBLISH_COUNTS - 1) { throw new RuntimeException(e.getMessage() + ": " + "Have retried maximum (" + NUM_TRIES_PUBLISH_COUNTS + ") times."); } try { Thread.sleep((long) (Math.random() * (i + 1) * 1000)); } catch (InterruptedException e1) { log.error("Caught interrupted exception between retries of publishing counts to Kafka. " + e1.getMessage()); } } } } } catch (Exception e) { <START> throw new RuntimeException("failed to publish counts to kafka: " + e.getMessage()); <END> } finally { if (producer != null) { producer.close(); } } }</code><technical_language>want change this to: throw new RuntimeException("failed publish counts Kafka: " + e.getMessage(), e); get full stack trace of original exception</technical_language>

Target:
private void produceCount(String brokerList, ArrayList<byte[]> monitorSet) { Properties props = new Properties(); props.put("metadata.broker.list", brokerList); props.put("producer.type", "async"); props.put("request.required.acks", "1"); props.put("request.timeout.ms", "30000"); log.debug("Broker list: " + brokerList); Producer producer = null; try { producer = createProducer(props); for (byte[] message : monitorSet) { for (int i = 0; i < NUM_TRIES_PUBLISH_COUNTS; i++) { try { KeyedMessage keyedMessage = new KeyedMessage("TrackingMonitoringEvent", message); producer.send(keyedMessage); break; } catch (Exception e) { log.error("Publishing count for topic " + topic + " to " + brokerList.toString() + " has failed " + (i + 1) + " times. " + (NUM_TRIES_PUBLISH_COUNTS - i - 1) + " more attempts will be made."); if (i == NUM_TRIES_PUBLISH_COUNTS - 1) { throw new RuntimeException(e.getMessage() + ": " + "Have retried maximum (" + NUM_TRIES_PUBLISH_COUNTS + ") times."); } try { Thread.sleep((long) (Math.random() * (i + 1) * 1000)); } catch (InterruptedException e1) { log.error("Caught interrupted exception between retries of publishing counts to Kafka. " + e1.getMessage()); } } } } } catch (Exception e) { throw new RuntimeException("failed to publish counts to kafka: " + e.getMessage(), e); } finally { if (producer != null) { producer.close(); } } }
Source:
<code>public int getNextMessageId() { <START> return currentMID.getAndIncrement() % TOTAL_NO_OF_MIDS; <END> }</code><technical_language>This works currentMID exceed Integer.MAX_VALUE, negative (MIN_VALUE). modulo of this negative number negative too. is happen currentMID | NextMessageID ---------------------------- 2147483644 | 65532 2147483645 | 65533 2147483646 | 65534 2147483647 | 65535 -2147483648 | 0 -2147483647 | -65535 -2147483646 | -65534 -2147483645 | -65533 do : java if (currentMID.get() + 1 >= TOTAL_NB_OF_MIDS) { currentMID.set(0); } else { currentMID.incrementAndGet(); } } do a modulo in constructor</technical_language>

Target:
public int getNextMessageId() { return currentMID.getAndIncrement() & 0x0000FFFF; }
Source:
<code>public JSONObject toJASON() throws JSONException { <START> JSONObject rv = new JSONObject(); <END> rv.put("type", type.ordinal()); rv.put("inputVal", inputVal); rv.put("autoChar", autoChar); rv.put("customChar", customChar); return rv; }</code><technical_language>final JSONObject rv =</technical_language>

Target:
public JSONObject toJASON() throws JSONException { final JSONObject rv = new JSONObject(); rv.put("type", type.ordinal()); rv.put("inputVal", inputVal); rv.put("autoChar", autoChar); rv.put("customChar", customChar); return rv; }
Source:
<code>public void stopWorkers() throws Exception { if (mWorkers == null) { return; } for (WorkerProcess worker : mWorkers) { worker.stop(); } for (Thread thread : mWorkerThreads) { while (thread.isAlive()) { LOG.info("Stopping thread {}.", thread.getName()); thread.interrupt(); thread.join(1000); } } mWorkerThreads.clear(); DefaultBlockMaster bm = (DefaultBlockMaster) getLocalAlluxioMaster().getMasterProcess() .getMaster(BlockMaster.class); <START> bm.forgetAllWorkers(); <END> }</code><technical_language>check if master is started here/getMasterProcess() returns null? I check method signature I I vaguely remember</technical_language>

Target:
public void stopWorkers() throws Exception { if (mWorkers == null) { return; } for (WorkerProcess worker : mWorkers) { worker.stop(); } for (Thread thread : mWorkerThreads) { while (thread.isAlive()) { LOG.info("Stopping thread {}.", thread.getName()); thread.interrupt(); thread.join(1000); } } mWorkerThreads.clear(); LocalAlluxioMaster master = getLocalAlluxioMaster(); if (master != null) { DefaultBlockMaster bm = (DefaultBlockMaster) master.getMasterProcess().getMaster(BlockMaster.class); bm.forgetAllWorkers(); } }
Source:
<code><START> public static void notifyOutputAuthSuccessful(HttpMessage msg) { <END> try { Stats.incCounter(SessionStructure.getHostName(msg), AUTH_SUCCESS_STATS); } catch (URIException e) { } if (View.isInitialised()) { View.getSingleton().getOutputPanel() .append(Constant.messages.getString("authentication.output.success") + "\n"); } }</code><technical_language>This breaks binary compatibility, next main release is expected binary compatible "old method" deprecated instead</technical_language>

Target:
public static void notifyOutputAuthSuccessful(HttpMessage msg) { if (msg != null) { try { Stats.incCounter(SessionStructure.getHostName(msg), AUTH_SUCCESS_STATS); } catch (URIException e) { } } if (View.isInitialised()) { View.getSingleton().getOutputPanel() .append(Constant.messages.getString("authentication.output.success") + "\n"); } }
Source:
<code>private void highlightActiveMenuItem() { for (int id : ACTION_ITEMS_ALL) { page.getNavDrawer().getMenu().findItem(id).setCheckable(true) <START> .setChecked(false); <END> } int highlightItem = -1; if (page.getTopFragment() instanceof HistoryFragment) { highlightItem = R.id.nav_item_history; } else if (page.getTopFragment() instanceof SavedPagesFragment) { highlightItem = R.id.nav_item_saved_pages; } else if (page.getTopFragment() instanceof NearbyFragment) { highlightItem = R.id.nav_item_nearby; } else if (page.getTopFragment() instanceof PageViewFragmentInternal) { PageViewFragmentInternal fragment = (PageViewFragmentInternal) page.getTopFragment(); if (fragment.getHistoryEntry() != null) { if (fragment.getHistoryEntry().getSource() == HistoryEntry.SOURCE_MAIN_PAGE) { highlightItem = R.id.nav_item_today; } else if (fragment.getHistoryEntry().getSource() == HistoryEntry.SOURCE_RANDOM) { highlightItem = R.id.nav_item_random; } } } if (highlightItem != -1) { page.getNavDrawer().getMenu().findItem(highlightItem).setChecked(true); } }</code><technical_language>longer necessary, changes in xml</technical_language>

Target:
private void highlightActiveMenuItem() { int test = page.getNavDrawer().getMenu().size(); for (int i = 0; i < test; i++) { page.getNavDrawer().getMenu().getItem(i).setChecked(false); } @IdRes int highlightItem = View.NO_ID; if (page.getTopFragment() instanceof HistoryFragment) { highlightItem = R.id.nav_item_history; } else if (page.getTopFragment() instanceof SavedPagesFragment) { highlightItem = R.id.nav_item_saved_pages; } else if (page.getTopFragment() instanceof NearbyFragment) { highlightItem = R.id.nav_item_nearby; } else if (page.getTopFragment() instanceof PageViewFragmentInternal) { PageViewFragmentInternal fragment = (PageViewFragmentInternal) page.getTopFragment(); if (fragment.getHistoryEntry() != null) { if (fragment.getHistoryEntry().getSource() == HistoryEntry.SOURCE_MAIN_PAGE) { highlightItem = R.id.nav_item_today; } else if (fragment.getHistoryEntry().getSource() == HistoryEntry.SOURCE_RANDOM) { highlightItem = R.id.nav_item_random; } } } if (highlightItem != View.NO_ID) { page.getNavDrawer().getMenu().findItem(highlightItem).setChecked(true); } }
Source:
<code>public void testTypeUseWithList() { Foo foo = new Foo(); foo.names = Arrays.asList( "First", "", null ); Set<ConstraintViolation<Foo>> constraintViolations = validator.validate( foo ); assertNumberOfViolations( constraintViolations, 3 ); <START> assertCorrectPropertyPaths( constraintViolations, "names[1]", "names[2]", "names[2]" ); <END> }</code><technical_language>I blind, violations expected for names[2]? I if added assertCorrectConstraintTypes()</technical_language>

Target:
public void testTypeUseWithList() { A a = new A(); a.names = Arrays.asList( "First", "", null ); Set<ConstraintViolation<A>> constraintViolations = validator.validate( a ); assertNumberOfViolations( constraintViolations, 3 ); assertCorrectPropertyPaths( constraintViolations, "names[1]", "names[2]", "names[2]" ); assertCorrectConstraintTypes( constraintViolations, NotBlankTypeUse.class, NotBlankTypeUse.class, NotNullTypeUse.class ); }
Source:
<code>public void testMultipleEarlyNegotiationWithShortInterval() throws InterruptedException { final int nbApplicativeRequestReceived = applicativeLayerGetRequestCount.get(); testGetRequestWithEarlyNegotiation(false, PARAM_SHORT_RESP); testGetRequestWithEarlyNegotiation(false, PARAM_SHORT_RESP); <START> assertEquals("Applicative layer received only one request", 2, applicativeLayerGetRequestCount.get() - nbApplicativeRequestReceived); <END> }</code><technical_language>I prefer a implementation, calls applicativeLayerGetRequestCount.set(0); in @Afterinstead of calculation</technical_language>

Target:
public void testMultipleEarlyNegotiationWithShortInterval() throws InterruptedException { testGetRequestWithEarlyNegotiation(false, PARAM_SHORT_RESP); testGetRequestWithEarlyNegotiation(false, PARAM_SHORT_RESP); assertEquals("Application layer did not receive two requests", 2, applicationLayerGetRequestCount.get()); }
Source:
<code><START> public void reinitializeCharts() { <END> if (getGlobalPC() != null && !getGlobalPC().isDisposed()) { getGlobalPC().dispose(); } fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); if (getTimeRangePC() != null && !getTimeRangePC().isDisposed()) { getTimeRangePC().dispose(); fTimeRangePC = null; } layout(); setCurrentState(new PieChartViewerStateNoContentSelected(this)); }</code><technical_language>needs synchronized</technical_language>

Target:
synchronized public void reinitializeCharts() { if(isDisposed()){ return; } if (getGlobalPC() != null && !getGlobalPC().isDisposed()) { getGlobalPC().dispose(); } fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); if (getTimeRangePC() != null && !getTimeRangePC().isDisposed()) { getTimeRangePC().dispose(); fTimeRangePC = null; } layout(); setCurrentState(new PieChartViewerStateNoContentSelected(this)); }
Source:
<code>private void sendConsentViaSMS(Study study, Subpopulation subpop, StudyParticipant participant, ConsentPdf consentPdf) { String shortUrl = null; try { String fileName = getSignedConsentUrl(); DateTime expiresOn = getDownloadExpiration(); s3Helper.writeBytesToS3(USERSIGNED_CONSENTS_BUCKET, fileName, consentPdf.getBytes()); URL url = s3Helper.generatePresignedUrl(USERSIGNED_CONSENTS_BUCKET, fileName, expiresOn, HttpMethod.GET); shortUrl = urlShortenerService.shortenUrl(url.toString(), SIGNED_CONSENT_DOWNLOAD_EXPIRE_IN_SECONDS); } catch(IOException e) { throw new BridgeServiceException(e); } SmsMessageProvider provider = new SmsMessageProvider.Builder() .withStudy(study) .withPhone(participant.getPhone()) .withExpirationPeriod(EXPIRATION_PERIOD_KEY, SIGNED_CONSENT_DOWNLOAD_EXPIRE_IN_SECONDS) <START> .withPromotionType() <END> .withSmsTemplate(study.getSignedConsentSmsTemplate()) .withToken(BridgeConstants.CONSENT_URL, shortUrl) .build(); notificationsService.sendSmsMessage(provider); }</code><technical_language>This Transactional, this is a Governance requirement</technical_language>

Target:
private void sendConsentViaSMS(Study study, Subpopulation subpop, StudyParticipant participant, ConsentPdf consentPdf) { String shortUrl = null; try { String fileName = getSignedConsentUrl(); DateTime expiresOn = getDownloadExpiration(); s3Helper.writeBytesToS3(USERSIGNED_CONSENTS_BUCKET, fileName, consentPdf.getBytes()); URL url = s3Helper.generatePresignedUrl(USERSIGNED_CONSENTS_BUCKET, fileName, expiresOn, HttpMethod.GET); shortUrl = urlShortenerService.shortenUrl(url.toString(), SIGNED_CONSENT_DOWNLOAD_EXPIRE_IN_SECONDS); } catch(IOException e) { throw new BridgeServiceException(e); } SmsMessageProvider provider = new SmsMessageProvider.Builder() .withStudy(study) .withPhone(participant.getPhone()) .withExpirationPeriod(EXPIRATION_PERIOD_KEY, SIGNED_CONSENT_DOWNLOAD_EXPIRE_IN_SECONDS) .withTransactionType() .withSmsTemplate(study.getSignedConsentSmsTemplate()) .withToken(BridgeConstants.CONSENT_URL, shortUrl) .build(); notificationsService.sendSmsMessage(provider); }
Source:
<code>public Flowable<K> publishKeys(Predicate<? super K> filter) { return Flowable.fromIterable(() -> { List<K> keys = new ArrayList<>(entries.size()); long now = ctx.getTimeService().wallClockTime(); synchronized (entries) { for (Map.Entry<K, FileEntry> e : entries.entrySet()) { K key = e.getKey(); <START> if ((filter == null || filter.test(key)) && !e.getValue().isExpired(now)) { <END> keys.add(key); } } } return keys.iterator(); }); }</code><technical_language>put isExpired(now) check first, if filter out a lot of entries cheap</technical_language>

Target:
public Flowable<K> publishKeys(Predicate<? super K> filter) { return Flowable.fromIterable(() -> { List<K> keys = new ArrayList<>(entries.size()); long now = ctx.getTimeService().wallClockTime(); synchronized (entries) { for (Map.Entry<K, FileEntry> e : entries.entrySet()) { K key = e.getKey(); if (!e.getValue().isExpired(now) && (filter == null || filter.test(key))) { keys.add(key); } } } return keys.iterator(); }); }
Source:
<code>private void init() { this.navigate = new Navigate(); <START> this.cc = new CuratedMainPagePageObject(); <END> this.curatedContent = new CuratedContentPageObject(); this.loading = new Loading(driver); }</code><technical_language>give name this variable? is meaningless</technical_language>

Target:
private void init() { this.navigate = new Navigate(); this.curatedMainPage = new CuratedMainPagePageObject(); this.curatedContent = new CuratedContentPageObject(); this.loading = new Loading(driver); }
Source:
<code>private String getParameters() { Map<String, String> params = new HashMap<>(parameters); System.getProperties() .stringPropertyNames() .stream() <START> .filter(k -> k.startsWith("reporter.")) <END> .forEach(k -> { if (System.getProperty(k) != null) { params.put(k, System.getProperty(k)); } }); StringBuilder param = new StringBuilder(); if (!params.isEmpty()) { param.append(";parameters='"); } params.entrySet() .forEach(e -> { param.append(e.getKey() + "=" + e.getValue() + ","); }); if (!params.isEmpty()) { param.deleteCharAt(param.length() - 1); param.append("'"); } return param.toString(); }</code><technical_language>"bnd.reporter." "bnd.reporter.skip" parameter. in ExportReportCommand description</technical_language>

Target:
private String getParameters() { Map<String, String> params = new HashMap<>(parameters); System.getProperties() .stringPropertyNames() .stream() .filter(k -> k.startsWith("bnd.reporter.")) .forEach(k -> { if (System.getProperty(k) != null) { params.put(k, System.getProperty(k)); } }); StringBuilder param = new StringBuilder(); if (!params.isEmpty()) { param.append(";parameters='"); } params.entrySet() .forEach(e -> { param.append(e.getKey() + "=" + e.getValue() + ","); }); if (!params.isEmpty()) { param.deleteCharAt(param.length() - 1); param.append("'"); } return param.toString(); }
Source:
<code><START> public Integer getZkConnectionTimeoutMs() <END> { return zkConnectionTimeoutMs; }</code><technical_language>Integer int</technical_language>

Target:
public int getZkConnectionTimeoutMs() { return zkConnectionTimeoutMs; }
Source:
<code>protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) { DataPolicy resolvedDataPolicy = new DataPolicyConverter().convert(dataPolicy); <START> Assert.isTrue(resolvedDataPolicy != null || (resolvedDataPolicy == null && !StringUtils.hasText(dataPolicy)), <END> String.format("Data Policy '%1$s' is invalid.", dataPolicy)); if (resolvedDataPolicy == null || DataPolicy.NORMAL.equals(resolvedDataPolicy)) { regionFactory.setDataPolicy(isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.NORMAL); } else if (DataPolicy.PRELOADED.equals(resolvedDataPolicy)) { regionFactory.setDataPolicy(isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.PRELOADED); } else { throw new IllegalArgumentException(String.format("Data Policy '%1$s' is not supported in Local Regions.", dataPolicy)); } }</code><technical_language>This simplified Assert.isTrue(resolvedDataPolicy != null || !StringUtils.hasText(dataPolicy),..</technical_language>

Target:
protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) { DataPolicy resolvedDataPolicy = new DataPolicyConverter().convert(dataPolicy); Assert.isTrue(resolvedDataPolicy != null || !StringUtils.hasText(dataPolicy), String.format("Data Policy '%1$s' is invalid.", dataPolicy)); if (resolvedDataPolicy == null || DataPolicy.NORMAL.equals(resolvedDataPolicy)) { regionFactory.setDataPolicy(isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.NORMAL); } else if (DataPolicy.PRELOADED.equals(resolvedDataPolicy)) { regionFactory.setDataPolicy(isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.PRELOADED); } else { throw new IllegalArgumentException(String.format("Data Policy '%1$s' is not supported in Local Regions.", dataPolicy)); } }
Source:
<code>protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options, final String classname, final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname); <START> options.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue().isEmpty()); <END> final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class); if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) { scopes.add(IteratorScope.minc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) { scopes.add(IteratorScope.majc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) { scopes.add(IteratorScope.scan); } if (scopes.isEmpty()) { throw new IllegalArgumentException("You must select at least one scope to configure"); } final IteratorSetting setting = new IteratorSetting(priority, name, classname, options); shellState.getAccumuloClient().tableOperations().attachIterator(tableName, setting, scopes); }</code><technical_language>this values</technical_language>

Target:
protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options, final String classname, final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname); options.values().removeIf(v -> v == null || v.isEmpty()); final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class); if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) { scopes.add(IteratorScope.minc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) { scopes.add(IteratorScope.majc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) { scopes.add(IteratorScope.scan); } if (scopes.isEmpty()) { throw new IllegalArgumentException("You must select at least one scope to configure"); } final IteratorSetting setting = new IteratorSetting(priority, name, classname, options); shellState.getAccumuloClient().tableOperations().attachIterator(tableName, setting, scopes); }
Source:
<code>public boolean isInflateInsideIf() { if (this.viewAssignmentStatement != null) { if (getFirstAncestorOrNull(this.viewAssignmentStatement, IfStatement.class) != null) { return true; <START> } else if (getFirstAncestorOrNull(this.viewAssignmentStatement, SwitchStatement.class) != null) { <END> return true; } else { Expression inflateExpression = this.getInflateExpression(); if (inflateExpression != null && inflateExpression.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION) { return true; } } } return false; }</code><technical_language>in this file please getAncestor() instead of getFirstAncestorOrNull() possible. getFirstAncestorOrNull() is designed for multiple values types</technical_language>

Target:
public boolean isInflateInsideIf() { if (this.viewAssignmentStmt != null) { Expression inflateExpr = getInflateExpr(); return getFirstAncestorOrNull(this.viewAssignmentStmt, IfStatement.class, SwitchStatement.class) != null || (inflateExpr != null && inflateExpr.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION); } return false; }
Source:
<code>void shouldNotUpdateCharge_IfEpdqStatusIs6AndChargeStatusIsNotPresent() { final String payload = notificationPayloadForTransaction(payId, EPDQ_AUTHORISED_CANCELLED); charge = getCharge(false); setUpGatewayAccountToReturnGatewayAccountEntity(Optional.of(gatewayAccountEntity)); setUpChargeServiceToReturnCharge(Optional.of(charge)); <START> final boolean result = notificationService.handleNotificationFor(payload, FORWARDED_IP_ADDRESSES); assertTrue(result); <END> verifyNoInteractions(mockChargeNotificationProcessor); }</code><technical_language>inlined</technical_language>

Target:
void shouldNotUpdateCharge_IfEpdqStatusIs6AndChargeStatusIsNotPresent() { final String payload = notificationPayloadForTransaction(payId, EPDQ_AUTHORISED_CANCELLED); charge = getCharge(false); setUpGatewayAccountToReturnGatewayAccountEntity(Optional.of(gatewayAccountEntity)); setUpChargeServiceToReturnCharge(Optional.of(charge)); assertTrue(notificationService.handleNotificationFor(payload, FORWARDED_IP_ADDRESSES)); verifyNoInteractions(mockChargeNotificationProcessor); }
Source:
<code><START> private static <D, T, S> double[] calculateLogForwardProbabilities( <END> final HiddenMarkovModel<D, T, S> model, final List<D> data, final List<T> positions) { final List<S> states = model.hiddenStates(); final int width = states.size(); final int length = data.size(); final double[] result = new double[width * length]; if (length == 0) { return result; } final T position0 = positions.get(0); final D datum0 = data.get(0); for (int s = 0; s < states.size(); s++) { final S state = states.get(s); result[s] = model.logPriorProbability(state, position0) + model.logEmissionProbability(datum0, state, position0); } final double[] logSumBuffer = new double[states.size()]; for (int u = 1; u < data.size(); u++) { final int t = u - 1; final int tOffset = width * t; final int uOffset = tOffset + width; final T positionT = positions.get(t); final T positionU = positions.get(u); for (int sU = 0; sU < width; sU++) { final S stateU = states.get(sU); for (int sT = 0; sT < width; sT++) { logSumBuffer[sT] = result[sT + tOffset] + model.logTransitionProbability(states.get(sT), positionT, stateU, positionU); } result[sU + uOffset] = MathUtils.approximateLogSumLog(logSumBuffer) + model.logEmissionProbability(data.get(u), stateU, positionU); } } return result; }</code><technical_language>probabilities probabilities in code</technical_language>

Target:
private static <D, T, S> double[][] calculateLogForwardProbabilities( final HiddenMarkovModel<D, T, S> model, final List<D> data, final List<T> positions) { final List<S> states = model.hiddenStates(); final int numStates = states.size(); final int length = data.size(); final double[][] result = new double[length][numStates]; if (length == 0) { return result; } final T position0 = positions.get(0); final D datum0 = data.get(0); for (int stateIndex = 0; stateIndex < states.size(); stateIndex++) { final S state = states.get(stateIndex); result[0][stateIndex] = model.logPriorProbability(state, position0) + model.logEmissionProbability(datum0, state, position0); } final double[] logSumBuffer = new double[states.size()]; for (int thisPositionIndex = 1; thisPositionIndex < data.size(); thisPositionIndex++) { final int previousPositionIndex = thisPositionIndex - 1; final T previousPosition = positions.get(previousPositionIndex); final T thisPosition = positions.get(thisPositionIndex); for (int thisStateIndex = 0; thisStateIndex < numStates; thisStateIndex++) { final S thisState = states.get(thisStateIndex); for (int previousStateIndex = 0; previousStateIndex < numStates; previousStateIndex++) { logSumBuffer[previousStateIndex] = result[previousPositionIndex][previousStateIndex] + model.logTransitionProbability(states.get(previousStateIndex), previousPosition, thisState, thisPosition); } result[thisPositionIndex][thisStateIndex] = MathUtils.approximateLogSumLog(logSumBuffer) + model.logEmissionProbability(data.get(thisPositionIndex), thisState, thisPosition); } } return result; }
Source:
<code>public Schema(Class<?> cls, EntityDictionary entityDictionary) { this.entityClass = Objects.requireNonNull(cls, "cls"); this.entityDictionary = Objects.requireNonNull(entityDictionary, "entityDictionary"); <START> this.metrics = entityDictionary.getAllFields(getEntityClass()).stream() <END> .filter(this::isMetricField) .filter(field -> getEntityDictionary() .attributeOrRelationAnnotationExists(entityClass, field, MetricAggregation.class) ) .map(field -> constructMetric(field, getEntityClass(), entityDictionary)) .collect( Collectors.collectingAndThen( Collectors.toSet(), Collections::unmodifiableSet ) ); this.dimensions = getEntityDictionary().getAllFields(getEntityClass()).stream() .filter(field -> !isMetricField(field)) .map(field -> constructDimension(field, getEntityClass(), getEntityDictionary())) .collect( Collectors.collectingAndThen( Collectors.toSet(), Collections::unmodifiableSet ) ); this.columns = Stream.concat( getDimensions().stream().map(dimension -> (Column) dimension), getMetrics().stream().map(metric -> (Column) metric) ).collect(Collectors.toSet()); }</code><technical_language>I preferred methods getAllMetrics getAllDimensions. BetterCodeHub ding this for complexity number of lines</technical_language>

Target:
public Schema(Class<?> cls, EntityDictionary entityDictionary) { this.entityClass = Objects.requireNonNull(cls, "cls"); this.entityDictionary = Objects.requireNonNull(entityDictionary, "entityDictionary"); this.metrics = getAllMetrics(); this.dimensions = getAllDimensions(); }