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


Java Monetary.getAmountFactory方法代码示例

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


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

示例1: testQueryAmountType

import javax.money.Monetary; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)}.
 */
@Test
public void testQueryAmountType(){
    MonetaryAmountFactory<?> f = Monetary
            .getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setTargetType(RoundedMoney.class).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == RoundedMoney.class);
    f = Monetary.getAmountFactory(
            MonetaryAmountFactoryQueryBuilder.of().setTargetType(FastMoney.class).setPrecision(5).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == FastMoney.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setTargetType(Money.class).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Monetary.getDefaultAmountType());
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
    assertNotNull(f);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(20).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(5).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
    f = Monetary.getAmountFactory(MonetaryAmountFactoryQueryBuilder.of().setPrecision(200).build());
    assertNotNull(f);
    assertTrue(f.getAmountType() == Money.class);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:42,代码来源:MonetaryAmountsRegistrationTest.java

示例2: testGetAmountFactory_WithNull

import javax.money.Monetary; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)} .
 */
@Test(expectedExceptions = NullPointerException.class)
public void testGetAmountFactory_WithNull(){
    Monetary.getAmountFactory((MonetaryAmountFactoryQuery) null);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:9,代码来源:MonetaryAmountsRegistrationTest.java

示例3: testQueryAmountType_InvalidContext

import javax.money.Monetary; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link javax.money.Monetary#getAmountFactory(javax.money.MonetaryAmountFactoryQuery)} .
 */
@Test(expectedExceptions = MonetaryException.class)
public void testQueryAmountType_InvalidContext(){
    Monetary.getAmountFactory(
            MonetaryAmountFactoryQueryBuilder.of().setTargetType(FastMoney.class).setPrecision(20).build());
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:10,代码来源:MonetaryAmountsRegistrationTest.java


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