|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.mojo.pomtools.wrapper.modify.AbstractModifiableObject
org.codehaus.mojo.pomtools.wrapper.ObjectWrapper
public class ObjectWrapper
Field Summary | |
---|---|
static String |
FIELD_PATH_SEPARATOR
|
Constructor Summary | |
---|---|
ObjectWrapper(Modifiable parentModifiable,
ObjectWrapper parent,
Object objectToWrap,
String name,
Class objectToWrapClass)
Constructs an ObjectWrapper that wraps the objectToWrap. |
|
ObjectWrapper(ObjectWrapper parent,
Object objectToWrap,
String name)
Constructs a new ObjectWrapper and does not specify a implClass. |
|
ObjectWrapper(ObjectWrapper parent,
Object objectToWrap,
String name,
Class objectToWrapClass)
Constructs a new ObjectWrapper and specifies the implClass that is used to create an empty object if the objectToWrap is null. |
Method Summary | |
---|---|
protected Object |
createDefaultInstance()
Creates an instance of our wrapped class by calling its default constructor. |
BeanFields |
getFields()
Returns the internal BeanFields used to describe this object. |
Object |
getFieldValue(BeanField field)
Returns the value for the wrapped object for the specified field. |
Object |
getFieldValue(BeanField field,
boolean createIfNull)
Returns the value for the wrapped object for the specified field. |
Object |
getFieldValue(String fieldName)
Returns the value for the wrapped object for the specified fieldName. |
String |
getFullName()
Returns the fully qualified name of the wrapped object. |
protected Object |
getInternalWrappedObject()
Returns the original wrapped object passed to or created in the constructor. |
String |
getName()
Returns the name of the field to which this object belongs. |
ObjectWrapper |
getParent()
|
String |
getValueLabel()
Returns the toString() representation of the value with
an appended annotation if this object has been modified. |
Object |
getWrappedObject()
Returns the original wrapped object with all modifications applied to it. |
boolean |
isEmpty()
Iterates through each BeanField and determines if the value is empty. |
boolean |
isFieldModified(BeanField field)
|
boolean |
isSameAsDefault()
Returns whether the wrapped object is in the same state as it's default constructor. |
void |
setFieldValue(BeanField field,
Object value)
Sets the value for specified field of the underlying wrapped object to the specified value. |
void |
setFieldValue(String fieldName,
Object value)
Sets the value for specified field of the underlying wrapped object to the specified value. |
void |
setModified(BeanField field)
Sets the modified flag to true and adds the field to our modified fields.; |
void |
setModified(boolean modified)
Clears our list of modified fields if setting to false; |
String |
toString()
|
Methods inherited from class org.codehaus.mojo.pomtools.wrapper.modify.AbstractModifiableObject |
---|
addChild, isModified, setModified |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String FIELD_PATH_SEPARATOR
Constructor Detail |
---|
public ObjectWrapper(ObjectWrapper parent, Object objectToWrap, String name, Class objectToWrapClass)
Modifiable
parent is set to the parent;
parent
- the parent ObjectWrapper of this objectobjectToWrap
- the value object to wrap. This is a field of the parentname
- the field name that the objectToWrap is called within the parentobjectToWrapClass
- the Class to use to create a new objectToWrap if the supplied one is nullpublic ObjectWrapper(ObjectWrapper parent, Object objectToWrap, String name)
Modifiable
parent is set to the parent;
parent
- the parent ObjectWrapper of this objectobjectToWrap
- the value object to wrap. This is a field of the parentname
- the field name that the objectToWrap is called within the parentpublic ObjectWrapper(Modifiable parentModifiable, ObjectWrapper parent, Object objectToWrap, String name, Class objectToWrapClass)
parentModifiable
- allows separate specification of the parentModifiableparent
- the parent ObjectWrapper of this objectobjectToWrap
- the value object to wrap. This is a field of the parentname
- the field name that the objectToWrap is called within the parentobjectToWrapClass
- the Class to use to create a new objectToWrap if the supplied one is nullMethod Detail |
---|
protected Object createDefaultInstance()
public ObjectWrapper getParent()
public String getName()
public String getFullName()
Objects are comprised of fields which have names. A fully qualified name
is the this name of the field this object belongs to, as well as that field's
owner and up.
For example:
If this objects name were "dependency", it could have a fullName of:
project.dependencies.dependency
public final String getValueLabel()
toString()
representation of the value with
an appended annotation if this object has been modified.
protected Object getInternalWrappedObject()
Subclasses should excercise caution an never modify this object directly.
public Object getWrappedObject()
public final BeanFields getFields()
BeanFields
used to describe this object.
public boolean isEmpty()
BeanField
and determines if the value is empty.
If the value is an instance of ObjectWrapper
, the isEmpty()
method is called on that object.
If the value is a String
, the StringUtils.isNotEmpty(java.lang.String)
method is used.
The object is considered to be NOT empty if any field (other than String or ObjectWrapper) is non null.
public boolean isSameAsDefault()
public String toString()
toString
in class Object
public Object getFieldValue(String fieldName)
fieldName
-
IllegalArgumentException
- if the field cannot be found.public Object getFieldValue(BeanField field)
field
-
public Object getFieldValue(BeanField field, boolean createIfNull)
field
-
public void setFieldValue(String fieldName, Object value)
IllegalArgumentException
- if the field cannot be found.public void setFieldValue(BeanField field, Object value)
public boolean isFieldModified(BeanField field)
public void setModified(BeanField field)
public void setModified(boolean modified)
setModified
in interface Modifiable
setModified
in class AbstractModifiableObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |