01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package js;
21 
22 /**
23  * <p>An <b>opaque</b> class to construct a value reference which is useful from an 
24  * enclosed class to access a variable or field of the enclosing class that must have been 
25  * modified as <tt>final</tt> in that case.</p>
26  *
27  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
28  * 
29  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be 
30  * generated into the target codes. Re-compilers must exit with error on the operations of 
31  * accessing that kind of class objects.
32  */
33 
34 public final class Ref<T>
35 {
36     /**
37      * <p>The value the current value reference refers to.</p>
38      * @since 1.0
39      * @javascript Re-compilers must replace any access to this instance field with the 
40      * JavaScript expression: 
41      * <pre>r[0]</pre>
42      * where <tt>r</tt> is the current instance of the value reference.
43      */
44     public T value;
45 
46     /**
47      * <p>Creates a value reference.</p>
48      * @since 1.0
49      * @javascript Re-compilers must convert this constructor into the JavaScript expression: 
50      * <pre>[value]</pre>.
51      */
52     @SuppressWarnings("unchecked")
53     public Ref(Object value) {
54         this.value = (T)value;
55     }
56 
57     /**
58      * <p>Checks if the current value reference equals another object.</p>
59      * <p>This method is <b>internal</b> and calling this method is unsupported.</p>
60      * @param o Any value
61      * @return <tt>true</tt> if the current value reference equals <tt>o</tt>; 
62      * false, otherwise.
63      * @since 1.0
64      * @javascript Re-compilers must report error on the invocation to an <b>internal</b> method. 
65      */
66     @Override
67     public final boolean equals(Object o) {
68         throw new UnsupportedOperationException();
69     }
70 
71     /**
72      * <p>Gets the hash code of the current value reference.</p>
73      * <p>This method is <b>internal</b> and calling this method is unsupported.</p>
74      * @return The hash code of the current value reference.
75      * @since 1.0
76      * @javascript Re-compilers must report error on the invocation to an <b>internal</b> method. 
77      */
78     @Override
79     public final int hashCode() {
80         throw new UnsupportedOperationException();
81     }
82 
83     /**
84      * <p>Gets the string representation of the current value reference.</p>
85      * <p>This method is <b>internal</b> and calling this method is unsupported.</p>
86      * @return The string representation of the current value reference.
87      * @since 1.0
88      * @javascript Re-compilers must report error on the invocation to an <b>internal</b> method. 
89      */
90     @Override
91     public final String toString() {
92         throw new UnsupportedOperationException();
93     }
94 }