org.springframework.boot.bind

Class PropertiesConfigurationFactory<T>

  • java.lang.Object
    • org.springframework.boot.bind.PropertiesConfigurationFactory<T>
  • Type Parameters:
    T - the target type
    All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.MessageSourceAware


    public class PropertiesConfigurationFactory<T>
    extends Object
    implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.ApplicationContextAware, 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)
        Set the target name.
        Parameters:
        targetName - the target name
      • setApplicationContext

        public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
      • setMessageSource

        public void setMessageSource(org.springframework.context.MessageSource messageSource)
        Set the message source.
        Specified by:
        setMessageSource in interface org.springframework.context.MessageSourceAware
        Parameters:
        messageSource - the message source
      • setPropertySources

        public void setPropertySources(org.springframework.core.env.PropertySources propertySources)
        Set the property sources.
        Parameters:
        propertySources - the property sources
      • setConversionService

        public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
        Set the conversion service.
        Parameters:
        conversionService - the conversion service
      • setValidator

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

        @Deprecated
        public void setExceptionIfInvalid(boolean exceptionIfInvalid)
        Deprecated. as of 1.5, do not specify a Validator if validation should not occur
        Set a flag to indicate that an exception should be raised if a Validator is available and validation fails.
        Parameters:
        exceptionIfInvalid - the flag to set
      • setResolvePlaceholders

        public void setResolvePlaceholders(boolean resolvePlaceholders)
        Flag to indicate that placeholders should be replaced during binding. Default is true.
        Parameters:
        resolvePlaceholders - flag value
      • 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)
        Customize the data binder.
        Parameters:
        dataBinder - the data binder that will be used to bind and validate

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