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


Java ListIterable类代码示例

本文整理汇总了Java中org.eclipse.collections.api.list.ListIterable的典型用法代码示例。如果您正苦于以下问题:Java ListIterable类的具体用法?Java ListIterable怎么用?Java ListIterable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListIterable类属于org.eclipse.collections.api.list包,在下文中一共展示了ListIterable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSortWithFk

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testSortWithFk() throws Exception {
    final ExecuteChangeCommand aTab1 = newIncrementalCommand(tableChangeType(), "ATab", "1", Sets.immutable.<String>of(), 1);
    final ExecuteChangeCommand aTab2 = newIncrementalCommand(tableChangeType(), "ATab", "2", Sets.immutable.<String>of(), 2);
    final ExecuteChangeCommand aTab3 = newIncrementalCommand(tableChangeType(), "ATab", "3", Sets.immutable.<String>of(), 3);
    final ExecuteChangeCommand bTab1 = newIncrementalCommand(tableChangeType(), "BTab", "1", Sets.immutable.<String>of(), 1);
    final ExecuteChangeCommand bTab2 = newIncrementalCommand(tableChangeType(), "BTab", "2", Sets.immutable.<String>of("ATab"), 2);
    final ExecuteChangeCommand bTab3 = newIncrementalCommand(tableChangeType(), "BTab", "3", Sets.immutable.<String>of(), 3);
    final ListIterable<ExecuteChangeCommand> sortedCommands = sorter.sort(Lists.mutable.of(
            aTab1
            , aTab2
            , aTab3
            , bTab1
            , bTab2
            , bTab3
    ), false);

    // assert basic order
    assertThat("aTab changes should be in order", sortedCommands.indexOf(aTab1), Matchers.lessThan(sortedCommands.indexOf(aTab2)));
    assertThat("aTab changes should be in order", sortedCommands.indexOf(aTab2), Matchers.lessThan(sortedCommands.indexOf(aTab3)));
    assertThat("bTab changes should be in order", sortedCommands.indexOf(bTab1), Matchers.lessThan(sortedCommands.indexOf(bTab2)));
    assertThat("bTab changes should be in order", sortedCommands.indexOf(bTab2), Matchers.lessThan(sortedCommands.indexOf(bTab3)));

    // assert cross-object dependency
    assertThat("assert bTab change depending on aTab comes after tabA", sortedCommands.indexOf(aTab1), Matchers.lessThan(sortedCommands.indexOf(bTab2)));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:27,代码来源:ChangeCommandSorterImplTest.java

示例2: getAppContextAndJdbcDsParams

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
private Collection<Object[]> getAppContextAndJdbcDsParams(final int numConnections) {
    return getSysConfigs().flatCollect(new Function<Config, ListIterable<Object[]>>() {
        @Override
        public ListIterable<Object[]> valueOf(final Config config) {
            ListIterable<IntToObjectFunction<DbDeployerAppContext>> appContexts = getAppContext(config);
            return appContexts.collect(new Function<IntToObjectFunction<DbDeployerAppContext>, Object[]>() {
                @Override
                public Object[] valueOf(IntToObjectFunction<DbDeployerAppContext> appContext) {
                    return new Object[] {
                            appContext,
                            getJdbcDs(config, numConnections)
                    };
                }
            });
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:18,代码来源:ParamReader.java

示例3: getAppContext

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
private static ListIterable<IntToObjectFunction<DbDeployerAppContext>> getAppContext(final Config config) {
    final String sourcePath = config.getString("sourcePath");
    String env = getStringOptional(config, "env");

    final String[] envArgs = env != null ? env.split(",") : new String[] { null };
    final String username = getStringOptional(config, "username");
    final String password = getStringOptional(config, "password");
    return ArrayAdapter.adapt(envArgs).collect(new Function<String, IntToObjectFunction<DbDeployerAppContext>>() {
        @Override
        public IntToObjectFunction<DbDeployerAppContext> valueOf(final String envArg) {
            return new IntToObjectFunction<DbDeployerAppContext>() {
                @Override
                public DbDeployerAppContext valueOf(int stepNumber) {
                    String stepSourcePath = replaceStepNumber(sourcePath, stepNumber, config);

                    DbEnvironment dbEnvironment = DbEnvironmentFactory.getInstance().readOneFromSourcePath(stepSourcePath, envArg != null ? new String[] {envArg} : new String[0]);
                    if (username != null && password != null) {
                        return dbEnvironment.buildAppContext(username, password);
                    } else {
                        return dbEnvironment.buildAppContext();
                    }
                }
            };
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:27,代码来源:ParamReader.java

示例4: getCycleComponents

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
/**
 * Returns the components of the graph that are cycles.
 * Taken from the implementation of {@link CycleDetector#findCycles()}. (EPL)
 */
private static <T, E> ListIterable<Set<T>> getCycleComponents(final DirectedGraph<T, E> graph) {
    StrongConnectivityInspector<T, E> inspector =
            new StrongConnectivityInspector<T, E>(graph);

    return ListAdapter.adapt(inspector.stronglyConnectedSets()).select(new Predicate<Set<T>>() {
        @Override
        public boolean accept(Set<T> each) {
            if (each.size() > 1) {
                // multi-vertex strongly-connected component is a cycle
                return true;
            }

            // vertex with an edge to itself is a cycle
            T vertex = each.iterator().next();
            return graph.containsEdge(vertex, vertex);
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:23,代码来源:GraphUtil.java

示例5: testShouldRetrieveAllFoldersAvailableInClassPath

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testShouldRetrieveAllFoldersAvailableInClassPath() {
    ListIterable<FileObject> sourceDirs = FileRetrievalMode.CLASSPATH.resolveFileObjects("database/");
    assertEquals(3, sourceDirs.size());

    MutableSetIterable<String> resolved = Sets.mutable.empty();
    for (FileObject sourceDir : sourceDirs) {
        FileObject[] files = sourceDir.findFiles(new BasicFileSelector(vcsAware(), true));
        for (FileObject file : files) {
            resolved.add(file.getURL().getPath());
        }
    }
    assertTrue(resolved.anySatisfy(StringPredicates.endsWith("TEST_TABLE.sql")));
    assertTrue(resolved.anySatisfy(StringPredicates.endsWith("TEST_TABLE_1.sql")));
    assertTrue(resolved.anySatisfy(StringPredicates.endsWith("TEST_TABLE_2.sql")));
    assertTrue(resolved.anySatisfy(StringPredicates.endsWith("TEST_TABLE_3.sql")));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:18,代码来源:FileRetrievalModeTest.java

示例6: testSortWithMixedDependency

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testSortWithMixedDependency() throws Exception {
    final ExecuteChangeCommand aTab1 = newIncrementalCommand(tableChangeType(), "aTab", "1", Sets.immutable.<String>of("bTab.1"), 1);
    final ExecuteChangeCommand aTab2 = newIncrementalCommand(tableChangeType(), "aTab", "2", Sets.immutable.<String>of("bTab.2"), 2);
    final ExecuteChangeCommand bTab1 = newIncrementalCommand(tableChangeType(), "bTab", "1", Sets.immutable.<String>of(), 1);
    final ExecuteChangeCommand bTab2 = newIncrementalCommand(tableChangeType(), "bTab", "2", Sets.immutable.<String>of(), 2);
    final ListIterable<ExecuteChangeCommand> sortedCommands = sorter.sort(Lists.mutable.of(
            aTab1
            , aTab2
            , bTab1
            , bTab2
    ), false);

    // assert basic order
    assertThat("bTab.1 comes before aTab.1 due to FK dependency", sortedCommands.indexOf(bTab1), Matchers.lessThan(sortedCommands.indexOf(aTab1)));
    assertThat("bTab.2 must come after aTab.1 and before aTab.2 as aTab.2 depends explicitly on bTab2.", sortedCommands.indexOf(aTab1), Matchers.lessThan(sortedCommands.indexOf(bTab2)));
    assertThat("bTab.2 must come after aTab.1 and before aTab.2 as aTab.2 depends explicitly on bTab2.", sortedCommands.indexOf(bTab2), Matchers.lessThan(sortedCommands.indexOf(aTab2)));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:19,代码来源:ChangeCommandSorterImplTest.java

示例7: testFunc2TableToFuncDependency

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testFunc2TableToFuncDependency() throws Exception {
    final ExecuteChangeCommand func1 = newCommand(viewChangeType(), "Func1", "n/a", Sets.immutable.<String>of());
    final ExecuteChangeCommand func2 = newCommand(viewChangeType(), "Func2", "n/a", Sets.immutable.<String>of("Func1"));
    final ExecuteChangeCommand aTab1 = newIncrementalCommand(tableChangeType(), "ATab", "1", Sets.immutable.<String>of("Func2"), 1);
    final ExecuteChangeCommand aTab2 = newIncrementalCommand(tableChangeType(), "ATab", "2", Sets.immutable.<String>of(), 2);
    final ExecuteChangeCommand funcOnTab3 = newCommand(viewChangeType(), "FuncOnTab3", "n/a", Sets.immutable.<String>of("ATab"));


    ListIterable<ExecuteChangeCommand> sortedCommands = sorter.sort(Lists.mutable.of(
            func1, func2, aTab1, aTab2, funcOnTab3
    ), false);

    assertThat("func1 should precede func2", sortedCommands.indexOf(func1), Matchers.lessThan(sortedCommands.indexOf(func2)));
    assertThat("func2 should precede atab1", sortedCommands.indexOf(func2), Matchers.lessThan(sortedCommands.indexOf(aTab1)));
    assertThat("aTab changes should remain in order", sortedCommands.indexOf(aTab1), Matchers.lessThan(sortedCommands.indexOf(aTab2)));
    assertThat("function should be created after the table", sortedCommands.indexOf(aTab1), Matchers.lessThan(sortedCommands.indexOf(funcOnTab3)));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:19,代码来源:ChangeCommandSorterImplTest.java

示例8: testBaselineNewAddition

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testBaselineNewAddition() {
    // dep1, dep2, dep3 are not deployed - hence, we should deploy the baseline we find in the source
    Change srcB = new ChangeIncremental(tableChangeType(), "schema", "tabB", "bas1", 0, "chng1", CONTENT)
            .withBaselines(Lists.mutable.with("ch1", "ch2", "ch3"));
    Change src4 = new ChangeIncremental(tableChangeType(), "schema", "tabB", "ch4", 1, "chng1", CONTENT);

    ListIterable<ChangeCommand> changeset = cmdCalc.calculateCommands(tableChangeType(), Lists.mutable.of(
            new ChangePair(srcB, null)
            , new ChangePair(src4, null)
    ), unusedChangesArg, false, false);

    assertEquals(2, changeset.size());
    Verify.assertAnySatisfy(changeset, assertValue(DeployChangeCommand.class, srcB));
    Verify.assertAnySatisfy(changeset, assertValue(DeployChangeCommand.class, src4));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:17,代码来源:IncrementalChangeTypeCommandCalculatorTest.java

示例9: testBaselineException

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testBaselineException() {
    // In this use case, srcB is the baseline change w/ ch1 ch2 ch3 marked. However, we only see ch1 and ch2 deployed, so we throw an exception

    Change dep1 = new ChangeIncremental(tableChangeType(), "schema", "tabB", "ch1", 0, "chng1", CONTENT);
    Change dep2 = new ChangeIncremental(tableChangeType(), "schema", "tabB", "ch2", 0, "chng1", CONTENT);
    // hiding dep3 as to show the exception use case
    //Change dep3 = new ChangeIncremental(tableChangeType(), "schema", "tabB", "ch3", 0, "chng1", CONTENT);
    Change srcB = new ChangeIncremental(tableChangeType(), "schema", "tabB", "bas1", 0, "chng1", CONTENT)
            .withBaselines(Lists.mutable.with("ch1", "ch2", "ch3"));
    Change src4 = new ChangeIncremental(tableChangeType(), "schema", "tabB", "ch4", 1, "chng1", CONTENT);

    ListIterable<ChangeCommand> changeset = cmdCalc.calculateCommands(tableChangeType(), Lists.mutable.of(
            new ChangePair(srcB, null)
            , new ChangePair(src4, null)
            , new ChangePair(null, dep1)
            , new ChangePair(null, dep2)
    ), unusedChangesArg, false, false);

    assertEquals(2, changeset.size());
    Verify.assertAnySatisfy(changeset, assertValue(DeployChangeCommand.class, src4));
    Predicate<ChangeCommand> baselineWarningPredicate = assertValue(IncompleteBaselineWarning.class, srcB);
    Verify.assertAnySatisfy(changeset, baselineWarningPredicate);
    IncompleteBaselineWarning baselineWarning = (IncompleteBaselineWarning) changeset.detect(baselineWarningPredicate);
    assertEquals(Sets.mutable.with("ch3"), baselineWarning.getNonDeployedChanges());
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:27,代码来源:IncrementalChangeTypeCommandCalculatorTest.java

示例10: testSimpleViews

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testSimpleViews() {
    Change view1Dep = new ChangeRerunnable(viewChangeType(), "schema", "viewA", "hash", CONTENT);
    Change view1Src = new ChangeRerunnable(viewChangeType(), "schema", "viewA", "hashdiff", CONTENT);
    Change view2Dep = new ChangeRerunnable(viewChangeType(), "schema", "viewB", "samehash", CONTENT);
    Change view2Src = new ChangeRerunnable(viewChangeType(), "schema", "viewB", "samehash", CONTENT);
    Change view3Dep = new ChangeRerunnable(viewChangeType(), "schema", "viewC", "deletion", CONTENT);
    Change view4Src = new ChangeRerunnable(viewChangeType(), "schema", "viewD", "addition", CONTENT);

    MutableList<Change> allSourceChanges = Lists.mutable.with(
            view1Src, view2Src, view4Src
    );

    ListIterable<ChangeCommand> changeset = cmdCalc.calculateCommands(viewChangeType(), Lists.mutable.of(
            new ChangePair(view1Src, view1Dep)
            , new ChangePair(view2Src, view2Dep)
            , new ChangePair(null, view3Dep)
            , new ChangePair(view4Src, null)
    ), allSourceChanges, false, false);

    assertEquals(3, changeset.size());
    Verify.assertAnySatisfy(changeset, assertValue(DeployChangeCommand.class, view1Src));
    Verify.assertAnySatisfy(changeset, assertValue(DeployChangeCommand.class, view4Src));
    Verify.assertAnySatisfy(changeset, assertValue(DropObjectChangeCommand.class, view3Dep));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:26,代码来源:RerunnableChangeTypeCommandCalculatorTest.java

示例11: getAppContextParams

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
public Collection<Object[]> getAppContextParams() {
    return getSysConfigs().flatCollect(new Function<Config, ListIterable<Object[]>>() {
        @Override
        public ListIterable<Object[]> valueOf(final Config config) {
            ListIterable<IntToObjectFunction<DbDeployerAppContext>> appContexts = getAppContext(config);
            return appContexts.collect(new Function<IntToObjectFunction<DbDeployerAppContext>, Object[]>() {
                @Override
                public Object[] valueOf(IntToObjectFunction<DbDeployerAppContext> appContext) {
                    return new Object[] { appContext };
                }
            });
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:15,代码来源:ParamReader.java

示例12: sort

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Override
public ImmutableList<ExecuteChangeCommand> sort(RichIterable<ExecuteChangeCommand> changeCommands, boolean rollback) {
    final RichIterable<DbCommandSortKey> commandDatas = changeCommands.collect(DbCommandSortKey.CREATE);

    PartitionIterable<DbCommandSortKey> dataCommandPartition = commandDatas.partition(
            Predicates.attributeIn(Functions.chain(DbCommandSortKey.TO_CHANGE_TYPE, ChangeType.TO_NAME), Sets.fixedSize.of(ChangeType.STATICDATA_STR)));

    PartitionIterable<DbCommandSortKey> dropPartition = dataCommandPartition.getRejected().partition(Predicates.attributeEqual(DbCommandSortKey.TO_DROP, true));

    ListIterable<DbCommandSortKey> orderedAdds = sortAddCommands(dropPartition.getRejected(), rollback);
    ListIterable<DbCommandSortKey> orderedDrops = sortDropCommands(dropPartition.getSelected());
    ListIterable<DbCommandSortKey> orderedDatas = sortDataCommands(dataCommandPartition.getSelected());

    return Lists.mutable.withAll(orderedDrops).withAll(orderedAdds).withAll(orderedDatas).collect(DbCommandSortKey.TO_CHANGE_COMMAND).toImmutable();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:16,代码来源:ChangeCommandSorterImpl.java

示例13: sortAddCommands

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
private ListIterable<DbCommandSortKey> sortAddCommands(RichIterable<DbCommandSortKey> addCommands, boolean rollback) {
    DirectedGraph<DbCommandSortKey, DefaultEdge> addGraph = enricher.createDependencyGraph(addCommands, rollback);

    ListIterable<DbCommandSortKey> addChanges = graphSorter.sortChanges(addGraph, SortableDependencyGroup.GRAPH_SORTER_COMPARATOR);
    addChanges.forEachWithIndex(new ObjectIntProcedure<DbCommandSortKey>() {
        @Override
        public void value(DbCommandSortKey command, int order) {
            command.setOrder(order);
        }
    });

    return addCommands.toSortedListBy(DbCommandSortKey.TO_ORDER);
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:14,代码来源:ChangeCommandSorterImpl.java

示例14: sortDataCommands

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
private ListIterable<DbCommandSortKey> sortDataCommands(RichIterable<DbCommandSortKey> dataCommands) {
    // The background behind this order check: while we want to rely on the FK-dependencies generally to
    // figure out the order of deployment (and once we group by connected components,
    // then the dependencies between components shouldn't matter), there are a couple use cases where we
    // still need to rely on the "order" attribute:
    // 1) for backwards-compatibility w/ teams using older versions of this tool that didn't have
    // this more-advanced ordering logic and that instead needed the "order" attribute
    // 2) the MetadataGroup use case (see "MetadataGroupTest")
    // Hence, we will still rely on the "changeOrder" attribute here as a fallback for the order
    MutableList<DbCommandSortKey> sortedDataCommands = dataCommands.toSortedListBy(new Function<DbCommandSortKey, Comparable>() {
        @Override
        public Comparable valueOf(DbCommandSortKey dbCommandSortKey) {
            ListIterable<Change> changes = dbCommandSortKey.getChangeCommand().getChanges();
            if (changes.isEmpty() || changes.size() > 1) {
                return Change.DEFAULT_CHANGE_ORDER;
            } else {
                return changes.getFirst().getOrder();
            }
        }
    });

    sortedDataCommands.forEachWithIndex(new ObjectIntProcedure<DbCommandSortKey>() {
        @Override
        public void value(DbCommandSortKey dataCommand, int order) {
            dataCommand.setOrder(order);
        }
    });

    return dataCommands.toSortedListBy(DbCommandSortKey.TO_ORDER);
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:31,代码来源:ChangeCommandSorterImpl.java

示例15: testNewTableAdd

import org.eclipse.collections.api.list.ListIterable; //导入依赖的package包/类
@Test
public void testNewTableAdd() {
    Change tabA1Src = new ChangeIncremental(tableChangeType(), "schema", "tabA", "new", 0, "chng1", CONTENT);

    ListIterable<ChangeCommand> changeCommands = cmdCalc.calculateCommands(tableChangeType(), Lists.mutable.<ChangePair>of(
            new ChangePair(tabA1Src, null)
    ), unusedChangesArg, false, false);

    assertEquals(1, changeCommands.size());
    Verify.assertAnySatisfy(changeCommands, assertValue(DeployChangeCommand.class, tabA1Src));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:12,代码来源:IncrementalChangeTypeCommandCalculatorTest.java


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