本文整理汇总了Java中org.eclipse.collections.api.list.MutableList.select方法的典型用法代码示例。如果您正苦于以下问题:Java MutableList.select方法的具体用法?Java MutableList.select怎么用?Java MutableList.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.collections.api.list.MutableList
的用法示例。
在下文中一共展示了MutableList.select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predicateIsEven
import org.eclipse.collections.api.list.MutableList; //导入方法依赖的package包/类
@Test
public void predicateIsEven()
{
MutableList<Integer> numbers = Interval.oneTo(10).toList();
// TODO - Convert the anonymous inner class to a lambda
Predicate<Integer> evenPredicate = new Predicate<Integer>()
{
@Override
public boolean accept(Integer integer)
{
return integer % 2 == 0;
}
};
Assert.assertTrue(evenPredicate.test(2));
Assert.assertFalse(evenPredicate.test(1));
MutableList<Integer> evens = numbers.select(evenPredicate);
Assert.assertTrue(evens.allSatisfy(evenPredicate));
Assert.assertTrue(evens.stream().allMatch(evenPredicate));
Assert.assertFalse(evens.noneSatisfy(evenPredicate));
Assert.assertFalse(evens.stream().noneMatch(evenPredicate));
Assert.assertTrue(evens.anySatisfy(evenPredicate));
Assert.assertTrue(evens.stream().anyMatch(evenPredicate));
Assert.assertEquals(Interval.evensFromTo(1, 10), evens);
}
示例2: predicateIsOdd
import org.eclipse.collections.api.list.MutableList; //导入方法依赖的package包/类
@Test
public void predicateIsOdd()
{
MutableList<Integer> numbers = Interval.oneTo(10).toList();
// TODO - Convert the anonymous inner class to a lambda
Predicate<Integer> oddPredicate = new Predicate<Integer>()
{
@Override
public boolean accept(Integer integer)
{
return integer % 2 == 1;
}
};
Assert.assertFalse(oddPredicate.test(2));
Assert.assertTrue(oddPredicate.test(1));
MutableList<Integer> odds = numbers.select(oddPredicate);
Assert.assertTrue(odds.allSatisfy(oddPredicate));
Assert.assertTrue(odds.stream().allMatch(oddPredicate));
Assert.assertFalse(odds.noneSatisfy(oddPredicate));
Assert.assertFalse(odds.stream().noneMatch(oddPredicate));
Assert.assertTrue(odds.stream().anyMatch(oddPredicate));
Assert.assertTrue(odds.anySatisfy(oddPredicate));
Assert.assertEquals(Interval.oddsFromTo(1, 10), odds);
}
示例3: handleRawFullSql
import org.eclipse.collections.api.list.MutableList; //导入方法依赖的package包/类
@Override
public String handleRawFullSql(String sql, Change change) {
sql = CommentRemover.removeComments(sql, "sybase sp_addtype conversion").trim();
if (sql.startsWith("sp_addtype")) {
// all the params are in string literals, e.g. 'param'. Let's extract it out
MutableList<SqlToken> allParts = new SqlTokenParser().parseTokens(sql);
MutableList<SqlToken> parts = allParts.select(Predicates.attributeEqual(SqlToken.TO_TOKEN_TYPE,
SqlTokenType.STRING));
String domainName = null;
String domainType = null;
String domainProps = null;
for (int i = 0; i < parts.size(); i++) {
String part = this.stripAddTypeParam(parts.get(i).getText().trim());
if (i == 0) {
domainName = part;
} else if (i == 1) {
domainType = part;
} else if (i == 2) {
domainProps = part;
} else {
throw new IllegalArgumentException("Not expecting more than 3 args here, but got: " +
Arrays.asList(parts));
}
}
return this.createDomainSql(domainName, domainType, domainProps);
} else {
return sql;
}
}
示例4: readChanges
import org.eclipse.collections.api.list.MutableList; //导入方法依赖的package包/类
@Override
public ImmutableList<Change> readChanges(boolean useBaseline) {
MutableList<Change> allChanges = Lists.mutable.empty();
ImmutableSet<String> envSchemas = env.getSchemaNames().collect(this.convertDbObjectName);
for (FileObject sourceDir : env.getSourceDirs()) {
for (FileObject schemaDir : sourceDir.findFiles(new BasicFileSelector(and(vcsAware(), directory()), false))) {
String schema = schemaDir.getName().getBaseName();
if (envSchemas.contains(this.convertDbObjectName.valueOf(schema))) {
MutableList<Change> schemaChanges = Lists.mutable.empty();
for (ChangeType changeType : env.getPlatform().getChangeTypes()) {
FileObject changeTypeDir = this.findDirectoryForChangeType(schemaDir, changeType);
if (changeTypeDir != null) {
ImmutableList<Change> changes;
if (changeType.isRerunnable()) {
changes = findChanges(changeType, changeTypeDir, this.rerunnableChangeParser, TrueFileFilter.INSTANCE, schema);
} else {
changes = findTableChanges(changeType, changeTypeDir, schema, useBaseline);
}
schemaChanges.withAll(changes);
}
}
MutableCollection<Change> tableChanges = schemaChanges.select(
Predicates.attributeIn(Change.TO_CHANGE_TYPE_NAME, Sets.immutable.of(ChangeType.TABLE_STR, ChangeType.FOREIGN_KEY_STR)));
MutableMultimap<String, Change> tableChangeMap = tableChanges.groupBy(Change.TO_DB_OBJECT_KEY);
MutableCollection<Change> staticDataChanges = schemaChanges.select(Predicates.attributeEqual(Change.TO_CHANGE_TYPE_NAME, ChangeType.STATICDATA_STR));
// now enrich the staticData objects w/ the information from the tables to facilitate the
// deployment order calculation.
for (Change staticDataChange : staticDataChanges) {
MutableCollection<Change> relatedTableChanges = tableChangeMap.get(staticDataChange.getDbObjectKey());
MutableCollection<Change> foreignKeys = relatedTableChanges.select(
Predicates.attributeEqual(Change.TO_CHANGE_TYPE_NAME, ChangeType.FOREIGN_KEY_STR));
String fkContent = foreignKeys.collect(Change.TO_CONTENT).makeString("\n\n");
staticDataChange.setContentForDependencyCalculation(fkContent);
}
allChanges.addAll(schemaChanges);
} else {
LOG.info("Skipping schema directory [{}] as it was not defined among the schemas in your system-config.xml file: {}", schema, envSchemas);
continue;
}
}
}
return allChanges.selectWith(ArtifactRestrictions.apply(), env).toImmutable();
}
示例5: getSqlSnippets
import org.eclipse.collections.api.list.MutableList; //导入方法依赖的package包/类
private MutableList<String> getSqlSnippets(File file) {
final MutableList<String> dataLines;
dataLines = FileUtilsCobra.readLines(file);
dataLines.forEachWithIndex(new ObjectIntProcedure<String>() {
@Override
public void value(String line, int i) {
if (!line.isEmpty() && line.charAt(0) == '\uFEFF') {
dataLines.set(i, dataLines.get(i).substring(1));
}
if (line.startsWith("--------------------")
&& dataLines.get(i + 1).startsWith("-- DDL Statements")
&& dataLines.get(i + 2).startsWith("--------------------")) {
dataLines.set(i, "");
dataLines.set(i + 1, "");
dataLines.set(i + 2, "");
} else if (line.startsWith("--------------------")
&& dataLines.get(i + 2).startsWith("-- DDL Statements")
&& dataLines.get(i + 4).startsWith("--------------------")) {
dataLines.set(i, "");
dataLines.set(i + 1, "");
dataLines.set(i + 2, "");
dataLines.set(i + 3, "");
dataLines.set(i + 4, "");
} else if (line.startsWith("-- DDL Statements for ")) {
dataLines.set(i, "");
}
// For PostgreSQL
if ((line.equals("--")
&& dataLines.get(i + 1).startsWith("-- Name: ")
&& dataLines.get(i + 2).equals("--"))) {
dataLines.set(i, "");
dataLines.set(i + 1, "GO");
dataLines.set(i + 2, "");
}
}
});
MutableList<String> sqlSnippets;
if (stringSplitter != null) {
String data = dataLines
.reject(skipLinePredicates != null ? Predicates.or(skipLinePredicates) : (Predicate) Predicates.alwaysFalse())
.makeString(SystemUtils.LINE_SEPARATOR);
sqlSnippets = stringSplitter.valueOf(data);
} else {
// If null, then default each line to being its own parsable statement
sqlSnippets = dataLines
.reject(skipLinePredicates != null ? Predicates.or(skipLinePredicates) : (Predicate) Predicates.alwaysFalse());
}
sqlSnippets = sqlSnippets.collect(new Function<String, String>() {
@Override
public String valueOf(String sqlSnippet) {
return StringUtils.stripStart(sqlSnippet, "\r\n \t");
}
});
sqlSnippets = sqlSnippets.select(StringPredicates.notBlank().and(Predicates.noneOf(skipPredicates)));
return sqlSnippets;
}