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


Java Digits类代码示例

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


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

示例1: process

import javax.validation.constraints.Digits; //导入依赖的package包/类
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
    if (!ctx.isAnnotationPresent(Digits.class)) {
        return value;
    }

    int integrals = ctx.getAnnotation(Digits.class).integer();
    String number = "0";
    if (integrals > 0) {
        number = RandomStringUtils.randomNumeric(integrals);
    }
    int fractions = ctx.getAnnotation(Digits.class).fraction();
    if (fractions > 0) {
        number += "." + RandomStringUtils.randomNumeric(fractions);
    }
    return ReflectionUtils.stringToNumber(number, value.getClass());
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:18,代码来源:DigitsAnnotationPostProcessor.java

示例2: updateCost

import javax.validation.constraints.Digits; //导入依赖的package包/类
@Action(
        semantics = SemanticsOf.IDEMPOTENT
)
public ToDoItem updateCost(
        @Parameter(optionality = Optionality.OPTIONAL)
        @Digits(integer = 10, fraction = 2)
        final BigDecimal newCost) {
    final String titleOf = titleService.titleOf(this);
    LOG.debug("%s: cost updated: %s -> %s", titleOf, getCost(), newCost);

    // just to simulate a long-running action
    try {
        Thread.sleep(3000);
    } catch (final InterruptedException ignored) {
    }

    setCost(newCost);
    return this;
}
 
开发者ID:isisaddons,项目名称:isis-app-todoapp,代码行数:20,代码来源:ToDoItem.java

示例3: testDigits

import javax.validation.constraints.Digits; //导入依赖的package包/类
@Test
public void testDigits() {
	Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, Digits.class);
	assertNotNull(violations);
	assertEquals(violations.size(), 1);

	if (runPeformance) {
		long time = System.currentTimeMillis();
		for (int index = 0; index < 10000; index++) {
			validator.validate(obj, Digits.class);
		}
		long used = System.currentTimeMillis() - time;
		System.out.println("Hibernate Validator [Digits] check used " + used + "ms, avg. " + ((double) used)
				/ 10000 + "ms.");
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:17,代码来源:TestObject.java

示例4: fromAnnotation

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * Builds a new constraint from the annotation data.
 * @param anno JSR-303 annotation instance
 * @return a new constraint
 */
public static Constraint fromAnnotation(Annotation anno) {
	if (anno instanceof Min) {
		return min(((Min) anno).value());
	} else if (anno instanceof Max) {
		return max(((Max) anno).value());
	} else if (anno instanceof Size) {
		return size(((Size) anno).min(), ((Size) anno).max());
	} else if (anno instanceof Digits) {
		return digits(((Digits) anno).integer(), ((Digits) anno).fraction());
	} else if (anno instanceof Pattern) {
		return pattern(((Pattern) anno).regexp());
	} else {
		return new Constraint(VALIDATORS.get(anno.annotationType()),
				simplePayload(VALIDATORS.get(anno.annotationType()))) {
					public boolean isValid(Object actualValue) {
						return true;
					}
				};
	}
}
 
开发者ID:Erudika,项目名称:para,代码行数:26,代码来源:Constraint.java

示例5: changeItemDetails

import javax.validation.constraints.Digits; //导入依赖的package包/类
public IncomingDocViewModel changeItemDetails(
        final String description,
        @Digits(integer=13, fraction = 2)
        final BigDecimal netAmount,
        @Digits(integer=13, fraction = 2)
        @Nullable
        final BigDecimal vatAmount,
        @Nullable
        final Tax tax,
        @Digits(integer=13, fraction = 2)
        @Nullable
        final BigDecimal grossAmount
){
    setDescription(description);
    setNetAmount(netAmount);
    setVatAmount(vatAmount);
    setTax(tax);
    setGrossAmount(grossAmount);
    calculateVat();
    determineAmounts();
    return this;
}
 
开发者ID:estatio,项目名称:estatio,代码行数:23,代码来源:IncomingDocViewModel.java

示例6: addItem

import javax.validation.constraints.Digits; //导入依赖的package包/类
@MemberOrder(name="items", sequence = "1")
public IncomingInvoice addItem(
        final IncomingInvoiceType type,
        final Charge charge,
        final String description,
        @Digits(integer=13, fraction = 2)
        final BigDecimal netAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal vatAmount,
        @Digits(integer=13, fraction = 2)
        final BigDecimal grossAmount,
        @Nullable final Tax tax,
        @Nullable final LocalDate dueDate,
        @Nullable final String period,
        @Nullable final Property property,
        @Nullable final Project project,
        @Nullable final BudgetItem budgetItem) {

    addItemToThis(
            type, charge, description, netAmount, vatAmount, grossAmount, tax, dueDate,
            period, property, project, budgetItem);
    return this;
}
 
开发者ID:estatio,项目名称:estatio,代码行数:25,代码来源:IncomingInvoice.java

示例7: updateAmounts

import javax.validation.constraints.Digits; //导入依赖的package包/类
@Action(semantics = SemanticsOf.IDEMPOTENT)
public IncomingInvoiceItem updateAmounts(
        @Digits(integer=13, fraction = 2)
        final BigDecimal netAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal vatAmount,
        @Digits(integer=13, fraction = 2)
        final BigDecimal grossAmount,
        @Nullable
        final Tax tax){
    setNetAmount(netAmount);
    setVatAmount(vatAmount);
    setGrossAmount(grossAmount);
    setTax(tax);
    IncomingInvoice invoice = (IncomingInvoice) getInvoice();
    return this;
}
 
开发者ID:estatio,项目名称:estatio,代码行数:19,代码来源:IncomingInvoiceItem.java

示例8: updateAmounts

import javax.validation.constraints.Digits; //导入依赖的package包/类
@Action(semantics = SemanticsOf.IDEMPOTENT)
public OrderItem updateAmounts(
        @Digits(integer=13, fraction = 2)
        final BigDecimal netAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal vatAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal grossAmount,
        @Nullable
        final Tax tax){
    setNetAmount(netAmount);
    setVatAmount(vatAmount);
    setGrossAmount(grossAmount);
    setTax(tax);
    return this;
}
 
开发者ID:estatio,项目名称:estatio,代码行数:19,代码来源:OrderItem.java

示例9: addItem

import javax.validation.constraints.Digits; //导入依赖的package包/类
@MemberOrder(name="items", sequence = "1")
public Order addItem(
        final Charge charge,
        @Nullable final String description,
        @Digits(integer=13, fraction = 2)
        final BigDecimal netAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal vatAmount,
        @Nullable
        @Digits(integer=13, fraction = 2)
        final BigDecimal grossAmount,
        @Nullable final Tax tax,
        @Nullable final String period,
        @Nullable final org.estatio.module.asset.dom.Property property,
        @Nullable final Project project,
        @Nullable final BudgetItem budgetItem
) {
    orderItemRepository.upsert(
            this, charge, description, netAmount, vatAmount, grossAmount, tax, PeriodUtil.yearFromPeriod(period).startDate(), PeriodUtil.yearFromPeriod(period).endDate(), property, project, budgetItem);
    // (we think there's) no need to add to the getItems(), because the item points back to this order.
    return this;
}
 
开发者ID:estatio,项目名称:estatio,代码行数:24,代码来源:Order.java

示例10: applyDigits

import javax.validation.constraints.Digits; //导入依赖的package包/类
private static void applyDigits(Property property, ConstraintDescriptor<?> descriptor) {
	if ( Digits.class.equals( descriptor.getAnnotation().annotationType() ) ) {
		@SuppressWarnings("unchecked")
		ConstraintDescriptor<Digits> digitsConstraint = (ConstraintDescriptor<Digits>) descriptor;
		int integerDigits = digitsConstraint.getAnnotation().integer();
		int fractionalDigits = digitsConstraint.getAnnotation().fraction();
		Column col = (Column) property.getColumnIterator().next();
		col.setPrecision( integerDigits + fractionalDigits );
		col.setScale( fractionalDigits );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:TypeSafeActivator.java

示例11: getPrice

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * 获取商品价格
 * 
 * @return 商品价格
 */
@JsonProperty
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getPrice() {
	return price;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:14,代码来源:OrderItem.java

示例12: getBalance

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * 获取余额
 * 
 * @return 余额
 */
@NotNull(groups = Save.class)
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 27, scale = 12)
public BigDecimal getBalance() {
	return balance;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:13,代码来源:Member.java

示例13: getAmount

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * 获取付款金额
 * 
 * @return 付款金额
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, updatable = false, precision = 21, scale = 6)
public BigDecimal getAmount() {
	return amount;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:13,代码来源:Payment.java

示例14: getFreight

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * 获取运费
 * 
 * @return 运费
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getFreight() {
	return freight;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:13,代码来源:Order.java

示例15: getOffsetAmount

import javax.validation.constraints.Digits; //导入依赖的package包/类
/**
 * 获取调整金额
 * 
 * @return 调整金额
 */
@NotNull
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getOffsetAmount() {
	return offsetAmount;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:12,代码来源:Order.java


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