001package Torello.Java.Additional; 002 003import Torello.Java.*; 004 005/** 006 * This is the parent class of the 'Multiple Return Type' classes. ({@code Ret0 ... Ret8}) 007 * All classes which inherit {@code RetN} have ReadOnly, {@code final}, fields. 008 */ 009public abstract class RetN extends MultiType 010{ 011 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 012 protected static final long serialVersionUID = 1; 013 014 RetN() { } 015 // Cannot be private, because of the 'abstract' modifier 016 // Cannot be public (the auto-generated, zero-arg constructor is always public) 017 // because then it makes my JavaDoc ugly 018 019 020 // Optimization: This is saved, so that it is only generated once by the descendant classes 021 // The 'transient' modifier implies that if an instance of, say "Ret3", is peristed using 022 // Object-serialization, this field will not be saved. 023 024 private transient Object[] objArr = null; 025 026 final Object[] asArrayMain() 027 { 028 // This variant-implementation of 'asArray' saves the returned array, since it only needs 029 // to be generated ONCE. This is because all instances of "RetN" are Read-Only, which of 030 // course means their values can never change. This means the array, once created, can be 031 // saved and returned if it is ever needed again. This DOES NOT WORK for "TupleN" which is 032 // Read-Write. 033 034 if (this.objArr == null) this.objArr = asArrayInternal(); 035 return this.objArr; 036 } 037 038 /** 039 * Converts {@code 'this'} Read-Only {@code RetN} instance into a Read-Write {@link TupleN}. 040 * 041 * @return A {@link TupleN} of the same size, which is a modifiable type whose fields are not 042 * decorated with the {@code 'final'} modifier - <I>as the fields in this class are</I>. 043 */ 044 public abstract TupleN toModifiable(); 045}