当前位置: 首页>>代码示例>>Java>>正文


Java MutableList.select方法代码示例

本文整理汇总了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);
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:26,代码来源:EclipseCollectionsFunctionalInterfaceTest.java

示例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);
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:26,代码来源:EclipseCollectionsFunctionalInterfaceTest.java

示例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;
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:32,代码来源:MsSqlDomainSqlTranslator.java

示例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();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:58,代码来源:DbDirectoryChangesetReader.java

示例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;
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:62,代码来源:AbstractDdlReveng.java


注:本文中的org.eclipse.collections.api.list.MutableList.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。