public abstract class PropertyMatches
extends java.lang.Object
Mainly for use within the framework and in particular the binding facility.
forProperty(String, Class)
,
forField(String, Class)
Modifier and Type | Class and Description |
---|---|
private static class |
PropertyMatches.BeanPropertyMatches |
private static class |
PropertyMatches.FieldPropertyMatches |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_DISTANCE
Default maximum property distance: 2
|
private java.lang.String[] |
possibleMatches |
private java.lang.String |
propertyName |
Modifier | Constructor and Description |
---|---|
private |
PropertyMatches(java.lang.String propertyName,
java.lang.String[] possibleMatches)
Create a new PropertyMatches instance for the given property and possible matches.
|
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.
|
private static int |
calculateStringDistance(java.lang.String s1,
java.lang.String s2)
Calculate the distance between the given two Strings
according to the Levenshtein algorithm.
|
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.
|
public static final int DEFAULT_MAX_DISTANCE
private final java.lang.String propertyName
private java.lang.String[] possibleMatches
private PropertyMatches(java.lang.String propertyName, java.lang.String[] possibleMatches)
public static PropertyMatches forProperty(java.lang.String propertyName, java.lang.Class<?> beanClass)
propertyName
- the name of the property to find possible matches forbeanClass
- the bean class to search for matchespublic static PropertyMatches forProperty(java.lang.String propertyName, java.lang.Class<?> beanClass, int maxDistance)
propertyName
- the name of the property to find possible matches forbeanClass
- the bean class to search for matchesmaxDistance
- the maximum property distance allowed for matchespublic static PropertyMatches forField(java.lang.String propertyName, java.lang.Class<?> beanClass)
propertyName
- the name of the field to find possible matches forbeanClass
- the bean class to search for matchespublic static PropertyMatches forField(java.lang.String propertyName, java.lang.Class<?> beanClass, int maxDistance)
propertyName
- the name of the field to find possible matches forbeanClass
- the bean class to search for matchesmaxDistance
- the maximum property distance allowed for matchespublic java.lang.String getPropertyName()
public java.lang.String[] getPossibleMatches()
public abstract java.lang.String buildErrorMessage()
protected void appendHintMessage(java.lang.StringBuilder msg)
private static int calculateStringDistance(java.lang.String s1, java.lang.String s2)
s1
- the first Strings2
- the second String