org.hibernate.validator.internal.engine.PredefinedScopeConfigurationImpl Maven / Gradle / Ivy
/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or .
*/
package org.hibernate.validator.internal.engine;
import static org.hibernate.validator.internal.util.logging.Messages.MESSAGES;
import java.util.Collections;
import java.util.Locale;
import java.util.Set;
import javax.validation.spi.BootstrapState;
import javax.validation.spi.ConfigurationState;
import javax.validation.spi.ValidationProvider;
import org.hibernate.validator.PredefinedScopeHibernateValidatorConfiguration;
import org.hibernate.validator.internal.util.CollectionHelper;
import org.hibernate.validator.internal.util.Contracts;
/**
* @author Guillaume Smet
*/
public class PredefinedScopeConfigurationImpl extends AbstractConfigurationImpl
implements PredefinedScopeHibernateValidatorConfiguration, ConfigurationState {
private Set builtinConstraints = Collections.emptySet();
private Set> beanClassesToInitialize;
public PredefinedScopeConfigurationImpl(BootstrapState state) {
super( state );
}
public PredefinedScopeConfigurationImpl(ValidationProvider validationProvider) {
super( validationProvider );
}
@Override
public PredefinedScopeHibernateValidatorConfiguration builtinConstraints(Set constraints) {
this.builtinConstraints = CollectionHelper.toImmutableSet( constraints );
return thisAsT();
}
@Override
public PredefinedScopeHibernateValidatorConfiguration initializeBeanMetaData(Set> beanMetaDataToInitialize) {
beanClassesToInitialize = CollectionHelper.toImmutableSet( beanMetaDataToInitialize );
return thisAsT();
}
public Set getBuiltinConstraints() {
return builtinConstraints;
}
public Set> getBeanClassesToInitialize() {
return beanClassesToInitialize;
}
@Override
public PredefinedScopeHibernateValidatorConfiguration initializeLocales(Set localesToInitialize) {
Contracts.assertNotNull( localesToInitialize, MESSAGES.parameterMustNotBeNull( "localesToInitialize" ) );
locales( localesToInitialize );
return thisAsT();
}
@Override
protected boolean preloadResourceBundles() {
return true;
}
}