Class ParameterContact<T extends Annotation>

java.lang.Object
org.simpleframework.xml.core.ParameterContact<T>
All Implemented Interfaces:
Contact, Type
Direct Known Subclasses:
AttributeParameter.Contact, ElementArrayParameter.Contact, ElementListParameter.Contact, ElementListUnionParameter.Contact, ElementMapParameter.Contact, ElementMapUnionParameter.Contact, ElementParameter.Contact, ElementUnionParameter.Contact, TextParameter.Contact

abstract class ParameterContact<T extends Annotation> extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Constructor
    Description
    ParameterContact(T label, Constructor factory, int index)
    Constructor for the ParameterContact object.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(Object source)
    This 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>
    A
    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.
    This provides the dependent classes for the contact.
    abstract String
    This represents the name of the parameter.
    This will provide the contact type.
    boolean
    This is used to determine if the annotated contact is for a read only variable.
    void
    set(Object source, Object value)
    This is used to set the value on the specified object through this contact.
    This is used to provide a textual representation of the parameter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • labels

      protected final Annotation[] labels
      This is used to hold the annotations for this parameter.
    • factory

      protected final Constructor factory
      This is the constructor the parameter was declared within.
    • owner

      protected final Class owner
      This represents the class that this parameter was declared in.
    • index

      protected final int index
      This is the index of the parameter within the constructor.
    • label

      protected final T extends Annotation label
      This is the annotation used to label the parameter.
  • Constructor Details

    • ParameterContact

      public ParameterContact(T label, Constructor factory, int index)
      Constructor for the ParameterContact 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 parameter
      factory - this is the constructor that is represented
      index - this is the index for the parameter
  • Method Details

    • getAnnotation

      public Annotation 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 interface Contact
      Returns:
      this provides the annotation associated with this
    • getType

      public Class 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.
      Specified by:
      getType in interface Type
      Returns:
      this returns the type that this contact represents
    • getDependent

      public Class getDependent()
      This provides the dependent class for the contact. This will typically represent a generic type for the actual type. For contacts that use a Collection type this will be the generic type parameter for that collection.
      Specified by:
      getDependent in interface Contact
      Returns:
      this returns the dependent type for the contact
    • getDependents

      public Class[] getDependents()
      This provides the dependent classes for the contact. This will typically represent a generic types for the actual type. For contacts that use a Map type this will be the generic type parameter for that map type declaration.
      Specified by:
      getDependents in interface Contact
      Returns:
      this returns the dependent types for the contact
    • getDeclaringClass

      public Class 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 interface Contact
      Returns:
      the class this parameter is declared within
    • get

      public Object get(Object source)
      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.
      Specified by:
      get in interface Contact
      Parameters:
      source - this is the object to acquire the value from
      Returns:
      this is the value acquired from the point of contact
    • set

      public void set(Object source, Object value)
      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.
      Specified by:
      set in interface Contact
      Parameters:
      source - this is the object to set the value on
      value - this is the value to be set through the contact
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> type)
      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 interface Type
      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 interface Contact
      Returns:
      this returns true if the contact is a constant one
    • toString

      public String 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.
      Specified by:
      toString in interface Contact
      Specified by:
      toString in interface Type
      Overrides:
      toString in class Object
      Returns:
      this returns the string representation for this
    • getName

      public abstract String 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.
      Specified by:
      getName in interface Contact
      Returns:
      this returns the name of the contact represented