當前位置: 首頁>>代碼示例>>Java>>正文


Java Future類代碼示例

本文整理匯總了Java中javax.validation.constraints.Future的典型用法代碼示例。如果您正苦於以下問題:Java Future類的具體用法?Java Future怎麽用?Java Future使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Future類屬於javax.validation.constraints包,在下文中一共展示了Future類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFuture

import javax.validation.constraints.Future; //導入依賴的package包/類
@Test
public void testFuture() {
	Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, Future.class);
	assertNotNull(violations);
	assertEquals(violations.size(), 1);

	if (runPeformance) {
		long time = System.currentTimeMillis();
		for (int index = 0; index < 10000; index++) {
			validator.validate(obj, Future.class);
		}
		long used = System.currentTimeMillis() - time;
		System.out.println("Hibernate Validator [Future] check used " + used + "ms, avg. " + ((double) used)
				/ 10000 + "ms.");
	}
}
 
開發者ID:bradwoo8621,項目名稱:nest-old,代碼行數:17,代碼來源:TestObject.java

示例2: convert

import javax.validation.constraints.Future; //導入依賴的package包/類
private void convert(MetaDataEntry metaData, Map<String, Object> result) {
    if (NotNull.class.getName().equals(metaData.getKey())) {
        result.put(CommonMetaDataKeys.REQUIRED.getKey(), Boolean.TRUE);
    }
    if (Size.class.getName().equals(metaData.getKey())) {
        Size size = (Size) metaData.getValue();
        if (size.max() < Integer.MAX_VALUE) {
            result.put(CommonMetaDataKeys.SIZE.getKey(), size.max());
        }
    }
    if (Past.class.getName().equals(metaData.getKey())) {
        result.put(CommonMetaDataKeys.PAST.getKey(), Boolean.TRUE);
    }
    if (Future.class.getName().equals(metaData.getKey())) {
        result.put(CommonMetaDataKeys.FUTURE.getKey(), Boolean.TRUE);
    }
}
 
開發者ID:atbashEE,項目名稱:jsf-renderer-extensions,代碼行數:18,代碼來源:BeanValidationMetaDataTransformer.java

示例3: isValidSimpleConstraint

import javax.validation.constraints.Future; //導入依賴的package包/類
private static boolean isValidSimpleConstraint(String cName, String field, Object actual, LinkedList<String> err) {
	if ("required".equals(cName) && !required().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is required.", field));
		return false;
	} else if (matches(AssertFalse.class, cName) && !falsy().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be false.", field));
		return false;
	} else if (matches(AssertTrue.class, cName) && !truthy().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be true.", field));
		return false;
	} else if (matches(Future.class, cName) && !future().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be in the future.", field));
		return false;
	} else if (matches(Past.class, cName) && !past().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be in the past.", field));
		return false;
	} else if (matches(URL.class, cName) && !url().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is not a valid URL.", field));
		return false;
	} else if (matches(Email.class, cName) && !email().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is not a valid email.", field));
		return false;
	}
	return true;
}
 
開發者ID:Erudika,項目名稱:para,代碼行數:26,代碼來源:ValidationUtils.java

示例4: process

import javax.validation.constraints.Future; //導入依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
    if (!ctx.isAnnotationPresent(Future.class)) {
        return value;
    }
    return DateUtils.addDays(new Date(), 2);
}
 
開發者ID:randomito,項目名稱:randomito-all,代碼行數:8,代碼來源:FutureAnnotationPostProcessor.java

示例5: getDataEntrega

import javax.validation.constraints.Future; //導入依賴的package包/類
@Future
@NotNull
@Temporal(TemporalType.DATE)
@Column(name = "data_entrega", nullable = false)
public Date getDataEntrega() {
	return this.dataEntrega;
}
 
開發者ID:marcelothebuilder,項目名稱:webpedidos,代碼行數:8,代碼來源:Pedido.java

示例6: getStartDate

import javax.validation.constraints.Future; //導入依賴的package包/類
/**
 * Getter for the conference start date.
 *
 * @return the start date
 */
@Future
@NotNull
@Temporal(value = TemporalType.DATE)
@Column(nullable = false)
public Date getStartDate() {

	return startDate;
}
 
開發者ID:n-moser,項目名稱:Conference,代碼行數:14,代碼來源:Conference.java

示例7: getEndDate

import javax.validation.constraints.Future; //導入依賴的package包/類
/**
 * Getter for the conference end date.
 *
 * @return the end date
 */
@Future
@NotNull
@Temporal(value = TemporalType.DATE)
@Column(nullable = false)
public Date getEndDate() {

	return endDate;
}
 
開發者ID:n-moser,項目名稱:Conference,代碼行數:14,代碼來源:Conference.java

示例8: getCheckinDate

import javax.validation.constraints.Future; //導入依賴的package包/類
@Basic
   @Temporal(TemporalType.DATE)
   @Future
   @NotNull
   public Date getCheckinDate() {
return checkinDate;
   }
 
開發者ID:websphere,項目名稱:SpringPrimeFacesShowcase,代碼行數:8,代碼來源:Booking.java

示例9: getCheckoutDate

import javax.validation.constraints.Future; //導入依賴的package包/類
@Basic
   @Temporal(TemporalType.DATE)
   @Future
   @NotNull
   public Date getCheckoutDate() {
return checkoutDate;
   }
 
開發者ID:websphere,項目名稱:SpringPrimeFacesShowcase,代碼行數:8,代碼來源:Booking.java

示例10: mapBeanValidationParameter

import javax.validation.constraints.Future; //導入依賴的package包/類
private static void mapBeanValidationParameter(Annotation annotation, InstanceDescriptor element) {
  	SimpleTypeDescriptor typeDescriptor = (SimpleTypeDescriptor) element.getLocalType(false);
if (annotation instanceof AssertFalse)
  		typeDescriptor.setTrueQuota(0.);
  	else if (annotation instanceof AssertTrue)
  		typeDescriptor.setTrueQuota(1.);
  	else if (annotation instanceof DecimalMax)
  		typeDescriptor.setMax(String.valueOf(DescriptorUtil.convertType(((DecimalMax) annotation).value(), typeDescriptor)));
  	else if (annotation instanceof DecimalMin)
  		typeDescriptor.setMin(String.valueOf(DescriptorUtil.convertType(((DecimalMin) annotation).value(), typeDescriptor)));
  	else if (annotation instanceof Digits) {
  		Digits digits = (Digits) annotation;
	typeDescriptor.setGranularity(String.valueOf(Math.pow(10, - digits.fraction())));
  	} else if (annotation instanceof Future)
       typeDescriptor.setMin(new SimpleDateFormat("yyyy-MM-dd").format(TimeUtil.tomorrow()));
      else if (annotation instanceof Max)
	typeDescriptor.setMax(String.valueOf(((Max) annotation).value()));
      else if (annotation instanceof Min)
  		typeDescriptor.setMin(String.valueOf(((Min) annotation).value()));
  	else if (annotation instanceof NotNull) {
  		element.setNullable(false);
  		element.setNullQuota(0.);
  	} else if (annotation instanceof Null) {
  		element.setNullable(true);
  		element.setNullQuota(1.);
  	} else if (annotation instanceof Past)
       typeDescriptor.setMax(new SimpleDateFormat("yyyy-MM-dd").format(TimeUtil.yesterday()));
      else if (annotation instanceof Pattern)
  		typeDescriptor.setPattern(String.valueOf(((Pattern) annotation).regexp()));
  	else if (annotation instanceof Size) {
  		Size size = (Size) annotation;
  		typeDescriptor.setMinLength(size.min());
  		typeDescriptor.setMaxLength(size.max());
  	}
  }
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:36,代碼來源:AnnotationMapper.java

示例11: incudeInValidation

import javax.validation.constraints.Future; //導入依賴的package包/類
@Override
public boolean incudeInValidation(Future futureAnnotation, RequestHandler requestHandler, ValidationContext validationCtx) {
    return true;
}
 
開發者ID:geetools,項目名稱:geeMVC-Java-MVC-Framework,代碼行數:5,代碼來源:FutureValidationAdapter.java

示例12: validate

import javax.validation.constraints.Future; //導入依賴的package包/類
@Override
public void validate(Future futureAnnotation, String name, ValidationContext validationCtx, Errors errors) {
    Object value = validationCtx.value(name);

    if (value == null)
        return;

    if (!(value instanceof Date))
        errors.add(name, futureAnnotation.message(), value);

    LocalDate inputDate = ((Date) value).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

    if (tomorrow().isBefore(inputDate) || tomorrow().isEqual(inputDate))
        errors.add(name, futureAnnotation.message(), value);

}
 
開發者ID:geetools,項目名稱:geeMVC-Java-MVC-Framework,代碼行數:17,代碼來源:FutureValidationAdapter.java

示例13: initialize

import javax.validation.constraints.Future; //導入依賴的package包/類
@Override
public void initialize(Future constraintAnnotation) {
}
 
開發者ID:bhits,項目名稱:common-libraries,代碼行數:4,代碼來源:FutureValidatorForLocalDate.java

示例14: initialize

import javax.validation.constraints.Future; //導入依賴的package包/類
@Override
public void initialize(final Future constraintAnnotation) {}
 
開發者ID:ManfredTremmel,項目名稱:gwt-bean-validators,代碼行數:3,代碼來源:FutureValidatorForCalendar.java

示例15: showDate

import javax.validation.constraints.Future; //導入依賴的package包/類
@Future
public Date showDate(boolean correct) {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, correct ? 5 : -5);
    return cal.getTime();
}
 
開發者ID:ftomassetti,項目名稱:JavaIncrementalParser,代碼行數:7,代碼來源:MyBean.java


注:本文中的javax.validation.constraints.Future類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。