001package Torello.Java.Additional;
002
003import Torello.Java.UnreachableError;
004
005/**
006 * Contains a <B>{@code static}</B> reference to a <B STYLE='color:red'>singleton</B>-instance of
007 * {@code Tuple0}.
008 */
009public class Tuple0
010    extends TupleN
011    implements java.io.Serializable
012{
013    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID>  */
014    protected static final long serialVersionUID = 1;
015
016    /** This is the singleton instance of this class. */
017    public static final Tuple0 T0 = new Tuple0();
018
019    /** Constructs this object */
020    private Tuple0() { }
021
022    // Super-class uses this for toString, equals, and hashCode
023    // There is an optimization, so if this is requested multiple times, it is saved in a
024    // transient field.
025
026    private static final Object[] EMPTY_ARR = new Object[0];
027
028    final Object[] asArrayInternal()
029    { return EMPTY_ARR; }
030
031    /**
032     * Returns {@code '0'}, indicating how many fields are declared by this class.
033     * @return As an instance of {@code Tuple0}, this method returns {@code '0'};
034     */
035    public int n() { return 0; }
036
037    /**
038     * This method may not be invoked, or it will throw an exception.
039     * @throws UnsupportedOperationException This class only <I>one <B>singleton</B> instance.</I>
040     */
041    public final Tuple0 clone()
042    {
043        throw new UnsupportedOperationException
044            ("The singleton instance of Tuple0 cannot be cloned.");
045    }
046
047    /**
048     * Produces the {@code Tuple0} singleton-instance {@code 'toString'}
049     * @return The Java Literal-String {@code "Tuple0 Singleton Instance"}
050     */
051    @Override
052    public final String toString()
053    { return "Tuple0 Singleton Instance"; }
054
055    /**
056     * There is only one, singleton, instance of {@code Tuple0}, so reference-equality is the only
057     * equality-test.
058     * 
059     * @return {@code TRUE} if and only if {@code 'other'} is this class' singleton instance of 
060     * {@code Tuple0}
061     */
062    @Override
063    public final boolean equals(Object other)
064    { return this == other; }
065
066    /**
067     * Returns the hash-code for the singleton-instance of {@code Ret0}
068     * @return A nice round-number, 55 to be exact.
069     */
070    @Override
071    public final int hashCode()
072    { return 55; }
073
074    /**
075     * This method is guaranteed to throw an {@code IndexOutOfBoundsExceptin}.  There aren't any 
076     * fields that can be retrieved from the {@code Tuple0} Singleton-Instance.
077     * 
078     * @param i ignored parameter
079     * @return Does not return anything.  Always throws IOOBEX.
080     * @throws IndexOutOfBoundsException Always throws.
081     */
082    public Object get(int i)
083    {
084        // Always throws Out Of Bounds Exception, Cannot get from Tuple0
085        CHECK_GET(i);
086
087        // The above method should always throw IOOOBEX, this line quiets javac
088        throw new UnreachableError();
089    }
090
091    public Ret0 toImmutable()
092    { return Ret0.R0; }
093}