本文整理汇总了Java中org.eclipse.collections.impl.utility.Iterate类的典型用法代码示例。如果您正苦于以下问题:Java Iterate类的具体用法?Java Iterate怎么用?Java Iterate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Iterate类属于org.eclipse.collections.impl.utility包,在下文中一共展示了Iterate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assist
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
public List<Object> assist(String levelName, InvestigationLevel nextLevel, int drilldownLimit)
{
Twin<VerifiableTable> queryResults = execute(nextLevel);
VerifiableTable actualResults = new KeyedVerifiableTableAdapter(queryResults.getOne(), queryResults.getOne().getColumnCount() - 1);
VerifiableTable expectedResults = new KeyedVerifiableTableAdapter(queryResults.getTwo(), queryResults.getTwo().getColumnCount() - 1);
List<String> actualColumns = getColumns(actualResults);
List<String> expectedColumns = getColumns(expectedResults);
if (!Iterate.getLast(actualColumns).equals(Iterate.getLast(expectedColumns)))
{
throw new IllegalArgumentException(String.format("Key columns must match at each investigation level [actual: %s, expected: %s]", Iterate.getLast(actualColumns), Iterate.getLast(expectedColumns)));
}
Set<String> commonColumns = UnifiedSet.newSet(actualColumns);
commonColumns.retainAll(expectedColumns);
if (Math.min(actualColumns.size(), expectedColumns.size()) > 1 && commonColumns.size() < 2)
{
throw new IllegalArgumentException(String.format("There must be at least 2 matching columns at each investigation level [actual: %s, expected: %s]", Iterate.getLast(actualColumns), Iterate.getLast(expectedColumns)));
}
String levelDescription = nextLevel.getLevelDescription();
ResultTable results = this.findBreaks(levelDescription, actualResults, expectedResults);
HtmlFormatter htmlFormatter = new HtmlFormatter(outputFile, new HtmlOptions(false, HtmlFormatter.DEFAULT_ROW_LIMIT, false, true, false, Collections.<String>emptySet()));
htmlFormatter.appendResults(levelName, Maps.fixedSize.of(levelDescription, results), Metadata.newEmpty());
return getRowKeys(results, drilldownLimit);
}
示例2: getRowKeys
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
private List<Object> getRowKeys(ResultTable results, int drilldownLimit)
{
List<Object> rowKeys = FastList.newList();
List<List<ResultCell>> table = results.getVerifiedRows();
int rowIndex = 1;
while (rowIndex < table.size() && rowKeys.size() < drilldownLimit)
{
List<ResultCell> values = table.get(rowIndex);
int passedCount = Iterate.count(values, ResultCell.IS_PASSED_CELL);
int failedCount = Iterate.count(values, ResultCell.IS_FAILED_CELL);
if (passedCount == 0 || failedCount > 0)
{
ResultCell cell = Iterate.getLast(values);
rowKeys.add(cell.getActual() == null ? cell.getExpected() : cell.getActual());
}
rowIndex++;
}
return rowKeys;
}
示例3: handle
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
public void handle(Investigation investigation, File outputFile)
{
Watson watson = new Watson(outputFile);
InvestigationLevel currentLevel = investigation.getFirstLevel();
List<Object> drilldownKeys = watson.assist("Initial Results", currentLevel, investigation.getRowKeyLimit());
if (Iterate.isEmpty(drilldownKeys))
{
LOGGER.info("No breaks found :)");
return;
}
LOGGER.info("Got " + drilldownKeys.size() + " broken drilldown keys - " + outputFile);
int level = 1;
while (!drilldownKeys.isEmpty() && (currentLevel = investigation.getNextLevel(drilldownKeys)) != null)
{
drilldownKeys = watson.assist("Investigation Level " + level + " (Top " + investigation.getRowKeyLimit() + ')', currentLevel, investigation.getRowKeyLimit());
LOGGER.info("Got " + drilldownKeys.size() + " broken drilldown keys - " + outputFile);
level++;
}
String message = "Some tests failed. Check test results file " + outputFile.getAbsolutePath() + " for more details.";
throw new AssertionError(message);
}
示例4: shuffleAndDealHands
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void shuffleAndDealHands()
{
List<Set<Card>> jdkHands = this.jdkDeck.shuffleAndDeal(new Random(1), 5, 5);
Assert.assertEquals(5, jdkHands.size());
Assert.assertTrue(Iterate.allSatisfy(jdkHands, each -> each.size() == 5));
}
示例5: dealHands
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void dealHands()
{
Deque<Card> jdkShuffled = this.jdkDeck.shuffle(new Random(1));
List<Set<Card>> jdkHands = this.jdkDeck.dealHands(jdkShuffled, 5, 5);
Assert.assertEquals(5, jdkHands.size());
Assert.assertTrue(Iterate.allSatisfy(jdkHands, each -> each.size() == 5));
Assert.assertEquals(27, jdkShuffled.size());
}
示例6: findBreaks
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
private ResultTable findBreaks(String tableName, VerifiableTable actual, VerifiableTable expected)
{
Map<String, VerifiableTable> actualVerifiableTableResults = Maps.fixedSize.of(tableName, actual);
Map<String, VerifiableTable> expectedVerifiableTableResults = Maps.fixedSize.of(tableName, expected);
Map<String, ResultTable> verifyTables = this.multiTableVerifier.verifyTables(expectedVerifiableTableResults, actualVerifiableTableResults);
return Iterate.getOnly(verifyTables.values());
}
示例7: match
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public void match(MutableList<UnmatchedIndexMap> allMissingRows, MutableList<UnmatchedIndexMap> allSurplusRows, MutableList<IndexMap> matchedColumns)
{
List<IndexMap> keyColumnIndices = this.getKeyColumnIndexMaps(matchedColumns);
if (keyColumnIndices.isEmpty())
{
LOGGER.warn("No key columns found!");
return;
}
MutableMap<RowView, MutableList<UnmatchedIndexMap>> missingByKey = UnifiedMap.newMap(allMissingRows.size());
for (UnmatchedIndexMap expected : allMissingRows)
{
ExpectedRowView expectedRowView = new ExpectedRowView(this.expectedData, keyColumnIndices, this.columnComparators, expected.getExpectedIndex());
missingByKey.getIfAbsentPut(expectedRowView, NEW_LIST).add(expected);
}
MutableMap<RowView, MutableList<UnmatchedIndexMap>> surplusByKey = UnifiedMap.newMap(allSurplusRows.size());
for (UnmatchedIndexMap actual : allSurplusRows)
{
ActualRowView actualRowView = new ActualRowView(this.actualData, keyColumnIndices, this.columnComparators, actual.getActualIndex());
surplusByKey.getIfAbsentPut(actualRowView, NEW_LIST).add(actual);
}
for (RowView rowView : missingByKey.keysView())
{
MutableList<UnmatchedIndexMap> missing = missingByKey.get(rowView);
MutableList<UnmatchedIndexMap> surplus = surplusByKey.get(rowView);
if (Iterate.notEmpty(missing) && Iterate.notEmpty(surplus))
{
this.keyGroupPartialMatcher.match(missing, surplus, matchedColumns);
}
}
}
示例8: appendTo
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public void appendTo(final String testName, final String tableName, final Element table, final HtmlOptions htmlOptions)
{
HtmlFormatter.appendHeaderRow(table, this, htmlOptions);
Iterate.forEachWithIndex(this.getResultsByKey().keySet(), new ObjectIntProcedure<String>()
{
@Override
public void value(String key, int index)
{
SummaryResult summaryResult = getResultsByKey().get(key);
HtmlFormatter.appendSpanningRow(table, SummaryResultTable.this, "blank_row", null, null);
for (List<ResultCell> resultCells : summaryResult.getFirstFewRows())
{
HtmlFormatter.appendDataRow(table, SummaryResultTable.this, null, null, resultCells, htmlOptions);
}
int remainingRows = summaryResult.getRemainingRowCount();
if (remainingRows > 0)
{
String summaryRowId = HtmlFormatter.toHtmlId(testName, tableName) + ".summaryRow" + index;
String summaryText;
if ("0".equals(key))
{
summaryText = ResultCell.adaptOnCount(remainingRows, " more matched row");
}
else
{
summaryText = ResultCell.adaptOnCount(remainingRows, " more break") + " like this";
}
HtmlFormatter.appendSpanningRow(table, SummaryResultTable.this, "summary", NumberFormat.getInstance().format(remainingRows) + summaryText + "...", "toggleVisibility('" + summaryRowId + "')");
HtmlFormatter.appendDataRow(table, SummaryResultTable.this, summaryRowId, "display:none", summaryResult.getSummaryCardinalityRow(), htmlOptions);
}
}
});
}
示例9: parse
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
if (this.sectionName == null)
{
throw new ParseException("no section name found before line " + st.lineno(), st.lineno());
}
// parse the data
int currentAttribute = 0;
int token = st.ttype;
boolean wantData = true;
List<Object> rowValue = FastList.newList();
while (token != StreamTokenizer.TT_EOL && token != StreamTokenizer.TT_EOF)
{
if (wantData)
{
this.getParser().getExpectedTable().parseData(st, currentAttribute, rowValue);
currentAttribute++;
}
else
{
if (token != ',')
{
throw new ParseException("Expected a comma on line " + st.lineno(), st.lineno());
}
}
wantData = !wantData;
token = st.nextToken();
}
if (Iterate.notEmpty(rowValue))
{
this.getParser().getExpectedTable().addRowToList(rowValue);
}
return this.getParser().getBeginningOfLineState();
}
示例10: getValue
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
* Refactor to use {@link org.eclipse.collections.api.RichIterable#sumOfDouble(DoubleFunction)}.
*/
public double getValue()
{
Collection<Double> itemValues = Iterate.collect(this.lineItems, LineItem::getValue);
return CollectionAdapter.adapt(itemValues).injectInto(0.0, AddFunction.DOUBLE_TO_DOUBLE);
}
示例11: filterOrders
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
* Same exercise but don't use static utility - refactor the type of orders and {@link Customer#getOrders()}
* instead.
* Get the actual orders (not their double values) where those orders have a value greater than 2.0.
*/
@Test
public void filterOrders()
{
List<Order> orders = this.company.getMostRecentCustomer().getOrders();
MutableList<Order> filtered = null;
Assert.assertEquals(Lists.mutable.with(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);
Verify.assertInstanceOf(MutableList.class, this.company.getMostRecentCustomer().getOrders());
this.company.getMostRecentCustomer().getOrders().add(null);
Verify.assertContains("Don't return a copy from Customer.getOrders(). The field should be a MutableList.", null, this.company.getMostRecentCustomer().getOrders());
}
示例12: filterOrders
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
* Get the actual orders (not their double values) where those orders have a value greater than 2.0.
*/
@Test
public void filterOrders()
{
List<Order> orders = this.company.getMostRecentCustomer().getOrders();
MutableList<Order> filtered = null;
Assert.assertEquals(Lists.mutable.with(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);
}
示例13: diamonds
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void diamonds()
{
Assert.assertEquals(13, this.jdkDeck.diamonds().size());
Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.diamonds(), Card::isDiamonds));
}
示例14: hearts
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void hearts()
{
Assert.assertEquals(13, this.jdkDeck.hearts().size());
Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.hearts(), Card::isHearts));
}
示例15: spades
import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void spades()
{
Assert.assertEquals(13, this.jdkDeck.spades().size());
Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.spades(), Card::isSpades));
}