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


Java Ordering.explicit方法代码示例

本文整理汇总了Java中com.google.common.collect.Ordering.explicit方法的典型用法代码示例。如果您正苦于以下问题:Java Ordering.explicit方法的具体用法?Java Ordering.explicit怎么用?Java Ordering.explicit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Ordering的用法示例。


在下文中一共展示了Ordering.explicit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCaseCorrectionOfDropSet

import com.google.common.collect.Ordering; //导入方法依赖的package包/类
/**
 * Ensure that case-infidelity of discovered views doesn't break us.
 */
@Test
public void testCaseCorrectionOfDropSet() {
  ViewChanges c = new ViewChanges(
    ImmutableSet.of(
      view("A", "B"),
      view("B")
    ),
    ImmutableSet.of(
      view("b")
    ),
    ImmutableSet.of(
      view("A"),
      view("B")
    ));

  assertEquals("Views to drop mismatch", ImmutableSet.of("A", "B"), nameSet(c.getViewsToDrop()));
  assertEquals("Views to deploy mismatch", ImmutableSet.of("A", "B"), nameSet(c.getViewsToDeploy()));

  Ordering<String> dropOrder = Ordering.explicit(nameList(c.getViewsToDrop()));
  assertTrue("Must drop A before B", dropOrder.compare("A", "B") < 0);

  Ordering<String> deployOrder = Ordering.explicit(nameList(c.getViewsToDeploy()));
  assertTrue("Must deploy B before A", deployOrder.compare("B", "A") < 0);
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:28,代码来源:TestViewChanges.java

示例2: testDroppingAlsoDeployingAlso

import com.google.common.collect.Ordering; //导入方法依赖的package包/类
/**
 * Check we can expand the set of drops and deploys.
 */
@Test
public void testDroppingAlsoDeployingAlso() {
  ViewChanges c = new ViewChanges(
    ImmutableSet.of(
      view("A", "B"),
      view("B"),
      view("D")
    ),
    ImmutableSet.of(
      view("B")
    ),
    ImmutableSet.of(
      view("A"),
      view("B")
    )).droppingAlso(ImmutableSet.of(view("C"))).deployingAlso(ImmutableSet.of(view("D")));

  assertEquals("Views to drop mismatch", ImmutableSet.of("A", "B", "C"), nameSet(c.getViewsToDrop()));
  assertEquals("Views to deploy mismatch", ImmutableSet.of("A", "B", "D"), nameSet(c.getViewsToDeploy()));

  Ordering<String> dropOrder = Ordering.explicit(nameList(c.getViewsToDrop()));
  assertTrue("Must drop A before B", dropOrder.compare("A", "B") < 0);

  Ordering<String> deployOrder = Ordering.explicit(nameList(c.getViewsToDeploy()));
  assertTrue("Must deploy B before A", deployOrder.compare("B", "A") < 0);
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:29,代码来源:TestViewChanges.java

示例3: createExplicitComparator

import com.google.common.collect.Ordering; //导入方法依赖的package包/类
private static Ordering<String> createExplicitComparator(String[] elements) {
  // Collapse equal elements, which Ordering.explicit() doesn't support, while
  // maintaining the ordering by first occurrence.
  Set<String> elementsPlus = Sets.newLinkedHashSet();
  elementsPlus.add(BEFORE_FIRST);
  elementsPlus.add(BEFORE_FIRST_2);
  elementsPlus.addAll(Arrays.asList(elements));
  elementsPlus.add(AFTER_LAST);
  elementsPlus.add(AFTER_LAST_2);
  return Ordering.explicit(Lists.newArrayList(elementsPlus));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:SetGenerators.java

示例4: testSimple

import com.google.common.collect.Ordering; //导入方法依赖的package包/类
/**
 * Test a simple configuration.
 */
@Test
public void testSimple() {
  ViewChanges c = new ViewChanges(
    ImmutableSet.of(
      view("A", "B", "C"),
      view("B", "C", "D"),
      view("C"),
      view("D")
    ),
    ImmutableSet.of(
      view("B")
    ),
    ImmutableSet.of(
      view("A"),
      view("B")
    ));

  assertEquals("Views to drop mismatch", ImmutableSet.of("B", "A"), nameSet(c.getViewsToDrop()));
  assertEquals("Views to deploy mismatch", ImmutableSet.of("A", "B"), nameSet(c.getViewsToDeploy()));

  Ordering<String> dropOrder = Ordering.explicit(nameList(c.getViewsToDrop()));
  assertTrue("Must drop A before B", dropOrder.compare("A", "B") < 0);

  Ordering<String> deployOrder = Ordering.explicit(nameList(c.getViewsToDeploy()));
  assertTrue("Must deploy B before A", deployOrder.compare("B", "A") < 0);
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:30,代码来源:TestViewChanges.java

示例5: testObsoleted

import com.google.common.collect.Ordering; //导入方法依赖的package包/类
/**
 * Test we're still prepared to drop views that we know nothing of.
 */
@Test
public void testObsoleted() {
  ViewChanges c = new ViewChanges(
    ImmutableSet.of(
      view("A", "B"),
      view("B", "C"),
      view("C")
    ),
    ImmutableSet.of(
      view("B"),
      view("X")
    ),
    ImmutableSet.of(
      view("A"),
      view("B")
    ));

  assertEquals("Views to drop mismatch", ImmutableSet.of("A", "B", "X"), nameSet(c.getViewsToDrop()));
  assertEquals("Views to deploy mismatch", ImmutableSet.of("A", "B"), nameSet(c.getViewsToDeploy()));

  Ordering<String> dropOrder = Ordering.explicit(nameList(c.getViewsToDrop()));
  assertTrue("Must drop A before B", dropOrder.compare("A", "B") < 0);

  Ordering<String> deployOrder = Ordering.explicit(nameList(c.getViewsToDeploy()));
  assertTrue("Must deploy B before A", deployOrder.compare("B", "A") < 0);
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:30,代码来源:TestViewChanges.java


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