Class Reference

  • All Implemented Interfaces:
    Value

    class Reference
    extends java.lang.Object
    implements Value
    The Reference object represents a value that holds an object instance. If an object instance is to be provided from a Strategy implementation it must be wrapped in a value object. The value object can then provide the details of the instance and the actual object instance to the serializer.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class actual
      This is the actual type of the reference that is represented.
      private java.lang.Object data
      This represents the object instance that this represents.
      private Value value
      This represents the original value returned from a strategy.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reference​(Value value, java.lang.Object data, java.lang.Class actual)
      Constructor for a Reference object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLength()
      This will return the length of an array reference.
      java.lang.Class getType()
      This is the type of the object instance this represents.
      java.lang.Object getValue()
      This returns the actual object instance that is held by this reference object.
      boolean isReference()
      This will always return true as this Value object will always contain an object instance.
      void setValue​(java.lang.Object data)
      This is used to set the value of the object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • value

        private Value value
        This represents the original value returned from a strategy.
      • data

        private java.lang.Object data
        This represents the object instance that this represents.
      • actual

        private java.lang.Class actual
        This is the actual type of the reference that is represented.
    • Constructor Detail

      • Reference

        public Reference​(Value value,
                         java.lang.Object data,
                         java.lang.Class actual)
        Constructor for a Reference object. To create this a value and an object instance is required. The value provided may be null, but the instance should be a valid object instance to be used by the serializer.
        Parameters:
        value - this is the original value from a strategy
        data - this is the object instance that is wrapped
        actual - this is the overriding type of the reference
    • Method Detail

      • getLength

        public int getLength()
        This will return the length of an array reference. Because the value will represent the value itself the length is never used, as no instance needs to be created.
        Specified by:
        getLength in interface Value
        Returns:
        this will always return zero for a reference
      • getType

        public java.lang.Class getType()
        This is the type of the object instance this represents. The type returned by this is used to instantiate an object which will be set on this value and the internal graph maintained.
        Specified by:
        getType in interface Value
        Returns:
        the type of the object that must be instantiated
      • getValue

        public java.lang.Object getValue()
        This returns the actual object instance that is held by this reference object.
        Specified by:
        getValue in interface Value
        Returns:
        an instance of the type this object represents
      • isReference

        public boolean isReference()
        This will always return true as this Value object will always contain an object instance. Returning true from this method tells the serializer that there is no need to actually perform any further deserialization.
        Specified by:
        isReference in interface Value
        Returns:
        this always returns true as this will be a reference
      • setValue

        public void setValue​(java.lang.Object data)
        This is used to set the value of the object. If the internal Value is not null then the internal value will have the instance set also.
        Specified by:
        setValue in interface Value
        Parameters:
        data - this is the object instance that is to be set