Package org.simpleframework.xml.core
Class ParameterContact<T extends Annotation>
java.lang.Object
org.simpleframework.xml.core.ParameterContact<T>
- Direct Known Subclasses:
AttributeParameter.Contact
,ElementArrayParameter.Contact
,ElementListParameter.Contact
,ElementListUnionParameter.Contact
,ElementMapParameter.Contact
,ElementMapUnionParameter.Contact
,ElementParameter.Contact
,ElementUnionParameter.Contact
,TextParameter.Contact
The
ParameterContact
object is used to represent
a contact that is provided so that a Label
can be
used to determine a consistent name for the parameter. Unlike
field and method contacts this is essentially an adapter that
is used so that the parameter name can be determined in a
similar way to a method or field.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Constructor
This is the constructor the parameter was declared within.protected final int
This is the index of the parameter within the constructor.protected final T
This is the annotation used to label the parameter.protected final Annotation[]
This is used to hold the annotations for this parameter.protected final Class
This represents the class that this parameter was declared in. -
Constructor Summary
ConstructorsConstructorDescriptionParameterContact
(T label, Constructor factory, int index) Constructor for theParameterContact
object. -
Method Summary
Modifier and TypeMethodDescriptionThis is used to get the value from the specified object using the point of contact.This is the annotation associated with the point of contact.<A extends Annotation>
AgetAnnotation
(Class<A> type) This is the annotation associated with the point of contact.This is the class that declares the contact.This provides the dependent class for the contact.Class[]
This provides the dependent classes for the contact.abstract String
getName()
This represents the name of the parameter.getType()
This will provide the contact type.boolean
This is used to determine if the annotated contact is for a read only variable.void
This is used to set the value on the specified object through this contact.toString()
This is used to provide a textual representation of the parameter.
-
Field Details
-
labels
This is used to hold the annotations for this parameter. -
factory
This is the constructor the parameter was declared within. -
owner
This represents the class that this parameter was declared in. -
index
protected final int indexThis is the index of the parameter within the constructor. -
label
This is the annotation used to label the parameter.
-
-
Constructor Details
-
ParameterContact
Constructor for theParameterContact
object. This is used to create a contact that can be used to determine a consistent name for the parameter. It requires the annotation, the constructor, and the parameter declaration index.- Parameters:
label
- this is the annotation used for the parameterfactory
- this is the constructor that is representedindex
- this is the index for the parameter
-
-
Method Details
-
getAnnotation
This is the annotation associated with the point of contact. This will be an XML annotation that describes how the contact should be serialized and deserialized from the object.- Specified by:
getAnnotation
in interfaceContact
- Returns:
- this provides the annotation associated with this
-
getType
This will provide the contact type. The contact type is the class that is to be set and get on the object. Typically the type will be a serializable object or a primitive type. -
getDependent
This provides the dependent class for the contact. This will typically represent a generic type for the actual type. For contacts that use aCollection
type this will be the generic type parameter for that collection.- Specified by:
getDependent
in interfaceContact
- Returns:
- this returns the dependent type for the contact
-
getDependents
This provides the dependent classes for the contact. This will typically represent a generic types for the actual type. For contacts that use aMap
type this will be the generic type parameter for that map type declaration.- Specified by:
getDependents
in interfaceContact
- Returns:
- this returns the dependent types for the contact
-
getDeclaringClass
This is the class that declares the contact. The declaring class is where the parameter has been defined. Typically this will not be a class rather than an interface.- Specified by:
getDeclaringClass
in interfaceContact
- Returns:
- the class this parameter is declared within
-
get
This is used to get the value from the specified object using the point of contact. Typically the value is retrieved from the specified object by invoking a get method of by acquiring the value from a field within the specified object. -
set
This is used to set the value on the specified object through this contact. Depending on the type of contact this will set the value given, typically this will be done by invoking a method or setting the value on the object field. -
getAnnotation
This is the annotation associated with the point of contact. This will be an XML annotation that describes how the contact should be serialized and deserialized from the object.- Specified by:
getAnnotation
in interfaceType
- Parameters:
type
- this is the type of the annotation to acquire- Returns:
- this provides the annotation associated with this
-
isReadOnly
public boolean isReadOnly()This is used to determine if the annotated contact is for a read only variable. A read only variable is a field that can be set from within the constructor such as a blank final variable. It can also be a method with no set counterpart.- Specified by:
isReadOnly
in interfaceContact
- Returns:
- this returns true if the contact is a constant one
-
toString
This is used to provide a textual representation of the parameter. Providing a string describing the parameter is useful for debugging and for exception messages. -
getName
This represents the name of the parameter. Because the name of the parameter does not exist at runtime the name must be taken directly from the annotation and the parameter type. Each XML annotation must provide their own unique way of providing a name for the parameter contact.
-