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