當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。