Java 类org.hibernate.validator.spi.valuehandling.ValidatedValueUnwrapper 实例源码
项目:nest-old
文件:ValidatorFactoryImpl513.java
/**
* create validator
*
* @param constraintValidatorFactory
* @param messageInterpolator
* @param traversableResolver
* @param parameterNameProvider
* @param failFast
* @param validatedValueHandlers
* @return
*/
protected Validator createValidator(ConstraintValidatorFactory constraintValidatorFactory,
MessageInterpolator messageInterpolator, TraversableResolver traversableResolver,
ParameterNameProvider parameterNameProvider, boolean failFast,
List<ValidatedValueUnwrapper<?>> validatedValueHandlers) {
BeanMetaDataManager513 beanMetaDataManager;
if (!beanMetaDataManagerMap.containsKey(parameterNameProvider)) {
beanMetaDataManager = new BeanMetaDataManager513(constraintHelper, executableHelper, parameterNameProvider,
buildDataProviders(parameterNameProvider));
beanMetaDataManagerMap.put(parameterNameProvider, beanMetaDataManager);
} else {
beanMetaDataManager = beanMetaDataManagerMap.get(parameterNameProvider);
}
return new ValidatorImpl(constraintValidatorFactory, messageInterpolator, traversableResolver,
beanMetaDataManager, parameterNameProvider, typeResolutionHelper, validatedValueHandlers,
constraintValidatorManager, failFast);
}
项目:nest-old
文件:ValidatorFactoryImpl513.java
/**
* Returns a list with {@link ValidatedValueUnwrapper}s configured via the
* {@link HibernateValidatorConfiguration#VALIDATED_VALUE_HANDLERS}
* property.
*
* @param properties
* the properties used to bootstrap the factory
*
* @return a list with property-configured {@link ValidatedValueUnwrapper}s;
* May be empty but never {@code null}
*/
private List<ValidatedValueUnwrapper<?>> getPropertyConfiguredValidatedValueHandlers(Map<String, String> properties) {
String propertyValue = properties.get(HibernateValidatorConfiguration.VALIDATED_VALUE_HANDLERS);
if (propertyValue == null || propertyValue.isEmpty()) {
return Collections.emptyList();
}
String[] handlerNames = propertyValue.split(",");
List<ValidatedValueUnwrapper<?>> handlers = newArrayList(handlerNames.length);
for (String handlerName : handlerNames) {
@SuppressWarnings("unchecked")
Class<? extends ValidatedValueUnwrapper<?>> handlerType = (Class<? extends ValidatedValueUnwrapper<?>>) run(LoadClass
.action(handlerName, ValidatorFactoryImpl513.class));
handlers.add(run(NewInstance.action(handlerType, "validated value handler class")));
}
return handlers;
}
项目:nest-old
文件:ValidatorContextImpl513.java
public ValidatorContextImpl513(ValidatorFactoryImpl513 validatorFactory) {
this.validatorFactory = validatorFactory;
this.messageInterpolator = validatorFactory.getMessageInterpolator();
this.traversableResolver = validatorFactory.getTraversableResolver();
this.constraintValidatorFactory = validatorFactory.getConstraintValidatorFactory();
this.parameterNameProvider = validatorFactory.getParameterNameProvider();
this.failFast = validatorFactory.isFailFast();
this.validatedValueHandlers = new ArrayList<ValidatedValueUnwrapper<?>>(
validatorFactory.getValidatedValueHandlers());
}
项目:dropwizard-metrics-cloudwatch
文件:CloudWatchReporterFactoryTest.java
@Test
public void verifyConfigurable() throws Exception {
ObjectMapper mapper = Jackson.newObjectMapper();
// dropwizard 0.9.1 changed the validation wiring a bit..
Class<ValidatedValueUnwrapper> optValidatorClazz = (Class<ValidatedValueUnwrapper>) Class
.forName("io.dropwizard.validation.valuehandling.OptionalValidatedValueUnwrapper");
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
if (optValidatorClazz != null) {
validator = Validation.byProvider(HibernateValidator.class).configure()
.addValidatedValueHandler(optValidatorClazz.newInstance())
.buildValidatorFactory().getValidator();
}
ConfigurationFactory<CloudWatchReporterFactory> configFactory =
new ConfigurationFactory<>(CloudWatchReporterFactory.class,
validator, mapper, "dw");
CloudWatchReporterFactory f = configFactory.build(new File(Resources.getResource("cw.yml").getFile()));
assertEquals("[env=default]", f.getGlobalDimensions().toString());
assertEquals("us-east-1", f.getAwsRegion());
assertEquals("a.b", f.getNamespace());
assertEquals("XXXXX", f.getAwsSecretKey());
assertEquals("11111", f.getAwsAccessKeyId());
assertEquals("p.neustar.biz", f.getAwsClientConfiguration().getProxyHost());
assertNull(f.getAwsClientConfiguration().getProxyUsername());
}
项目:nest-old
文件:ValidatorFactoryImpl513.java
public ValidatorFactoryImpl513(ConfigurationState configurationState) {
this.messageInterpolator = configurationState.getMessageInterpolator();
this.traversableResolver = configurationState.getTraversableResolver();
this.parameterNameProvider = configurationState.getParameterNameProvider();
this.beanMetaDataManagerMap = Collections
.synchronizedMap(new IdentityHashMap<ParameterNameProvider, BeanMetaDataManager513>());
this.constraintHelper = new ConstraintHelper();
this.typeResolutionHelper = new TypeResolutionHelper();
this.executableHelper = new ExecutableHelper(typeResolutionHelper);
// HV-302; don't load XmlMappingParser if not necessary
if (configurationState.getMappingStreams().isEmpty()) {
this.xmlMetaDataProvider = null;
} else {
this.xmlMetaDataProvider = new XmlMetaDataProvider(constraintHelper, parameterNameProvider,
configurationState.getMappingStreams());
}
Map<String, String> properties = configurationState.getProperties();
boolean tmpFailFast = false;
List<ValidatedValueUnwrapper<?>> tmpValidatedValueHandlers = newArrayList(5);
Set<DefaultConstraintMapping> tmpConstraintMappings = newHashSet();
if (configurationState instanceof ConfigurationImpl) {
ConfigurationImpl hibernateSpecificConfig = (ConfigurationImpl) configurationState;
if (hibernateSpecificConfig.getProgrammaticMappings().size() > 0) {
tmpConstraintMappings.addAll(hibernateSpecificConfig.getProgrammaticMappings());
}
// check whether fail fast is programmatically enabled
tmpFailFast = hibernateSpecificConfig.getFailFast();
tmpValidatedValueHandlers.addAll(hibernateSpecificConfig.getValidatedValueHandlers());
}
this.constraintMappings = Collections.unmodifiableSet(tmpConstraintMappings);
tmpFailFast = checkPropertiesForFailFast(properties, tmpFailFast);
this.failFast = tmpFailFast;
tmpValidatedValueHandlers.addAll(getPropertyConfiguredValidatedValueHandlers(properties));
this.validatedValueHandlers = Collections.unmodifiableList(tmpValidatedValueHandlers);
this.constraintValidatorManager = new ConstraintValidatorManager(
configurationState.getConstraintValidatorFactory());
}
项目:nest-old
文件:ValidatorFactoryImpl513.java
public List<ValidatedValueUnwrapper<?>> getValidatedValueHandlers() {
return validatedValueHandlers;
}
项目:nest-old
文件:ValidatorContextImpl513.java
@Override
public HibernateValidatorContext addValidationValueHandler(ValidatedValueUnwrapper<?> handler) {
this.validatedValueHandlers.add(handler);
return this;
}
项目:storm-data-contracts
文件:TypeResolverBasedValueUnwrapper.java
public TypeResolverBasedValueUnwrapper(TypeResolutionHelper typeResolutionHelper) {
this.typeResolver = typeResolutionHelper.getTypeResolver();
clazz = resolveSingleTypeParameter( typeResolver, this.getClass(), ValidatedValueUnwrapper.class );
}