org.springframework.boot.bind

Class RelaxedDataBinder

  • java.lang.Object
    • org.springframework.validation.DataBinder
      • org.springframework.boot.bind.RelaxedDataBinder
  • All Implemented Interfaces:
    org.springframework.beans.PropertyEditorRegistry, org.springframework.beans.TypeConverter


    public class RelaxedDataBinder
    extends org.springframework.validation.DataBinder
    Binder implementation that allows caller to bind to maps and also allows property names to match a bit loosely (if underscores or dashes are removed and replaced with camel case for example).
    Author:
    Dave Syer, Phillip Webb, Stephane Nicoll, Andy Wilkinson
    See Also:
    RelaxedNames
    • Field Summary

      • Fields inherited from class org.springframework.validation.DataBinder

        DEFAULT_AUTO_GROW_COLLECTION_LIMIT, DEFAULT_OBJECT_NAME, logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected org.springframework.validation.AbstractPropertyBindingResult createBeanPropertyBindingResult() 
      protected void doBind(org.springframework.beans.MutablePropertyValues propertyValues) 
      protected String normalizePath(org.springframework.beans.BeanWrapper wrapper, String path)
      Normalize a bean property path to a format understood by a BeanWrapper.
      void setIgnoreNestedProperties(boolean ignoreNestedProperties)
      Flag to disable binding of nested properties (i.e.
      void setNameAliases(Map<String,List<String>> aliases)
      Set name aliases.
      RelaxedDataBinder withAlias(String name, String... alias)
      Add aliases to the DataBinder.
      • Methods inherited from class org.springframework.validation.DataBinder

        addCustomFormatter, addCustomFormatter, addCustomFormatter, addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, createDirectFieldBindingResult, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getInternalBindingResult, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, initBeanPropertyAccess, initDirectFieldAccess, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, replaceValidators, setAllowedFields, setAutoGrowCollectionLimit, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, setExtractOldValueForEditor, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate, validate
    • Constructor Detail

      • RelaxedDataBinder

        public RelaxedDataBinder(Object target)
        Create a new RelaxedDataBinder instance.
        Parameters:
        target - the target into which properties are bound
      • RelaxedDataBinder

        public RelaxedDataBinder(Object target,
                                 String namePrefix)
        Create a new RelaxedDataBinder instance.
        Parameters:
        target - the target into which properties are bound
        namePrefix - An optional prefix to be used when reading properties
    • 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)
      • setNameAliases

        public void setNameAliases(Map<String,List<String>> aliases)
        Set name aliases.
        Parameters:
        aliases - a map of property name to aliases
      • withAlias

        public RelaxedDataBinder withAlias(String name,
                                           String... alias)
        Add aliases to the DataBinder.
        Parameters:
        name - the property name to alias
        alias - aliases for the property names
        Returns:
        this instance
      • doBind

        protected void doBind(org.springframework.beans.MutablePropertyValues propertyValues)
        Overrides:
        doBind in class org.springframework.validation.DataBinder
      • normalizePath

        protected String normalizePath(org.springframework.beans.BeanWrapper wrapper,
                                       String path)
        Normalize a bean property path to a format understood by a BeanWrapper. This is used so that
        • Fuzzy matching can be employed for bean property names
        • Period separators can be used instead of indexing ([...]) for map keys
        Parameters:
        wrapper - a bean wrapper for the object to bind
        path - the bean path to bind
        Returns:
        a transformed path with correct bean wrapper syntax
      • createBeanPropertyBindingResult

        protected org.springframework.validation.AbstractPropertyBindingResult createBeanPropertyBindingResult()
        Overrides:
        createBeanPropertyBindingResult in class org.springframework.validation.DataBinder

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