org.springframework.beans

Class PropertyMatches

  • java.lang.Object
    • org.springframework.beans.PropertyMatches


  • public abstract class PropertyMatches
    extends java.lang.Object
    Helper class for calculating property matches, according to a configurable distance. Provide the list of potential matches and an easy way to generate an error message. Works for both java bean properties and fields.

    Mainly for use within the framework and in particular the binding facility.

    Since:
    2.0
    Author:
    Alef Arendsen, Arjen Poutsma, Juergen Hoeller, Stephane Nicoll
    See Also:
    forProperty(String, Class), forField(String, Class)
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int DEFAULT_MAX_DISTANCE
      Default maximum property distance: 2.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      protected void appendHintMessage(java.lang.StringBuilder msg) 
      abstract java.lang.String buildErrorMessage()
      Build an error message for the given invalid property name, indicating the possible property matches.
      static PropertyMatches forField(java.lang.String propertyName, java.lang.Class<?> beanClass)
      Create PropertyMatches for the given field property.
      static PropertyMatches forField(java.lang.String propertyName, java.lang.Class<?> beanClass, int maxDistance)
      Create PropertyMatches for the given field property.
      static PropertyMatches forProperty(java.lang.String propertyName, java.lang.Class<?> beanClass)
      Create PropertyMatches for the given bean property.
      static PropertyMatches forProperty(java.lang.String propertyName, java.lang.Class<?> beanClass, int maxDistance)
      Create PropertyMatches for the given bean property.
      java.lang.String[] getPossibleMatches()
      Return the calculated possible matches.
      java.lang.String getPropertyName()
      Return the name of the requested property.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_MAX_DISTANCE

        public static final int DEFAULT_MAX_DISTANCE
        Default maximum property distance: 2.
        See Also:
        Constant Field Values
    • Method Detail

      • forProperty

        public static PropertyMatches forProperty(java.lang.String propertyName,
                                                  java.lang.Class<?> beanClass)
        Create PropertyMatches for the given bean property.
        Parameters:
        propertyName - the name of the property to find possible matches for
        beanClass - the bean class to search for matches
      • forProperty

        public static PropertyMatches forProperty(java.lang.String propertyName,
                                                  java.lang.Class<?> beanClass,
                                                  int maxDistance)
        Create PropertyMatches for the given bean property.
        Parameters:
        propertyName - the name of the property to find possible matches for
        beanClass - the bean class to search for matches
        maxDistance - the maximum property distance allowed for matches
      • forField

        public static PropertyMatches forField(java.lang.String propertyName,
                                               java.lang.Class<?> beanClass)
        Create PropertyMatches for the given field property.
        Parameters:
        propertyName - the name of the field to find possible matches for
        beanClass - the bean class to search for matches
      • forField

        public static PropertyMatches forField(java.lang.String propertyName,
                                               java.lang.Class<?> beanClass,
                                               int maxDistance)
        Create PropertyMatches for the given field property.
        Parameters:
        propertyName - the name of the field to find possible matches for
        beanClass - the bean class to search for matches
        maxDistance - the maximum property distance allowed for matches
      • getPropertyName

        public java.lang.String getPropertyName()
        Return the name of the requested property.
      • getPossibleMatches

        public java.lang.String[] getPossibleMatches()
        Return the calculated possible matches.
      • buildErrorMessage

        public abstract java.lang.String buildErrorMessage()
        Build an error message for the given invalid property name, indicating the possible property matches.
      • appendHintMessage

        protected void appendHintMessage(java.lang.StringBuilder msg)