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
    See Also:
    RelaxedNames
    • Field Summary

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

        DEFAULT_AUTO_GROW_COLLECTION_LIMIT, DEFAULT_OBJECT_NAME, logger
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected void doBind(org.springframework.beans.MutablePropertyValues propertyValues) 
      void initBeanPropertyAccess() 
      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

        addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getInternalBindingResult, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, 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
      • initBeanPropertyAccess

        public void initBeanPropertyAccess()
        Overrides:
        initBeanPropertyAccess in class org.springframework.validation.DataBinder
      • 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

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