微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.validation.constraints.Null的实例源码

项目:nest-old    文件TestObject.java   
@Test
public void testAssertNull() {
    Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj,Null.class);
    assertNotNull(violations);
    assertEquals(violations.size(),1);

    if (runPeformance) {
        long time = System.currentTimeMillis();
        for (int index = 0; index < 10000; index++) {
            validator.validate(obj,Null.class);
        }
        long used = System.currentTimeMillis() - time;
        System.out.println("Hibernate Validator [Null] check used " + used + "ms,avg. " + ((double) used) / 10000
                + "ms.");
    }
}
项目:geomajas-project-server    文件BeanDeFinitionDtoConverterServiceImpl.java   
/**
 * Take a stab at fixing validation problems ?
 * 
 * @param object
 */
private void validate(Object object) {
    Set<ConstraintViolation<Object>> viols = validator.validate(object);
    for (ConstraintViolation<Object> constraintViolation : viols) {
        if (Null.class.isAssignableFrom(constraintViolation.getConstraintDescriptor().getAnnotation().getClass())) {
            Object o = constraintViolation.getLeafBean();
            Iterator<Node> iterator = constraintViolation.getPropertyPath().iterator();
            String propertyName = null;
            while (iterator.hasNext()) {
                propertyName = iterator.next().getName();
            }
            if (propertyName != null) {
                try {
                    PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(o.getClass(),propertyName);
                    descriptor.getWriteMethod().invoke(o,new Object[] { null });
                } catch (Exception e) {
                    e.printstacktrace();
                }
            }
        }
    }
}
项目:beanvalidation-benchmark    文件JSR303Annotator.java   
/**
 * @return The list of constraints for fields that reference other beans.
 */
private List<MetaAnnotation> buildrefFieldAnnotations() {
    List<MetaAnnotation> anns = Lists.newArrayList();
    HashMap<String,Object> annotParams;

    annotParams = Maps.newHashMap();
    anns.add(new MetaAnnotation(codemodel,NotNull.class,AnnotationType.JSR_303,annotParams));
    annotParams = Maps.newHashMap();
    anns.add(new MetaAnnotation(codemodel,Null.class,annotParams));
    return anns;
}
项目:randomito-all    文件NullAnnotationPostProcessor.java   
@Override
public Object process(AnnotationInfo ctx,Object value) throws Exception {
    if (!ctx.isAnnotationPresent(Null.class)) {
        return value;
    }
    return null;
}
项目:holdmail    文件MessageService.java   
public MessageList findMessages(@Null @Email String recipientEmail,Pageable pageRequest) {

        List<MessageEntity> entities;

        if (StringUtils.isBlank(recipientEmail)) {
            entities = messageRepository.findAllByOrderByReceivedDateDesc(pageRequest);
        }
        else {
            entities = messageRepository.findAllForRecipientOrderByReceivedDateDesc(recipientEmail,pageRequest);
        }

        return messageListMapper.toMessageList(entities);
    }
项目:apex-malhar    文件NegateExpression.java   
/**
 * @param column   Name of column value to be negated.
 */
public NegateExpression(@Null String column,String alias)
{
  super(column,alias);
  if (this.alias == null) {
    this.alias = "NEGATE(" + column + ")";
  }
}
项目:dwoss    文件StockTransaction.java   
@Null(message = "ValidationViolation must be null. ValidationMessage: ${validatedValue}")
public String getValidationViolations() {
    List<StockTransactionStatus> sortedList = new ArrayList<>(getStatusHistory());
    Collections.sort(sortedList);
    List<StockTransactionStatusType> sortedTypeList = new ArrayList<>();
    for (StockTransactionStatus stockTransactionStatus : sortedList) {
        sortedTypeList.add(stockTransactionStatus.getType());
    }

    if ( POSSIBLE_STATUS_TYPES.contains(sortedTypeList) ) return null;
    return "TransactionStatusHistory is in invalid. Statuses=" + sortedList + " AllowedTypes=" + POSSIBLE_STATUS_TYPES;
}
项目:dwoss    文件Product.java   
/**
 * Returns null if the instance is valid,or a string representing the error.
 * <p>
 * @return null if the instance is valid,or a string representing the error.
 */
@Null(message = "ViolationMessage is not null,but '${validatedValue}'")
public String getViolationMessage() {
    if ( TradeName == null ) return null;
    if ( !TradeName.isBrand() ) return TradeName + " is not a Brand";
    if ( TradeName.getManufacturer().getPartNoSupport() == null ) return null; // No Support,so everything is ok.
    return TradeName.getManufacturer().getPartNoSupport().violationMessages(partNo);
}
项目:dwoss    文件ProductSpec.java   
/**
 * Returns null if the instance is valid,but '${validatedValue}'")
public String getViolationMessage() {
    if ( model == null
            || model.getFamily() == null
            || model.getFamily().getSeries() == null
            || model.getFamily().getSeries().getBrand() == null
            || model.getFamily().getSeries().getBrand().getManufacturer().getPartNoSupport() == null )
        return null;
    return model.getFamily().getSeries().getBrand().getManufacturer().getPartNoSupport().violationMessages(partNo);
}
项目:benerator    文件AnnotationMapper.java   
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());
    }
  }
项目:school-express-delivery    文件Assert.java   
public static void checkNotEqual(@Null Object type,@NotNull Object target,ErrorCode errorCode) {
    if (!target.equals(type)) {
        throw new SedException(errorCode);
    }
}
项目:geeMVC-Java-MVC-Framework    文件NullValidationAdapter.java   
@Override
public boolean incudeInValidation(Null nullAnnotation,RequestHandler requestHandler,ValidationContext validationCtx) {
    return true;
}
项目:geeMVC-Java-MVC-Framework    文件NullValidationAdapter.java   
@Override
public void validate(Null nullAnnotation,String name,ValidationContext validationCtx,Errors e) {
    if (validationCtx.value(name) != null)
        e.add(name,nullAnnotation.message());
}
项目:sam    文件Server.java   
@Null(groups = { Create.class,Update.class })
public String getId() {
  return id;
}
项目:sam    文件Server.java   
@Null(groups = { Create.class,Update.class })
public String getName() {
  return name;
}
项目:ValidateFX    文件NullObservableValueValidator.java   
@Override
public void initialize(Null constraintAnnotation) {
}
项目:dolphin-platform    文件NullPropertyValidator.java   
@Override
public void initialize(Null constraintAnnotation) {
}
项目:dwoss    文件ProductSeries.java   
/**
 * Instance Validation. Validates: value brand is a brand.
 * <p>
 * @return null if valid,or a error message
 */
@Null(message = "ViolationMessage is not null,but '${validatedValue}'")
public String getViolationMessage() {
    if ( brand != null && !brand.isBrand() ) return brand.getName() + " is not a Brand";
    return null;
}
项目:dwoss    文件display.java   
@Null(message = "ViolationMessage is not null,but '${validatedValue}'")
public String getValidationViolations() {
    if ( resolution.ordinal() > size.getMaxResolution().ordinal() ) return "resolution > size.maxResolution";
    return null;
}
项目:putnami-web-toolkit    文件ModelCreator.java   
private void appendNullValidator(SourceWriter w,JField field) {
    Null nullAnnotation = field.getAnnotation(Null.class);
    if (nullAnnotation != null) {
        w.println(",new NullValidator(\"%s\")",nullAnnotation.message());
    }
}
项目:pexel-platform    文件InventoryImpl.java   
@Override
public void setSlotContents(final int slot,@Null final ItemStack itemStack) {
    this.slots[slot] = itemStack;
}
项目:gbif-api    文件Download.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Nullable
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Download.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Nullable
public Date getModified() {
  return modified;
}
项目:gbif-api    文件GbifUser.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Integer getKey() {
  return key;
}
项目:gbif-api    文件Identifier.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Min(1)
public Integer getKey() {
  return key;
}
项目:gbif-api    文件Identifier.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Endpoint.java   
@Null(groups = PrePersist.class)
@NotNull(groups = PostPersist.class)
@Min(1)
public Integer getKey() {
  return key;
}
项目:gbif-api    文件Endpoint.java   
@Null(groups = PrePersist.class)
@NotNull(groups = PostPersist.class)
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Endpoint.java   
@Null(groups = PrePersist.class)
@NotNull(groups = PostPersist.class)
public Date getModified() {
  return modified;
}
项目:gbif-api    文件Contact.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Integer getKey() {
  return key;
}
项目:gbif-api    文件Contact.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Contact.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Date getModified() {
  return modified;
}
项目:gbif-api    文件NetworkEntity.java   
@Nullable
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
UUID getKey();
项目:gbif-api    文件NetworkEntity.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Nullable
Date getCreated();
项目:gbif-api    文件NetworkEntity.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Nullable
Date getModified();
项目:gbif-api    文件Tag.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Min(1)
public Integer getKey() {
  return key;
}
项目:gbif-api    文件Tag.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Installation.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Override
public UUID getKey() {
  return key;
}
项目:gbif-api    文件Installation.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Override
public Date getCreated() {
  return created;
}
项目:gbif-api    文件Installation.java   
@Null(groups = {PrePersist.class})
@NotNull(groups = {PostPersist.class})
@Override
public Date getModified() {
  return modified;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。