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


Java AssertFalse类代码示例

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


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

示例1: testAssertFalse

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

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

示例2: checkAnnotations

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
private void checkAnnotations(Class<?> contractClass) {
    Field[] fields = contractClass.getFields();
    for (Field field : fields) {
        Class fieldType = field.getType();
        if (Optional.class.isAssignableFrom(fieldType)) {
            checkAnnotation(contractClass, field,UnwrapValidatedValue.class);
            checkNoAnnotation(contractClass, field, NotNull.class);
        }
        else {
            checkNoAnnotation(contractClass, field, UnwrapValidatedValue.class);
            checkAnnotation(contractClass, field,NotNull.class);
        }
    }

    for(Method method : contractClass.getMethods()) {
        if(method.isAnnotationPresent(AssertTrue.class) || method.isAnnotationPresent(AssertFalse.class)) {
            if(method.getReturnType() != boolean.class && method.getReturnType() != Boolean.class) {
                throw new IllegalStateException("AssertTrue or AssertFalse annotations must be placed above methods that return boolean value");
            }

            if(!method.getName().startsWith("is")) {
                throw new IllegalStateException("Methods annotated with AssertTrue or AssertFalse must start with \"is\"");
            }
        }
    }
}
 
开发者ID:forter,项目名称:storm-data-contracts,代码行数:27,代码来源:ContractsBoltReflector.java

示例3: isValidSimpleConstraint

import javax.validation.constraints.AssertFalse; //导入依赖的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: buildAssertFalseValidator

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
private static MinijaxConstraintDescriptor<AssertFalse> buildAssertFalseValidator(final AssertFalse assertFalse, final Class<?> valueClass) {
    if (valueClass == boolean.class || valueClass == Boolean.class) {
        return new MinijaxConstraintDescriptor<>(assertFalse, AssertFalseValidator.INSTANCE);
    }

    throw new ValidationException("Unsupported type for @AssertFalse annotation: " + valueClass);
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:MinijaxConstraintDescriptor.java

示例5: process

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
    if (!ctx.isAnnotationPresent(AssertFalse.class)) {
        return value;
    }
    return false;
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:8,代码来源:AssertFalseAnnotationPostProcessor.java

示例6: validate

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@Override
public void validate(AssertFalse assertFalseAnnotation, String name, ValidationContext validationCtx, Errors errors) {
    Object value = validationCtx.value(name);

    boolean isFalse = false;

    if (value != null && value instanceof Boolean)
        isFalse = Boolean.FALSE.equals(value);

    if (!isFalse)
        errors.add(name, assertFalseAnnotation.message(), value);
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:13,代码来源:AssertFalseValidationAdapter.java

示例7: verifyThatTheReflectionsConfigurationIsCapturingAllAnnotationPossibilities

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
/**
 * Makes sure that the Reflections helper stuff is working properly and capturing all annotation possibilities (class type, constructor, constructor param, method, method param, and field).
 */
@Test
public void verifyThatTheReflectionsConfigurationIsCapturingAllAnnotationPossibilities() {
    List<Pair<Annotation, AnnotatedElement>> annotationOptionsClassAnnotations = getSubAnnotationListForElementsOfOwnerClass(TROLLER.allConstraintAnnotationsMasterList,
            DifferentValidationAnnotationOptions.class);
    assertThat(annotationOptionsClassAnnotations.size(), is(10));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, SomeClassLevelJsr303Annotation.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, OtherClassLevelJsr303Annotation.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, AssertTrue.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, AssertFalse.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, NotNull.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, Min.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, Max.class).size(), is(1));
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:17,代码来源:ReflectionMagicWorksTest.java

示例8: annotatedMethod

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@AssertFalse(message = "I am an annotated method")
public boolean annotatedMethod(String nonAnnotatedMethodParam,
                               @Max(value = 42, message = "I am an annotated method param 1") Integer annotatedMethodParam1,
                               @Min(value = 42, message = "I am an annotated method param 2") Integer annotatedMethodParam2,
                               String alsoNotAnnotatedMethodParam) {
    return true;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:8,代码来源:ReflectionMagicWorksTest.java

示例9: mapBeanValidationParameter

import javax.validation.constraints.AssertFalse; //导入依赖的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

示例10: isGeolocationSourceNull

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@AssertFalse
public boolean isGeolocationSourceNull() {
    return getGeoLocation().getSource() == null;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:5,代码来源:ObservationDTOBase.java

示例11: incudeInValidation

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@Override
public boolean incudeInValidation(AssertFalse validationAnnotation, RequestHandler requestHandler, ValidationContext validationCtx) {
    return true;
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:5,代码来源:AssertFalseValidationAdapter.java

示例12: isInvalid

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@AssertFalse(message = "both 'username' and 'password' are required or neither one")
private boolean isInvalid() {
	return StringUtils.hasText(this.username) ^ StringUtils.hasText(this.password);
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:cassandra,代码行数:5,代码来源:CassandraProperties.java

示例13: isMutuallyExclusive

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@AssertFalse
public boolean isMutuallyExclusive() {
    return this.date != null && this.cron != null && this.fixedDelay != 1;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:5,代码来源:TriggerPropertiesMaxMessagesDefaultOne.java

示例14: isMutuallyExclusive

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
@AssertFalse
boolean isMutuallyExclusive();
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:3,代码来源:TriggerProperties.java

示例15: appendFalseValidator

import javax.validation.constraints.AssertFalse; //导入依赖的package包/类
private void appendFalseValidator(SourceWriter w, JField field) {
	AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class);
	if (falseAnnotation != null) {
		w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java


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