當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。