org.springframework.boot.bind

Class PropertiesConfigurationFactory<T>

  • java.lang.Object
    • org.springframework.boot.bind.PropertiesConfigurationFactory<T>
  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean, org.springframework.context.MessageSourceAware


    public class PropertiesConfigurationFactory<T>
    extends Object
    implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.MessageSourceAware, org.springframework.beans.factory.InitializingBean
    Validate some Properties (or optionally PropertySources) by binding them to an object of a specified type and then optionally running a Validator over it.
    Author:
    Dave Syer
    • Method Detail

      • setIgnoreNestedProperties

        public void setIgnoreNestedProperties(boolean ignoreNestedProperties)
        Flag to disable binding of nested properties (i.e. those with period separators in their paths). Can be useful to disable this if the name prefix is empty and you don't want to ignore unknown fields.
        Parameters:
        ignoreNestedProperties - the flag to set (default false)
      • setIgnoreUnknownFields

        public void setIgnoreUnknownFields(boolean ignoreUnknownFields)
        Set whether to ignore unknown fields, that is, whether to ignore bind parameters that do not have corresponding fields in the target object.

        Default is "true". Turn this off to enforce that all bind parameters must have a matching field in the target object.

        Parameters:
        ignoreUnknownFields - if unknown fields should be ignored
      • setIgnoreInvalidFields

        public void setIgnoreInvalidFields(boolean ignoreInvalidFields)
        Set whether to ignore invalid fields, that is, whether to ignore bind parameters that have corresponding fields in the target object which are not accessible (for example because of null values in the nested path).

        Default is "false". Turn this on to ignore bind parameters for nested objects in non-existing parts of the target object graph.

        Parameters:
        ignoreInvalidFields - if invalid fields should be ignored
      • setTargetName

        public void setTargetName(String targetName)
        Parameters:
        targetName - the target name to set
      • setMessageSource

        public void setMessageSource(org.springframework.context.MessageSource messageSource)
        Specified by:
        setMessageSource in interface org.springframework.context.MessageSourceAware
        Parameters:
        messageSource - the messageSource to set
      • setProperties

        public void setProperties(Properties properties)
        Parameters:
        properties - the properties to set
      • setPropertySources

        public void setPropertySources(org.springframework.core.env.PropertySources propertySources)
        Parameters:
        propertySources - the propertySources to set
      • setConversionService

        public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
        Parameters:
        conversionService - the conversionService to set
      • setValidator

        public void setValidator(org.springframework.validation.Validator validator)
        Parameters:
        validator - the validator to set
      • setExceptionIfInvalid

        public void setExceptionIfInvalid(boolean exceptionIfInvalid)
        Flag to indicate that an exception should be raised if a Validator is available and validation fails.
        Parameters:
        exceptionIfInvalid - the flag to set
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • getObjectType

        public Class<?> getObjectType()
        Specified by:
        getObjectType in interface org.springframework.beans.factory.FactoryBean<T>
      • isSingleton

        public boolean isSingleton()
        Specified by:
        isSingleton in interface org.springframework.beans.factory.FactoryBean<T>
      • getObject

        public T getObject()
                    throws Exception
        Specified by:
        getObject in interface org.springframework.beans.factory.FactoryBean<T>
        Throws:
        Exception
      • bindPropertiesToTarget

        public void bindPropertiesToTarget()
                                    throws org.springframework.validation.BindException
        Throws:
        org.springframework.validation.BindException
      • customizeBinder

        protected void customizeBinder(org.springframework.validation.DataBinder dataBinder)
        Parameters:
        dataBinder - the data binder that will be used to bind and validate

Copyright © 2014 Pivotal Software, Inc.. All rights reserved.