public final class PropertyHelper
extends java.lang.Object
Constructor and Description |
---|
PropertyHelper()
Creates a generic PropertyHelper that is not tied to a particular
provider.
|
PropertyHelper(DBObjectProvider pro)
Creates a generic PropertyHelper for the given provider.
|
Modifier and Type | Method and Description |
---|---|
static PropertyInfo |
findPropertyInfo(java.lang.Class clz,
java.lang.String propPath,
java.lang.Class<? extends DBObjectProvider> proClz)
If the given property path is supported for the given object class this
method returns the PropertyInfo associated with that property.
|
static PropertyInfo |
findPropertyInfo(java.lang.Class clz,
java.lang.String propPath,
DBObjectProvider pro)
If the given property path is supported for the given object class this
method returns the PropertyInfo associated with that property.
|
static PropertyInfo |
findPropertyInfo(java.lang.String type,
java.lang.String propPath,
java.lang.Class<? extends DBObjectProvider> proClz)
If the given property path is supported for the given object class this
method returns the PropertyInfo associated with that property.
|
Difference |
getChildDifference(Difference diff,
java.lang.String propPath)
Traverses the given difference looking for a Difference heirachy that
matches the given property path, and returns the Difference at the end
of that path if one is found.
|
Difference |
getChildDifference(Difference diff,
java.lang.String propPath,
boolean ignoreSame)
Traverses the given difference looking for a Difference heirachy that
matches the given property path, and returns the Difference at the end
of that path if one is found.
|
java.lang.Object |
getPropertyValue(java.lang.Object obj,
java.lang.String propPath)
Gets the value for the given property path on the given object.
|
java.lang.Object |
getPropertyValueOrFail(java.lang.Object obj,
java.lang.String propPath)
Gets the value for the given property path on the given object, or
throws a MissingPropertyException if the path is not valid.
|
void |
setPropertyValue(java.lang.Object bean,
java.lang.String propPath,
java.lang.Object value)
Sets property value on a given object.
|
void |
setPropertyValueOrFail(java.lang.Object object,
java.lang.String propPath,
java.lang.Object value)
Sets property value on a given object.
|
public PropertyHelper()
public PropertyHelper(DBObjectProvider pro)
pro
- the DBObjectProvider that contains the objects we will querypublic java.lang.Object getPropertyValue(java.lang.Object obj, java.lang.String propPath)
obj
- the object to querypropPath
- the property path to lookupgetPropertyValueOrFail(Object,String)
public java.lang.Object getPropertyValueOrFail(java.lang.Object obj, java.lang.String propPath) throws MissingPropertyException
obj
- the object to querypropPath
- the property path to lookupMissingPropertyException
- if any part of the property path is
not foundpublic void setPropertyValue(java.lang.Object bean, java.lang.String propPath, java.lang.Object value)
If the path contains simple child beans that do not exist, and can be created, then they will be instantiated and set as part of the operation.
bean
- the object to set the property onpropPath
- the property path to the property we want to setvalue
- the property value to setsetPropertyValueOrFail(Object,String,Object)
public void setPropertyValueOrFail(java.lang.Object object, java.lang.String propPath, java.lang.Object value) throws MissingPropertyException
If the path contains simple child beans that do not exist, and can be created, then they will be instantiated and set as part of the operation.
object
- the object to set the property onpropPath
- the property path to the property we want to setvalue
- the property value to setMissingPropertyException
- if the property path is not validpublic Difference getChildDifference(Difference diff, java.lang.String propPath) throws MissingPropertyException
diff
- the parent DifferencepropPath
- the property path to resolve from the object in the parent
Difference.MissingPropertyException
- if the path is invalidpublic Difference getChildDifference(Difference diff, java.lang.String propPath, boolean ignoreSame) throws MissingPropertyException
diff
- the parent DifferencepropPath
- the property path to resolve from the object in the parent
Difference.ignoreSame
- if true only Differences that are !same are returnedMissingPropertyException
- if the path is invalidpublic static PropertyInfo findPropertyInfo(java.lang.String type, java.lang.String propPath, java.lang.Class<? extends DBObjectProvider> proClz)
If you have a provider, it is better to use
provider.getPropertyManager().findPropertyInfo
type
- the object typepropPath
- the property pathproClz
- the provider class to filter the supported properties bypublic static PropertyInfo findPropertyInfo(java.lang.Class clz, java.lang.String propPath, java.lang.Class<? extends DBObjectProvider> proClz)
If you have a provider, it is better to use
provider.getPropertyManager().findPropertyInfo
clz
- the object classpropPath
- the property pathproClz
- the provider class to filter the supported properties byPropertyManager.findPropertyInfo(java.lang.Class,java.lang.String)
public static PropertyInfo findPropertyInfo(java.lang.Class clz, java.lang.String propPath, DBObjectProvider pro)
If you have a provider, it is better to use
provider.getPropertyManager().findPropertyInfowhich ultimately calls this method, but allows the provider implementation to apply additional logic.
clz
- the object classpropPath
- the property pathpro
- the provider to filter the supported properties byPropertyManager.findPropertyInfo(java.lang.Class,java.lang.String)