本文整理了Java中javax.validation.Configuration.getDefaultParameterNameProvider()
方法的一些代码示例,展示了Configuration.getDefaultParameterNameProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getDefaultParameterNameProvider()
方法的具体详情如下:
包路径:javax.validation.Configuration
类名称:Configuration
方法名:getDefaultParameterNameProvider
[英]Returns an implementation of the ParameterNameProviderinterface following the default ParameterNameProviderdefined in the specification:
代码示例来源:origin: spring-projects/spring-framework
private void configureParameterNameProvider(ParameterNameDiscoverer discoverer, Configuration<?> configuration) {
final ParameterNameProvider defaultProvider = configuration.getDefaultParameterNameProvider();
configuration.parameterNameProvider(new ParameterNameProvider() {
@Override
public List<String> getParameterNames(Constructor<?> constructor) {
String[] paramNames = discoverer.getParameterNames(constructor);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(constructor));
}
@Override
public List<String> getParameterNames(Method method) {
String[] paramNames = discoverer.getParameterNames(method);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(method));
}
});
}
代码示例来源:origin: org.springframework/spring-context
private void configureParameterNameProvider(ParameterNameDiscoverer discoverer, Configuration<?> configuration) {
final ParameterNameProvider defaultProvider = configuration.getDefaultParameterNameProvider();
configuration.parameterNameProvider(new ParameterNameProvider() {
@Override
public List<String> getParameterNames(Constructor<?> constructor) {
String[] paramNames = discoverer.getParameterNames(constructor);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(constructor));
}
@Override
public List<String> getParameterNames(Method method) {
String[] paramNames = discoverer.getParameterNames(method);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(method));
}
});
}
代码示例来源:origin: hibernate/hibernate-validator
private ParameterNameProvider createParameterNameProvider(Configuration<?> config) {
BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
String parameterNameProviderFqcn = bootstrapConfiguration.getParameterNameProviderClassName();
if ( parameterNameProviderFqcn == null ) {
return config.getDefaultParameterNameProvider();
}
@SuppressWarnings("unchecked")
Class<? extends ParameterNameProvider> parameterNameProviderClass = (Class<? extends ParameterNameProvider>) run(
LoadClass.action(
parameterNameProviderFqcn,
null
)
);
return createInstance( parameterNameProviderClass );
}
代码示例来源:origin: hibernate/hibernate-validator
public ValidationExtension() {
Configuration<?> config = Validation.byDefaultProvider().configure();
// we use the default ParameterNameProvider here as we cannot use the injected one
// as it hasn't been turned into a managed bean yet and might not be able to
// return a parameter name. At this stage, we don't care about the parameter names.
config.parameterNameProvider( config.getDefaultParameterNameProvider() );
BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
globalExecutableTypes = bootstrap.getDefaultValidatedExecutableTypes();
isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();
validatorFactory = config.buildValidatorFactory();
validator = validatorFactory.getValidator();
getterPropertySelectionStrategyHelper = GetterPropertySelectionStrategyHelper.forValidationFactory( validatorFactory );
executableHelper = new ExecutableHelper( new TypeResolutionHelper() );
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public ParameterNameProvider getDefaultParameterNameProvider() {
return delegate.getDefaultParameterNameProvider();
}
代码示例来源:origin: apache/servicemix-bundles
private void configureParameterNameProvider(ParameterNameDiscoverer discoverer, Configuration<?> configuration) {
final ParameterNameProvider defaultProvider = configuration.getDefaultParameterNameProvider();
configuration.parameterNameProvider(new ParameterNameProvider() {
@Override
public List<String> getParameterNames(Constructor<?> constructor) {
String[] paramNames = discoverer.getParameterNames(constructor);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(constructor));
}
@Override
public List<String> getParameterNames(Method method) {
String[] paramNames = discoverer.getParameterNames(method);
return (paramNames != null ? Arrays.asList(paramNames) :
defaultProvider.getParameterNames(method));
}
});
}
代码示例来源:origin: vakinge/jeesuite-libs
public CustomParameterNameProvider() {
nameProvider = Validation.byDefaultProvider().configure().getDefaultParameterNameProvider();
}
代码示例来源:origin: org.lwapp/lwapp-dropwizard-core
public CustomParameterNameProvider() {
nameProvider = Validation.byDefaultProvider().configure().getDefaultParameterNameProvider();
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_CONFIGURATION, id = "d")
public void testGetDefaultParameterNameProviderFromConfiguration() throws Exception {
Method method = User.class.getMethod( "setNames", String.class, String.class );
Constructor<User> constructor = User.class.getConstructor(
String.class,
String.class,
Date.class
);
ParameterNameProvider defaultParameterNameProvider = TestUtil.getConfigurationUnderTest()
.getDefaultParameterNameProvider();
assertNotNull(
defaultParameterNameProvider,
"getDefaultParameterNameProvider() must not return null"
);
assertEquals(
defaultParameterNameProvider.getParameterNames( constructor ),
Arrays.asList( "firstName", "lastName", "dateOfBirth" ),
"Wrong constructor parameter names returned by default provider"
);
assertEquals(
defaultParameterNameProvider.getParameterNames( method ),
Arrays.asList( "firstName", "lastName" ),
"Wrong method parameter names returned by default provider"
);
}
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator-cdi
private ParameterNameProvider createParameterNameProvider(Configuration<?> config) {
BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
String parameterNameProviderFqcn = bootstrapConfiguration.getParameterNameProviderClassName();
if ( parameterNameProviderFqcn == null ) {
return config.getDefaultParameterNameProvider();
}
@SuppressWarnings("unchecked")
Class<? extends ParameterNameProvider> parameterNameProviderClass = (Class<? extends ParameterNameProvider>) run(
LoadClass.action(
parameterNameProviderFqcn,
null
)
);
return createInstance( parameterNameProviderClass );
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator-cdi
public ValidationExtension() {
Configuration<?> config = Validation.byDefaultProvider().configure();
// we use the default ParameterNameProvider here as we cannot use the injected one
// as it hasn't been turned into a managed bean yet and might not be able to
// return a parameter name. At this stage, we don't care about the parameter names.
config.parameterNameProvider( config.getDefaultParameterNameProvider() );
BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
globalExecutableTypes = bootstrap.getDefaultValidatedExecutableTypes();
isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();
validatorFactory = config.buildValidatorFactory();
validator = validatorFactory.getValidator();
executableHelper = new ExecutableHelper( new TypeResolutionHelper() );
}
内容来源于网络,如有侵权,请联系作者删除!