logo       

self-referential static members: msg#00026

lang.scala

Subject: self-referential static members

Hi,

Regarding static members: it's my understanding they can be viewed as instances of a singleon object. However, I'm not able to acheive the effect I want in the following case, perhaps because it's more akin to viewing them as members of a metaclass. Here is an example in Java coming from the 'SimpleOrm' library:

public class Employee extends SRecordInstance implements java.io.Serializable {
    
    public static final SRecordMeta meta =
        new SRecordMeta(Employee.class, "XX_EMPLOYEE");
    // ie. SRecord objects describe SRecordInstances
    
    public static final SFieldString EMPEE_ID =
        new SFieldString(meta, "EMPEE_ID", 20, SCon.SFD_PRIMARY_KEY);

     ...
}

The salient feature of this is that it's necessary to to refer to Employee as a static member inside the employee class itself. How can I express this directly in Scala? Apologies in advance if this a failure on my part to RTM.

Thanks very much for your time.

Jason
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise