Class CacheParameter

  • All Implemented Interfaces:
    Parameter

    class CacheParameter
    extends java.lang.Object
    implements Parameter
    The CacheParameter object represents a parameter which caches its values internally. As well as caching parameter values this also caches a key from a Label object which ties the parameter an label together making it possible to reference each other from hash containers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.annotation.Annotation annotation
      This is the annotation used to represent this parameter.
      private boolean attribute
      This is true if this parameter represents an attribute.
      private Expression expression
      This is the XPath expression used to represent the parameter.
      private int index
      This is the index within the constructor for the parameter.
      private java.lang.Object key
      This is the key that uniquely identifies this parameter.
      private java.lang.String name
      This is the name of the element or attribute for the parameter.
      private java.lang.String path
      This is the path of the element or attribute for the parameter.
      private boolean primitive
      Determines if this parameter represents a primitive value.
      private boolean required
      This is true if this parameter is required to exist.
      private java.lang.String string
      This is the string representation of this parameter object.
      private boolean text
      This is true if this parameter represents a text value.
      private java.lang.Class type
      This is the type within the constructor of this parameter.
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheParameter​(Parameter value, Label label)
      Constructor for the CacheParameter object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.annotation.Annotation getAnnotation()
      This is used to acquire the annotation that is used for the parameter.
      Expression getExpression()
      This method is used to return an XPath expression that is used to represent the position of this parameter.
      int getIndex()
      This returns the index position of the parameter in the constructor.
      java.lang.Object getKey()
      This is the key used to represent the parameter.
      java.lang.String getName()
      This is used to acquire the name of the parameter that this represents.
      java.lang.String getPath()
      This is used to acquire the path of the element or attribute represented by this parameter.
      java.lang.Class getType()
      This is used to acquire the annotated type class.
      boolean isAttribute()
      This method is used to determine if the parameter represents an attribute.
      boolean isPrimitive()
      This is used to determine if the parameter is primitive.
      boolean isRequired()
      This is used to determine if the parameter is required.
      boolean isText()
      This is used to determine if the parameter represents text.
      java.lang.String toString()
      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 Detail

      • annotation

        private final java.lang.annotation.Annotation annotation
        This is the annotation used to represent this parameter.
      • expression

        private final Expression expression
        This is the XPath expression used to represent the parameter.
      • name

        private final java.lang.String name
        This is the name of the element or attribute for the parameter.
      • path

        private final java.lang.String path
        This is the path of the element or attribute for the parameter.
      • string

        private final java.lang.String string
        This is the string representation of this parameter object.
      • type

        private final java.lang.Class type
        This is the type within the constructor of this parameter.
      • key

        private final java.lang.Object key
        This is the key that uniquely identifies this parameter.
      • index

        private final int index
        This is the index within the constructor for the parameter.
      • primitive

        private final boolean primitive
        Determines if this parameter represents a primitive value.
      • required

        private final boolean required
        This is true if this parameter is required to exist.
      • attribute

        private final boolean attribute
        This is true if this parameter represents an attribute.
      • text

        private final boolean text
        This is true if this parameter represents a text value.
    • Constructor Detail

      • CacheParameter

        public CacheParameter​(Parameter value,
                              Label label)
                       throws java.lang.Exception
        Constructor for the CacheParameter object. This is used to create a parameter that internally caches all of the information of the provided parameter and also makes use of the label provided to generate a unique key.
        Parameters:
        value - this is the parameter to cache values from
        label - this is the label to acquire the key from
        Throws:
        java.lang.Exception
    • Method Detail

      • getKey

        public java.lang.Object getKey()
        This is the key used to represent the parameter. The key is used to store the parameter in hash containers. Unlike the path is not necessarily the path for the parameter.
        Specified by:
        getKey in interface Parameter
        Returns:
        this is the key used to represent the parameter
      • getType

        public java.lang.Class getType()
        This is used to acquire the annotated type class. The class is the type that is to be deserialized from the XML. This is used to validate against annotated fields and methods.
        Specified by:
        getType in interface Parameter
        Returns:
        this returns the type used for the parameter
      • getIndex

        public int getIndex()
        This returns the index position of the parameter in the constructor. This is used to determine the order of values that are to be injected in to the constructor.
        Specified by:
        getIndex in interface Parameter
        Returns:
        this returns the index for the parameter
      • getAnnotation

        public java.lang.annotation.Annotation getAnnotation()
        This is used to acquire the annotation that is used for the parameter. The annotation provided will be an XML annotation such as the Element or Attribute annotation.
        Specified by:
        getAnnotation in interface Parameter
        Returns:
        this returns the annotation used on the parameter
      • getExpression

        public Expression getExpression()
        This method is used to return an XPath expression that is used to represent the position of this parameter. If there is no XPath expression associated with this then an empty path is returned. This will never return a null expression.
        Specified by:
        getExpression in interface Parameter
        Returns:
        the XPath expression identifying the location
      • getName

        public java.lang.String getName()
        This is used to acquire the name of the parameter that this represents. The name is determined using annotation and the name attribute of that annotation, if one is provided.
        Specified by:
        getName in interface Parameter
        Returns:
        this returns the name of the annotated parameter
      • getPath

        public java.lang.String getPath()
        This is used to acquire the path of the element or attribute represented by this parameter. The path is determined by acquiring the XPath expression and appending the name of the label to form a fully qualified path.
        Specified by:
        getPath in interface Parameter
        Returns:
        returns the path that is used for this parameter
      • isRequired

        public boolean isRequired()
        This is used to determine if the parameter is required. If an attribute is not required then it can be null. Which means that we can inject a null value. Also, this means we can match constructors in a more flexible manner.
        Specified by:
        isRequired in interface Parameter
        Returns:
        this returns true if the parameter is required
      • isPrimitive

        public boolean isPrimitive()
        This is used to determine if the parameter is primitive. A primitive parameter must not be null. As there is no way to provide the value to the constructor. A default value is not a good solution as it affects the constructor score.
        Specified by:
        isPrimitive in interface Parameter
        Returns:
        this returns true if the parameter is primitive
      • isAttribute

        public boolean isAttribute()
        This method is used to determine if the parameter represents an attribute. This is used to style the name so that elements are styled as elements and attributes are styled as required.
        Specified by:
        isAttribute in interface Parameter
        Returns:
        this is used to determine if this is an attribute
      • isText

        public boolean isText()
        This is used to determine if the parameter represents text. If this represents text it typically does not have a name, instead the empty string represents the name. Also text parameters can not exist with other text parameters.
        Specified by:
        isText in interface Parameter
        Returns:
        returns true if this parameter represents text
      • toString

        public java.lang.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 Parameter
        Overrides:
        toString in class java.lang.Object
        Returns:
        this returns the string representation for this