Class ByRef<A>

  • Type Parameters:
    A - Any type. Class ByRef serves as a wrapper for this type.
    All Implemented Interfaces:
    java.lang.Cloneable

    public class ByRef<A>
    extends java.lang.Object
    implements java.lang.Cloneable
    A simple wrapper class for passing variables by-reference to methods calls.

    Note that this class is substantively identical to the class EffectivelyFinal, but has a more apropos name.


    • Field Summary

       
      The Wrapped Instance, Shielded from Compiler Warnings
      Modifier and Type Field
      A f
    • Constructor Summary

      Constructors 
      Constructor Description
      ByRef()
      Creates an instance of this class, and initializes the field this.f to null.
      ByRef​(A f)
      Creates an instance of this class, and initializes the field.
    • Method Summary

       
      Methods: class java.lang.Object
      Modifier and Type Method
      boolean equals​(Object other)
      int hashCode()
      String toString()
       
      Methods: interface java.lang.Cloneable
      Modifier and Type Method
      ByRef<A> clone()
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • ByRef

        🡅  🡇     🗕  🗗  🗖
        public ByRef​(A f)
        Creates an instance of this class, and initializes the field.
        Parameters:
        f - Initializes this class' only field, this.f, with the value provided by parameter 'f'
    • Method Detail

      • toString

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String toString()
        Invokes the standard java.lang.Object method toString() on the field this.f.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Returns the String produced by the contents' toString()
        Code:
        Exact Method Body:
         return f.toString();
        
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        public int hashCode()
        Invokes the standard java.lang.Object method hashCode() on the field this.f
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        Returns the hash code produced by the contents' hashCode().
        Code:
        Exact Method Body:
         return f.hashCode();
        
      • clone

        🡅  🡇     🗕  🗗  🗖
        public ByRef<Aclone()
        This creates a clone of the wrapper class.

        NOTE: The field, itself, is not cloned. Another ByRef wrapper is built, using the same internal field. Both the clone and 'this' will share a pointer-reference to the same field.
        Overrides:
        clone in class java.lang.Object
        Returns:
        An ByRef<A> clone.
        Code:
        Exact Method Body:
         return new ByRef<>(f);
        
      • equals

        🡅     🗕  🗗  🗖
        public boolean equals​(java.lang.Object other)
        This equality test checks whether both 'this' and 'other' share identical references. Equality between the contained / wrapped field 'f' is not checked.

        If this.f and other.f hold different references, this method will return FALSE even if both of these references have Object-Equality.
        Overrides:
        equals in class java.lang.Object
        Returns:
        Returns TRUE if and only if 'other' is an instance of 'ByRef' and this.f == other.f. This method checks for pointer-equality, rather than object-equality.
        Code:
        Exact Method Body:
         if (! (other instanceof ByRef)) return false;
        
         ByRef o = (ByRef) other;
        
         return this.f == o.f;