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


Java ComparableRange类代码示例

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


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

示例1: comparableRangeTest

import org.ofbiz.base.lang.ComparableRange; //导入依赖的package包/类
private static <T extends Comparable<T>, B extends Comparable<B>> void comparableRangeTest(String label, B bad, T a, T b, T c, T d) {
    comparableRangeConstructorTest(bad, a);
    assertTrue(label + ":a-isPoint", new ComparableRange<T>(a, a).isPoint());
    assertTrue(label + ":b-isPoint", new ComparableRange<T>(b, b).isPoint());
    assertTrue(label + ":c-isPoint", new ComparableRange<T>(c, c).isPoint());
    ComparableRange<T> first = new ComparableRange<T>(a, b);
    ComparableRange<T> second = new ComparableRange<T>(c, d);
    ComparableRange<T> all = new ComparableRange<T>(a, d);
    assertEquals(label + ":a-b toString", a + " - " + b, first.toString());
    assertEquals(label + ":c-d toString", c + " - " + d, second.toString());
    assertEquals(label + ":a-d toString", a + " - " + d, all.toString());
    assertFalse(label + ":a-b isPoint", first.isPoint());
    assertFalse(label + ":c-d isPoint", second.isPoint());
    assertFalse(label + ":a-d isPoint", all.isPoint());
    assertEquals(label + ":a-b == a-b", first, first);
    assertEquals(label + ":a-b.compareTo(a-b)", 0, first.compareTo(first));
    assertEquals(label + ":a-b equals a-b", first, new ComparableRange<T>(a, b));
    assertEquals(label + ":a-b.compareTo(new a-b)", 0, first.compareTo(new ComparableRange<T>(a, b)));
    assertEquals(label + ":a-b equals b-a", first, new ComparableRange<T>(b, a));
    assertEquals(label + ":a-b.compareTo(new b-a)", 0, first.compareTo(new ComparableRange<T>(b, a)));
    assertNotEquals(label + ":a-b not-equal other", first, ComparableRangeTests.class);
    assertFalse(label + ":a-d equals null", all.equals(null));
    ClassCastException caught = null;
    try {
        UtilGenerics.<Comparable<Object>>cast(first).compareTo(ComparableRangeTests.class);
    } catch (ClassCastException e) {
        caught = e;
    } finally {
        assertNotNull(label + " compareTo CCE", caught);
    }
    assertNotEquals(label + ":a-a != a-b", new ComparableRange<T>(a, a), first);
    assertThat(label + ":a-a.compareTo(a-b) < 0", 0, greaterThan(new ComparableRange<T>(a, a).compareTo(first)));
    assertNotEquals(label + ":a-a != c-d", new ComparableRange<T>(a, a), second);
    assertThat(label + ":a-a.compareTo(c-d) < 0", 0, greaterThan(new ComparableRange<T>(a, a).compareTo(second)));
    assertNotEquals(label + ":a-a != a-d", new ComparableRange<T>(a, a), all);
    assertThat(label + ":a-a.compareTo(a-d) < 0", 0, greaterThan(new ComparableRange<T>(a, a).compareTo(all)));
    assertTrue(label + ":b-c after a-b", second.after(first));
    assertThat(label + ":b-c.compareTo(a-b)", 0, lessThan(second.compareTo(first)));
    assertFalse(label + ":c-d !after c-d", second.after(second));
    assertEquals(label + ":c-d.compareTo(c-d)", 0, second.compareTo(second));
    assertTrue(label + ":a-b before c-d", first.before(second));
    assertThat(label + ":a-b.compareTo(c-d)", 0, greaterThan(first.compareTo(second)));
    assertFalse(label + ":a-b !before a-b", first.before(first));
    assertEquals(label + ":a-b.compareTo(a-b)", 0, first.compareTo(first));
    assertTrue(label + ":a-d includes a-b", all.includes(first));
    assertTrue(label + ":a-b overlaps b-c", first.overlaps(new ComparableRange<T>(b, c)));
    assertTrue(label + ":b-c overlaps c-d", new ComparableRange<T>(b, c).overlaps(second));
    assertTrue(label + ":a-b overlaps a-d", first.overlaps(all));
    assertTrue(label + ":a-d overlaps a-b", all.overlaps(first));
    assertTrue(label + ":a-d overlaps b-c", all.overlaps(new ComparableRange<T>(b, c)));
    assertTrue(label + ":b-c overlaps a-d", new ComparableRange<T>(b, c).overlaps(all));
    assertFalse(label + ":a-b overlaps c-d", first.overlaps(second));
    assertFalse(label + ":c-d overlaps a-b", second.overlaps(first));
    assertTrue(label + ":a-b includes a", first.includes(a));
    assertTrue(label + ":a-b includes b", first.includes(b));
    assertFalse(label + ":a-b includes c", first.includes(c));
    assertFalse(label + ":a includes a-b", new ComparableRange<T>(a, a).includes(first));
    assertTrue(label + ":c-d after a", second.after(a));
    assertTrue(label + ":c-d after b", second.after(b));
    assertFalse(label + ":c-d after c", second.after(c));
    assertFalse(label + ":c-d after d", second.after(d));
    assertFalse(label + ":a-b after a", first.before(a));
    assertFalse(label + ":a-b after b", first.before(b));
    assertTrue(label + ":a-b after c", first.before(c));
    assertTrue(label + ":a-b after d", first.before(d));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:67,代码来源:ComparableRangeTests.java


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