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


Java Payload类代码示例

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


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

示例1: ConstraintDescriptorImpl

import javax.validation.Payload; //导入依赖的package包/类
protected ConstraintDescriptorImpl(final T annotation, final Set<Class<?>> groups,
    final Set<Class<? extends Payload>> payload,
    final List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses,
    final Map<String, Object> attributes, final Set<ConstraintDescriptor<?>> composingConstraints,
    final boolean reportAsSingleViolation, final ElementType elementType,
    final ConstraintOrigin definedOn) {
  super();
  this.annotation = annotation;
  this.groups = groups;
  this.payload = payload;
  this.constraintValidatorClasses = constraintValidatorClasses;
  this.attributes = attributes;
  this.composingConstraints = composingConstraints;
  this.reportAsSingleViolation = reportAsSingleViolation;
  this.elementType = elementType;
  this.definedOn = definedOn;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:18,代码来源:ConstraintDescriptorImpl.java

示例2: buildTemplateConstraint

import javax.validation.Payload; //导入依赖的package包/类
private JDefinedClass buildTemplateConstraint(String name) {
    try {
        JDefinedClass tplConstraint = codeModel._class(Config.CFG.getBasePackageName() + ".annot."+name, ClassType.ANNOTATION_TYPE_DECL);
        tplConstraint.annotate(Documented.class);
        tplConstraint.annotate(Retention.class).param("value", RetentionPolicy.RUNTIME);
        tplConstraint.annotate(Target.class).paramArray("value").param(ElementType.TYPE).param(ElementType.ANNOTATION_TYPE).param(ElementType.FIELD).param(ElementType.METHOD);
        
        // Using direct as I don't know how to build default { } with code model
        tplConstraint.direct("\n" + "    Class<?>[] groups() default {};\n" + "    String message() default \"Invalid value\";\n" + "    Class<? extends Payload>[] payload() default {};\n");
        
        // Hack to force the import of javax.validation.Payload
        tplConstraint.javadoc().addThrows((JClass) codeModel._ref(Payload.class)).add("Force import");
        
        return tplConstraint;
    } catch (JClassAlreadyExistsException e) {
        throw new RuntimeException("Tried to create an already existing class: " + name, e);
    }
}
 
开发者ID:hibernate,项目名称:beanvalidation-benchmark,代码行数:19,代码来源:Jsr303Annotator.java

示例3: getConstraintSeverity

import javax.validation.Payload; //导入依赖的package包/类
/**
 * (non-Javadoc)
 * 
 * @see com.github.nest.arcteryx.meta.beans.IConstraintViolation#getConstraintSeverity()
 */
@SuppressWarnings("unchecked")
@Override
public ConstraintSeverity getConstraintSeverity() {
	Set<Class<? extends Payload>> payloads = this.getViolation().getConstraintDescriptor().getPayload();
	if (payloads == null || payloads.size() == 0) {
		return ConstraintSeverity.defaultSeverity();
	} else {
		// get first one
		Class<? extends Payload> payloadClass = payloads.iterator().next();
		if (HibernateSeverity.INFO.class == payloadClass) {
			return ConstraintSeverity.INFO;
		} else if (HibernateSeverity.WARN.class == payloadClass) {
			return ConstraintSeverity.WARN;
		} else if (HibernateSeverity.ERROR.class == payloadClass) {
			return ConstraintSeverity.ERROR;
		} else if (HibernateSeverity.FATAL.class == payloadClass) {
			return ConstraintSeverity.FATAL;
		} else {
			return ConstraintSeverity.defaultSeverity();
		}
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:28,代码来源:HibernateConstraintViolation.java

示例4: errorMessage

import javax.validation.Payload; //导入依赖的package包/类
private String errorMessage(ConstraintViolation<?> error) {
    Set<Class<? extends Payload>> payload = error.getConstraintDescriptor().getPayload();

    if (payload.contains(NoLogging.class)) {
        return error.getPropertyPath().toString() + ", " + error.getMessage();
    } else {
        return error.getPropertyPath().toString() + ", " + error.getMessage() + ", was: " + error.getInvalidValue();
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:10,代码来源:ConstraintViolationExceptionMapper.java

示例5: getMessage

import javax.validation.Payload; //导入依赖的package包/类
/**
 * Calculate a localized string message for a constraint violation.
 * <p>
 * If a labeled payload is present, the label of the payload is used as
 * template. Although not required, you are encouraged to use
 * {@link ValidationMessage} as base class for such payloads. If no labeled
 * payload is present and the message has the form "{......}", the string
 * without the brackets is used as key and the corresponding resource string
 * is used as template. Otherwise, the message is used directly as template.
 * 
 * <p>
 * When the template is determined, it is used to create a
 * {@link PatternString} . The arguments are the standard validation
 * arguments (all attributes of the constraint annotation) plus
 * "invalidValue" containing the value which has been validated.
 * 
 * <p>
 * finally the PatternString is resolved and returned as message.
 * 
 */
public LString getMessage(ConstraintViolation<?> violation) {

    // arguments for the message
    Map<String, Object> args = new HashMap<>();
    args.putAll(violation.getConstraintDescriptor().getAttributes());
    args.put("invalidValue", violation.getInvalidValue());

    // check for labeled payload
    {
        Optional<TranslatedString> pattern = violation.getConstraintDescriptor().getPayload().stream()
                .filter(Payload.class::isAssignableFrom).map(x -> labelUtil.type(x).tryLabel())
                .filter(x -> x.isPresent()).map(x -> x.get()).findFirst();
        if (pattern.isPresent())
            // we found a labeled payload. Use payload label as pattern
            return new PatternString(patternStringResolver, pattern.get(), args);
    }

    // check for resource key reference
    String messageTemplate = violation.getMessageTemplate();
    if (messageTemplate.startsWith("{") && messageTemplate.endsWith("}")) {
        return new PatternString(patternStringResolver, new TranslatedString(translatedStringResolver,
                messageTemplate.substring(1, messageTemplate.length() - 1)), args);
    }

    // fallback: just use the string as is as pattern
    return new PatternString(patternStringResolver, LString.of(messageTemplate), args);
}
 
开发者ID:ruediste,项目名称:rise,代码行数:48,代码来源:ValidationUtil.java

示例6: ConstraintDescriptorImpl

import javax.validation.Payload; //导入依赖的package包/类
protected ConstraintDescriptorImpl(final T pannotation, final Set<Class<?>> pgroups,
    final Set<Class<? extends Payload>> ppayload,
    final List<Class<? extends ConstraintValidator<T, ?>>> pconstraintValidatorClasses,
    final Map<String, Object> pattributes,
    final Set<ConstraintDescriptor<?>> pcomposingConstraints,
    final boolean preportAsSingleViolation, final ElementType pelementType,
    final ConstraintOrigin pdefinedOn) {
  super(pannotation, pgroups, ppayload, pconstraintValidatorClasses, pattributes,
      pcomposingConstraints, preportAsSingleViolation, pelementType, pdefinedOn);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:11,代码来源:ConstraintDescriptorImpl.java

示例7: convertSeverity

import javax.validation.Payload; //导入依赖的package包/类
/**
 * convert severity
 * 
 * @param constraint
 * @return
 */
protected Class<? extends Payload> convertSeverity(C constraint) {
	ConstraintSeverity severity = constraint.getSeverity();
	if (ConstraintSeverity.INFO.equals(severity)) {
		return HibernateSeverity.INFO.class;
	} else if (ConstraintSeverity.WARN.equals(severity)) {
		return HibernateSeverity.WARN.class;
	} else if (ConstraintSeverity.ERROR.equals(severity)) {
		return HibernateSeverity.ERROR.class;
	} else if (ConstraintSeverity.FATAL.equals(severity)) {
		return HibernateSeverity.FATAL.class;
	} else {
		return HibernateSeverity.INFO.class;
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:21,代码来源:AbstractHibernateConstraintConvertor.java

示例8: getPayload

import javax.validation.Payload; //导入依赖的package包/类
@Override
public Set<Class<? extends Payload>> getPayload() {
    throw new UnsupportedOperationException();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:5,代码来源:MinijaxConstraintDescriptor.java

示例9: payload

import javax.validation.Payload; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Class<? extends Payload>[] payload() {
	return new Class[0];
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:6,代码来源:JAXRSBeanValidationImplicitInInterceptor.java

示例10: payload

import javax.validation.Payload; //导入依赖的package包/类
@Override
public Class<? extends Payload>[] payload()
{
    throw new UnsupportedOperationException();
}
 
开发者ID:airlift,项目名称:units,代码行数:6,代码来源:MockMaxDataSize.java

示例11: getConstraintDescriptor

import javax.validation.Payload; //导入依赖的package包/类
@Required
@Override
public ConstraintDescriptor<?> getConstraintDescriptor() {
    String methodName = "getConstraintDescriptor";
    Method method;
    try {
        method = MockConstraintViolation.class.getMethod(methodName, new Class<?>[] {});
    } catch (NoSuchMethodException | SecurityException e) {
        throw new IllegalStateException("Failed to get the method: " + methodName, e);
    }
    Required annotation = method.getAnnotation(Required.class);
    return new ConstraintDescriptor<Annotation>() {

        @Override
        public Annotation getAnnotation() {
            return annotation;
        }

        @Override
        public String getMessageTemplate() {
            return null;
        }

        @Override
        public Set<Class<?>> getGroups() {
            return DfCollectionUtil.newHashSet(ClientError.class);
        }

        @Override
        public Set<Class<? extends Payload>> getPayload() {
            return null;
        }

        @Override
        public ConstraintTarget getValidationAppliesTo() {
            return null;
        }

        @Override
        public List<Class<? extends ConstraintValidator<Annotation, ?>>> getConstraintValidatorClasses() {
            return null;
        }

        @Override
        public Map<String, Object> getAttributes() {
            return null;
        }

        @Override
        public Set<ConstraintDescriptor<?>> getComposingConstraints() {
            return null;
        }

        @Override
        public boolean isReportAsSingleViolation() {
            return false;
        }

        @Override
        public ValidateUnwrappedValue getValueUnwrapping() {
            return null;
        }

        @Override
        public <U> U unwrap(Class<U> type) {
            return null;
        }
    };
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:70,代码来源:MockConstraintViolation.java

示例12: setPayload

import javax.validation.Payload; //导入依赖的package包/类
public Builder<T> setPayload(final Class<? extends Payload>[] classes) {
  this.setPayload(new HashSet<>(Arrays.asList(classes)));
  return this;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:5,代码来源:ConstraintDescriptorImpl.java

示例13: getPayload

import javax.validation.Payload; //导入依赖的package包/类
@Override
public Set<Class<? extends Payload>> getPayload() {
  return this.payload;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:5,代码来源:ConstraintDescriptorImpl.java

示例14: getPayload

import javax.validation.Payload; //导入依赖的package包/类
@Override
public Set<Class<? extends Payload>> getPayload() {
    return Collections.emptySet();
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:5,代码来源:AbstractValidatorTest.java

示例15: payload

import javax.validation.Payload; //导入依赖的package包/类
Class<? extends Payload>[] payload() default {}; 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:2,代码来源:RelaxedDataBinderTests.java


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