• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MonetaryQuery类的典型用法和代码示例

java 1次浏览

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

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

示例1: testQuery

点赞 3

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Test method for
 * {@link RoundedMoney#query(javax.money.MonetaryQuery)}
 * .
 */
@Test
public void testQuery() {
    MonetaryQuery<Integer> q = new MonetaryQuery<Integer>(){
        @Override
        public Integer queryFrom(MonetaryAmount amount) {
            return RoundedMoney.from(amount).getPrecision();
        }
    };
    RoundedMoney[] moneys = new RoundedMoney[]{RoundedMoney.of(100, "CHF"), RoundedMoney.of(34242344, "USD"),
            RoundedMoney.of(23123213.435, "EUR"), RoundedMoney.of(-23123213.435, "USS"),
            RoundedMoney.of(-23123213, "USN"), RoundedMoney.of(0, "GBP")};
    for (RoundedMoney money : moneys) {
        assertEquals(money.query(q), (Integer) money.getPrecision());
    }
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:21,
代码来源:RoundedMoneyTest.java

示例2: testQuery

点赞 3

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Test method for {@link FastMoney#query(javax.money.MonetaryQuery)}.
 */
@Test
public void testQuery(){
    MonetaryQuery<Integer> q = new MonetaryQuery<Integer>() {
        @Override
        public Integer queryFrom(MonetaryAmount amount) {
            return FastMoney.from(amount).getPrecision();
        }
    };
    FastMoney[] moneys = new FastMoney[]{FastMoney.of(100, "CHF"), FastMoney.of(34242344, "USD"),
            FastMoney.of(23123213.435, "EUR"), FastMoney.of(-23123213.435, "USS"), FastMoney.of(-23123213, "USN"),
            FastMoney.of(0, "GBP")};
    for (FastMoney money : moneys) {
        assertEquals(money.query(q), (Integer) money.getPrecision());
    }
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:19,
代码来源:FastMoneyTest.java

示例3: testQuery

点赞 2

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Test method for {@link Money#query(javax.money.MonetaryQuery)}.
 */
@Test
public void testQuery() {
    MonetaryQuery<Integer> q = new MonetaryQuery<Integer>(){
        @Override
        public Integer queryFrom(MonetaryAmount amount) {
            return Money.from(amount).getNumber().getPrecision();
        }
    };
    Money[] moneys = new Money[]{Money.of(100, "CHF"), Money.of(34242344, "USD"), Money.of(23123213.435, "EUR"),
            Money.of(-23123213.435, "USS"), Money.of(-23123213, "USN"), Money.of(0, "GBP")};
    for (Money money : moneys) {
        assertEquals(money.query(q), Integer.valueOf(money.getNumber().getPrecision()));
    }
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:18,
代码来源:MoneyTest.java

示例4: testQuery

点赞 2

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Test method for {@link org.javamoney.moneta.FastMoney#query(javax.money.MonetaryQuery)}.
 */
@Test
public void testQuery() {
    MonetaryQuery<Integer> q = amount -> FastMoney.from(amount).getPrecision();
    FastMoney[] moneys = new FastMoney[]{FastMoney.of(100, "CHF"), FastMoney.of(34242344, "USD"),
            FastMoney.of(23123213.435, "EUR"), FastMoney.of(-23123213.435, "USS"), FastMoney.of(-23123213, "USN"),
            FastMoney.of(0, "GBP")};
    for (FastMoney money : moneys) {
        assertEquals(money.query(q), (Integer) money.getPrecision());
    }
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri,
代码行数:14,
代码来源:FastMoneyTest.java

示例5: main

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
public static void main(String[] args) {
    MonetaryQuery<Long> longQuery = m -> m.getNumber().longValue();
    MonetaryQuery<String> currencyCodeQuery = m -> m.getCurrency().getCurrencyCode();
    MonetaryQuery<Integer> fractionDigits = m -> m.getCurrency().getDefaultFractionDigits();


}
 

开发者ID:otaviojava,
项目名称:money-api-book-samples,
代码行数:8,
代码来源:MonetaryQueryExamples.java

示例6: minorUnits

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Access the shared instance of {@link MinorUnits} for use.
 *
 * @return the shared instance, never {@code null}.
 */
public static MonetaryQuery<Long> minorUnits() {
    return MINORUNITS;
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:9,
代码来源:MonetaryUtil.java

示例7: majorUnits

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Access the shared instance of {@link MajorUnits} for use.
 *
 * @return the shared instance, never {@code null}.
 */
public static MonetaryQuery<Long> majorUnits() {
    return MAJORUNITS;
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:9,
代码来源:MonetaryUtil.java

示例8: extractMajorPart

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Allows to extract the major part of a {@link MonetaryAmount} instance.
 * Gets the amount in major units as a {@code long}.
 * <p>
 * For example, 'EUR 2.35' will return 2, and 'BHD -1.345' will return -1.
 * </p>
 *
 * <pre>
 * {
 * 	@code
 * 	MonetaryAmount monetaryAmount = Money.parse(&quot;EUR 2.35&quot;);
 * 	Long result = monetaryAmount.query(MonetaryQueries.majorPart());// 2L
 * }
 * </pre>
 */
public static MonetaryQuery<Long> extractMajorPart() {
	return EXTRACTOR_MAJOR_PART;
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:19,
代码来源:MonetaryQueries.java

示例9: convertMinorPart

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Convert to minor part a {@link MonetaryAmount} instance.
 * <p>
 * This returns the monetary amount in terms of the minor units of the
 * currency, truncating the amount if necessary. For example, 'EUR 2.35'
 * will return 235, and 'BHD -1.345' will return -1345.
 * </p>
 * </p>
 *
 * <pre>
 * {
 * 	@code
 * 	MonetaryAmount monetaryAmount = Money.parse(&quot;EUR 2.35&quot;);
 * 	Long result = monetaryAmount.query(MonetaryQueries.convertMinorPart());// 235L
 * }
 * </pre>
 *
 */
public static MonetaryQuery<Long> convertMinorPart() {
	return CONVERT_MINOR_PART;
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:22,
代码来源:MonetaryQueries.java

示例10: extractMinorPart

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Convert to minor part a {@link MonetaryAmount} instance.
 * <p>
 * This returns the monetary amount in terms of the minor units of the
 * currency, truncating the whole part if necessary. For example, 'EUR 2.35'
 * will return 35, and 'BHD -1.345' will return -345.
 * </p>
 *
 * <pre>
 * {
 * 	@code
 * 	MonetaryAmount monetaryAmount = Money.parse(&quot;EUR 2.35&quot;);
 * 	Long result = monetaryAmount.query(MonetaryQueries.convertMinorPart());// 35L
 * }
 * </pre>
 *
 */
public static MonetaryQuery<Long> extractMinorPart() {
	return EXTRACTOR_MINOR_PART;
}
 

开发者ID:JavaMoney,
项目名称:jsr354-ri-bp,
代码行数:21,
代码来源:MonetaryQueries.java

示例11: getCountingQuery

点赞 1

import javax.money.MonetaryQuery; //导入依赖的package包/类
/**
 * Implement a {@link javax.money.MonetaryQuery} that return {@code true} for each amount, that has an ISO
 * currency (as available on {@link java.util.Currency}.
 */
public MonetaryQuery<Boolean> getCountingQuery() {
    throw new UnsupportedOperationException();
}
 

开发者ID:atsticks,
项目名称:moneymachine,
代码行数:8,
代码来源:MoneyAlgorithmics.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)