public void sort() { factMappingValues.sort((a, b) -> { Integer aIndex = simulationDescriptor.getIndexByIdentifier(a.getFactIdentifier(), a.getExpressionIdentifier()); Integer bIndex = simulationDescriptor.getIndexByIdentifier(b.getFactIdentifier(), b.getExpressionIdentifier()); return aIndex.compareTo(bIndex); }); }
public void sort() { factMappingValues.sort((a, b) -> { Integer aIndex = simulationDescriptor.getIndexByIdentifier(a.getFactIdentifier(), a.getExpressionIdentifier()); Integer bIndex = simulationDescriptor.getIndexByIdentifier(b.getFactIdentifier(), b.getExpressionIdentifier()); return aIndex.compareTo(bIndex); }); }
@Test public void getIndexByIdentifierTest() { List<FactMapping> originalFactMappings = IntStream.range(0, 2).boxed() .map(i -> simulationDescriptor .addFactMapping(FactIdentifier.create("test " + i, String.class.getCanonicalName()), this.expressionIdentifier) ).collect(Collectors.toList()); int indexToCheck = 0; int indexRetrieved = simulationDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); indexToCheck = 1; indexRetrieved = simulationDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); }
@Test public void getIndexByIdentifierTest() { List<FactMapping> originalFactMappings = IntStream.range(0, 2).boxed() .map(i -> simulationDescriptor .addFactMapping(FactIdentifier.create("test " + i, String.class.getCanonicalName()), this.expressionIdentifier) ).collect(Collectors.toList()); int indexToCheck = 0; int indexRetrieved = simulationDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); indexToCheck = 1; indexRetrieved = simulationDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); }
/** * This method <i>insert</i> a row to the grid and populate it with values taken from given <code>Scenario</code> * @param row */ public void insertRowGridOnly(final int rowIndex, final GridRow row, final Scenario scenario) { checkSimulation(); super.insertRow(rowIndex, row); scenario.getUnmodifiableFactMappingValues().forEach(value -> { FactIdentifier factIdentifier = value.getFactIdentifier(); ExpressionIdentifier expressionIdentifier = value.getExpressionIdentifier(); if (value.getRawValue() == null || value.getRawValue() instanceof String) { // Let' put a placeholder String stringValue = (String) value.getRawValue(); int columnIndex = simulation.getSimulationDescriptor().getIndexByIdentifier(factIdentifier, expressionIdentifier); String placeHolder = ((ScenarioGridColumn) columns.get(columnIndex)).getPlaceHolder(); setCell(rowIndex, columnIndex, () -> new ScenarioGridCell(new ScenarioGridCellValue(stringValue, placeHolder))); } else { throw new UnsupportedOperationException("Only string is supported at the moment"); } }); updateIndexColumn(); }