Package Torello.Java.Additional
Class ByRef<A>
- java.lang.Object
-
- Torello.Java.Additional.ByRef<A>
-
- Type Parameters:
A
- Any type. ClassByRef
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 classEffectivelyFinal
, but has a more apropos name.
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/ByRef.java
- Open New Browser-Tab: Torello/Java/Additional/ByRef.java
File Size: 2,831 Bytes Line Count: 84 '\n' Characters Found
-
-
Constructor Detail
-
ByRef
-
ByRef
public ByRef()
Creates an instance of this class, and initializes the fieldthis.f
to null.
-
-
Method Detail
-
toString
public java.lang.String toString()
Invokes the standardjava.lang.Object
methodtoString()
on the fieldthis.f
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- Returns the
String
produced by the contents'toString()
- Code:
- Exact Method Body:
return f.toString();
-
hashCode
public int hashCode()
Invokes the standardjava.lang.Object
methodhashCode()
on the fieldthis.f
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Returns the hash code produced by the contents'
hashCode()
. - Code:
- Exact Method Body:
return f.hashCode();
-
clone
public ByRef<A> clone()
This creates a clone of the wrapper class.
NOTE: The field, itself, is not cloned. AnotherByRef
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 classjava.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.
Ifthis.f
andother.f
hold different references, this method will returnFALSE
even if both of these references have Object-Equality.- Overrides:
equals
in classjava.lang.Object
- Returns:
- Returns
TRUE
if and only if'other'
is an instance of'ByRef'
andthis.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;
-
-