public class PropertyTypeDynaClass
extends java.lang.Object
implements org.apache.commons.beanutils.MutableDynaClass, java.io.Serializable
A DynaClass for the PropertyType which always returns
PropertyType
as the type
for all properties.
org.apche.commons.beanutils.LazyDynaBean
,
Serialized FormConstructor and Description |
---|
PropertyTypeDynaClass(java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(org.apache.commons.beanutils.DynaProperty property)
Add a new dynamic property.
|
void |
add(java.lang.String name) |
void |
add(java.lang.String name,
java.lang.Class type)
Add a new dynamic property with the specified data type, but with
no restrictions on readability or writeability.
|
void |
add(java.lang.String name,
java.lang.Class type,
boolean readable,
boolean writeable)
Add a new dynamic property with the specified data type, readability,
and writeability.
|
org.apache.commons.beanutils.DynaProperty[] |
getDynaProperties() |
org.apache.commons.beanutils.DynaProperty |
getDynaProperty(java.lang.String name)
Return a property descriptor for the specified property.
|
java.lang.String |
getName() |
boolean |
isRestricted()
This MutableDynaClass is never restricted.
|
org.apache.commons.beanutils.DynaBean |
newInstance() |
void |
remove(java.lang.String name)
Remove the specified dynamic property, and any associated data type,
readability, and writeability, from this dynamic class.
|
void |
setRestricted(boolean restricted) |
public PropertyTypeDynaClass(java.lang.String name)
name
- The name.public boolean isRestricted()
isRestricted
in interface org.apache.commons.beanutils.MutableDynaClass
MutableDynaClass.isRestricted()
public void setRestricted(boolean restricted)
setRestricted
in interface org.apache.commons.beanutils.MutableDynaClass
public void add(java.lang.String name)
add
in interface org.apache.commons.beanutils.MutableDynaClass
public void add(java.lang.String name, java.lang.Class type)
add
in interface org.apache.commons.beanutils.MutableDynaClass
name
- Name of the new dynamic propertytype
- Data type of the new dynamic property (null for no
restrictions)java.lang.IllegalArgumentException
- if name is nulljava.lang.IllegalStateException
- if this DynaClass is currently
restricted, so no new properties can be addedpublic void add(java.lang.String name, java.lang.Class type, boolean readable, boolean writeable)
Add a new dynamic property with the specified data type, readability, and writeability.
N.B.Support for readable/writeable properties has not been implemented
and this method always throws a UnsupportedOperationException
.
I'm not sure the intention of the original authors for this method, but it seems to
me that readable/writable should be attributes of the DynaProperty
class
(which they are not) and is the reason this method has not been implemented.
add
in interface org.apache.commons.beanutils.MutableDynaClass
name
- Name of the new dynamic propertytype
- Data type of the new dynamic property (null for no
restrictions)readable
- Set to true
if this property value
should be readablewriteable
- Set to true
if this property value
should be writeablejava.lang.UnsupportedOperationException
- anytime this method is calledprotected void add(org.apache.commons.beanutils.DynaProperty property)
property
- Property the new dynamic property to add.java.lang.IllegalArgumentException
- if name is nulljava.lang.IllegalStateException
- if this DynaClass is currently
restricted, so no new properties can be addedpublic void remove(java.lang.String name)
remove
in interface org.apache.commons.beanutils.MutableDynaClass
name
- Name of the dynamic property to removejava.lang.IllegalArgumentException
- if name is nulljava.lang.IllegalStateException
- if this DynaClass is currently
restricted, so no properties can be removedpublic org.apache.commons.beanutils.DynaProperty getDynaProperty(java.lang.String name)
Return a property descriptor for the specified property.
If the property is not found and the returnNull
indicator is
true
, this method always returns null
.
If the property is not found and the returnNull
indicator is
false
a new property descriptor is created and returned (although
its not actually added to the DynaClass's properties). This is the default
beahviour.
The reason for not returning a null
property descriptor is that
BeanUtils
uses this method to check if a property exists
before trying to set it - since these Lazy implementations automatically
add any new properties when they are set, returning null
from
this method would defeat their purpose.
getDynaProperty
in interface org.apache.commons.beanutils.DynaClass
name
- Name of the dynamic property for which a descriptor
is requestedjava.lang.IllegalArgumentException
- if no property name is specifiedpublic org.apache.commons.beanutils.DynaProperty[] getDynaProperties()
getDynaProperties
in interface org.apache.commons.beanutils.DynaClass
public java.lang.String getName()
getName
in interface org.apache.commons.beanutils.DynaClass
public org.apache.commons.beanutils.DynaBean newInstance() throws java.lang.IllegalAccessException, java.lang.InstantiationException
newInstance
in interface org.apache.commons.beanutils.DynaClass
java.lang.IllegalAccessException
java.lang.InstantiationException