java类javax.validation.constraints.Digits的实例源码

DigitsAnnotationPostProcessor.java 文件源码 项目:randomito-all 阅读 20 收藏 0 点赞 0 评论 0
@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());
}
ToDoItem.java 文件源码 项目:isis-app-todoapp 阅读 25 收藏 0 点赞 0 评论 0
@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;
}
TestObject.java 文件源码 项目:nest-old 阅读 25 收藏 0 点赞 0 评论 0
@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.");
    }
}
Constraint.java 文件源码 项目:para 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
                    }
                };
    }
}
IncomingDocViewModel.java 文件源码 项目:estatio 阅读 16 收藏 0 点赞 0 评论 0
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;
}
IncomingInvoice.java 文件源码 项目:estatio 阅读 19 收藏 0 点赞 0 评论 0
@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;
}
IncomingInvoiceItem.java 文件源码 项目:estatio 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
OrderItem.java 文件源码 项目:estatio 阅读 26 收藏 0 点赞 0 评论 0
@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;
}
Order.java 文件源码 项目:estatio 阅读 26 收藏 0 点赞 0 评论 0
@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;
}
TypeSafeActivator.java 文件源码 项目:lams 阅读 24 收藏 0 点赞 0 评论 0
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 );
    }
}
OrderItem.java 文件源码 项目:my-paper 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 获取商品价格
 * 
 * @return 商品价格
 */
@JsonProperty
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getPrice() {
    return price;
}
Member.java 文件源码 项目:my-paper 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 获取余额
 * 
 * @return 余额
 */
@NotNull(groups = Save.class)
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 27, scale = 12)
public BigDecimal getBalance() {
    return balance;
}
Payment.java 文件源码 项目:my-paper 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 获取付款金额
 * 
 * @return 付款金额
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, updatable = false, precision = 21, scale = 6)
public BigDecimal getAmount() {
    return amount;
}
Order.java 文件源码 项目:my-paper 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 获取运费
 * 
 * @return 运费
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getFreight() {
    return freight;
}
Order.java 文件源码 项目:my-paper 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 获取调整金额
 * 
 * @return 调整金额
 */
@NotNull
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getOffsetAmount() {
    return offsetAmount;
}
Order.java 文件源码 项目:my-paper 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 获取税金
 * 
 * @return 税金
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getTax() {
    return tax;
}
Promotion.java 文件源码 项目:my-paper 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 获取最小商品价格
 * 
 * @return 最小商品价格
 */
@JsonProperty
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(precision = 21, scale = 6)
public BigDecimal getMinimumPrice() {
    return minimumPrice;
}
Promotion.java 文件源码 项目:my-paper 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 获取最大商品价格
 * 
 * @return 最大商品价格
 */
@JsonProperty
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(precision = 21, scale = 6)
public BigDecimal getMaximumPrice() {
    return maximumPrice;
}
Refunds.java 文件源码 项目:my-paper 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 获取退款金额
 * 
 * @return 退款金额
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, updatable = false, precision = 21, scale = 6)
public BigDecimal getAmount() {
    return amount;
}
Shipping.java 文件源码 项目:my-paper 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 获取物流费用
 * 
 * @return 物流费用
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(updatable = false, precision = 21, scale = 6)
public BigDecimal getFreight() {
    return freight;
}
Coupon.java 文件源码 项目:my-paper 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 获取最小商品价格
 * 
 * @return 最小商品价格
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(precision = 21, scale = 6)
public BigDecimal getMinimumPrice() {
    return minimumPrice;
}
Coupon.java 文件源码 项目:my-paper 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 获取最大商品价格
 * 
 * @return 最大商品价格
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(precision = 21, scale = 6)
public BigDecimal getMaximumPrice() {
    return maximumPrice;
}
Returns.java 文件源码 项目:my-paper 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 获取物流费用
 * 
 * @return 物流费用
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(updatable = false, precision = 21, scale = 6)
public BigDecimal getFreight() {
    return freight;
}
MemberRank.java 文件源码 项目:my-paper 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 获取优惠比例
 * 
 * @return 优惠比例
 */
@NotNull
@Min(0)
@Digits(integer = 3, fraction = 3)
@Column(nullable = false, precision = 12, scale = 6)
public Double getScale() {
    return scale;
}
MemberRank.java 文件源码 项目:my-paper 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 获取消费金额
 * 
 * @return 消费金额
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(unique = true, precision = 21, scale = 6)
public BigDecimal getAmount() {
    return amount;
}
ShippingMethod.java 文件源码 项目:my-paper 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 获取首重价格
 * 
 * @return 首重价格
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getFirstPrice() {
    return firstPrice;
}
ShippingMethod.java 文件源码 项目:my-paper 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 获取续重价格
 * 
 * @return 续重价格
 */
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getContinuePrice() {
    return continuePrice;
}
Product.java 文件源码 项目:my-paper 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 获取销售价
 * 
 * @return 销售价
 */
@JsonProperty
@Field(store = Store.YES, index = Index.UN_TOKENIZED)
@NumericField
@FieldBridge(impl = BigDecimalNumericFieldBridge.class)
@NotNull
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getPrice() {
    return price;
}
Product.java 文件源码 项目:my-paper 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 获取成本价
 * 
 * @return 成本价
 */
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(precision = 21, scale = 6)
public BigDecimal getCost() {
    return cost;
}
Product.java 文件源码 项目:my-paper 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 获取市场价
 * 
 * @return 市场价
 */
@Field(store = Store.YES, index = Index.NO)
@Min(0)
@Digits(integer = 12, fraction = 3)
@Column(nullable = false, precision = 21, scale = 6)
public BigDecimal getMarketPrice() {
    return marketPrice;
}


问题


面经


文章

微信
公众号

扫码关注公众号