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


Java Comparators类代码示例

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


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

示例1: validateNoBaselineBreaks

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
public void validateNoBaselineBreaks(DbDeployerAppContext appContext, Predicate<? super CompareBreak> breakIgnorePredicate) {
    MutableList<CompareBreak> sortedCompareBreaks = this.calculateBaselineBreaks(appContext).toList().sortThis(
            Comparators.fromFunctions(
                    CompareBreak.TO_COMPARE_SUBJECT,
                    Functions.chain(CompareBreak.TO_CLAZZ, CLASS_TO_NAME),
                    Functions.chain(Functions.getToClass(), CLASS_TO_NAME)
            ));

    MutableList<CompareBreak> relevantBreaks = sortedCompareBreaks.reject(breakIgnorePredicate);

    LOG.info("Found " + relevantBreaks.size() + " breaks");

    if (!relevantBreaks.isEmpty()) {
        throw new IllegalArgumentException(
                "Found some mismatches between your change alters (LEFT) and your baseline files (RIGHT). Please review:\n"
                        + relevantBreaks.makeString("\n"));
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:19,代码来源:BaselineValidatorMain.java

示例2: getColumnsOrderedBySelectivity

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
private MutableList<IndexMap> getColumnsOrderedBySelectivity(MutableList<UnmatchedIndexMap> allMissingRows, MutableList<UnmatchedIndexMap> allSurplusRows, MutableList<IndexMap> columnIndices)
{
    LOGGER.info("Calculating column selectivity");
    MutableList<Pair<IndexMap, Integer>> columnSelectivities = Lists.mutable.of();
    for (IndexMap column : columnIndices)
    {
        CellComparator expectedComparator = this.columnComparators.getComparator(expectedData.getColumnName(column.getExpectedIndex()));
        Set<String> expectedValues = getColumnValues(allMissingRows, Functions.chain(expectedValueFunction(column), expectedComparator.getFormatter()));
        CellComparator actualComparator = this.columnComparators.getComparator(actualData.getColumnName(column.getActualIndex()));
        Set<String> actualValues = getColumnValues(allSurplusRows, Functions.chain(actualValueFunction(column), actualComparator.getFormatter()));
        actualValues.retainAll(expectedValues);
        int selectivity = actualValues.size();
        if (selectivity > 0)
        {
            columnSelectivities.add(Tuples.pair(column, Integer.valueOf(selectivity)));
        }
    }
    return columnSelectivities
            .sortThis(Comparators.reverse(Comparators.byFunction(Functions.<Integer>secondOfPair())))
            .collect(Functions.<IndexMap>firstOfPair());
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:22,代码来源:AdaptivePartialMatcher.java

示例3: testBasicOrderingWithComparator

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
@Test
public void testBasicOrderingWithComparator() {
    SortableDependency sp1 = newVertex("sp1");
    SortableDependency sp2 = newVertex("sp2");
    SortableDependency sp3 = newVertex("sp3");
    SortableDependency sp4 = newVertex("sp4");
    SortableDependency sp5 = newVertex("sp5");

    DirectedGraph<SortableDependency, DefaultEdge> graph = new DefaultDirectedGraph<SortableDependency, DefaultEdge>(DefaultEdge.class);

    for (SortableDependency vertex : shuffledList(sp1, sp2, sp3, sp4, sp5)) {
        graph.addVertex(vertex);
    }

    graph.addEdge(sp1, sp5);
    graph.addEdge(sp3, sp5);
    graph.addEdge(sp2, sp1);
    graph.addEdge(sp5, sp4);

    ListIterable<SortableDependency> sorted = sorter.sortChanges(graph, Comparators.fromFunctions(SortableDependency.TO_CHANGE_NAME));

    // First, compare the root topological order (i.e. ensure that the dependencies are respected)
    assertEquals(5, sorted.size());
    assertThat(sorted.indexOf(sp1), greaterThan(sorted.indexOf(sp2)));
    assertThat(sorted.indexOf(sp5), greaterThan(sorted.indexOf(sp1)));
    assertThat(sorted.indexOf(sp5), greaterThan(sorted.indexOf(sp3)));
    assertThat(sorted.indexOf(sp4), greaterThan(sorted.indexOf(sp5)));

    // Now check that we can achieve a consistent order too (for easier debuggability for clients)
    assertEquals(Lists.immutable.with(sp2, sp1, sp3, sp5, sp4), sorted);
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:32,代码来源:GraphSorterTest.java

示例4: compareTo

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
@Override
public int compareTo(User o) {
  Comparator c = Comparators.naturalOrder();
  if (this.id == null && o.id == null)
    return c.compare(this.login, o.login);
  else
    return c.compare(this.id, o.id);
}
 
开发者ID:OHDSI,项目名称:WebAPI,代码行数:9,代码来源:UserService.java

示例5: searchExtraViewInfo

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
@Override
public ImmutableCollection<ExtraRerunnableInfo> searchExtraViewInfo(DaSchema schema, String tableName, Connection conn) throws SQLException {
    String query = String.format("select obj.name name, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.type in ('V')\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "order by com.id, number, colid2, colid\n", schema.getName());
    QueryRunner qr = new QueryRunner();  // using queryRunner so that we can reuse the connection
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(qr.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> viewInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            return new ExtraRerunnableInfo(
                    (String) object.get("name"),
                    null,
                    (String) object.get("text"),
                    null,
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return viewInfos.groupBy(ExtraRerunnableInfo.TO_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new ExtraRerunnableInfo(
                    sortedInfos.get(0).getName(),
                    null,
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:47,代码来源:SybaseAseMetadataDialect.java

示例6: searchExtraRoutines

import org.eclipse.collections.impl.block.factory.Comparators; //导入依赖的package包/类
@Override
public ImmutableCollection<DaRoutine> searchExtraRoutines(final DaSchema schema, String procedureName, Connection conn) throws SQLException {
    String nameClause = procedureName != null ? "and obj.name = '" + procedureName + "'\n" : "";

    String query = String.format("select obj.name name, obj.type type, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "and obj.type in ('SF', 'P')\n" +
            nameClause +
            "order by com.id, number, colid2, colid\n", schema.getName());
    QueryRunner qr = new QueryRunner();  // using queryRunner so that we can reuse the connection
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(qr.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> routineInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            String basename = (String) object.get("name");
            int number = ((Integer) object.get("number")).intValue();
            String specificName = number > 1 ? basename + ";" + number : basename;
            return new ExtraRerunnableInfo(
                    basename,
                    specificName,
                    (String) object.get("text"),
                    ((String) object.get("type")).trim(),
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return routineInfos.groupBy(ExtraRerunnableInfo.TO_SPECIFIC_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, DaRoutine>() {
        @Override
        public DaRoutine valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new DaRoutinePojoImpl(
                    sortedInfos.get(0).getName(),
                    schema,
                    sortedInfos.get(0).getType().equals("P") ? DaRoutineType.procedure : DaRoutineType.function,
                    sortedInfos.get(0).getSpecificName(),
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:55,代码来源:SybaseAseMetadataDialect.java


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