rolodex
Class Name
java.lang.Object
|
+--rolodex.Name
- All Implemented Interfaces:
- java.io.Serializable
- public class Name
- extends java.lang.Object
- implements java.io.Serializable
Class Name is the heavyweight translation of the RSL atomic object
definition
object Name is string;
"Heavy-weight" means that Name is a complete class, with a constructor,
string conversion method, and equals method.
A lighter-weight class definition would have just a single public string
data member, with no methods. Such a definition violates our convention of
no public data members. A wimped-out translation would be to eliminate the
mnemonic identifier "Name" entirely from the design, replacing it directly
with type String. This definition violates our convention of design-to-spec
traceability.
The problem we're having here is one of RSL-to-Java translation. The
problem is due to the lack a simple type definition construct in Java, such
as "typedef" in C/C++ or "type" in Pascal-class languages. Such a construct
allows the programmer to equate a mnemonic name with an existing type.
E.g.,
typedef String Name;
equates the identifier "Name" with the type identifier "String", such that
"Name" becomes a synonym for "String". Absent such a construct in Java,
we're stuck with defining Name as a class or losing Name altogether by
systematically replacing it with String.
A nice solution to this problem would be to define Name simply as
class Name extends String{};
This would provide precisely the definition of Name that we're after here.
Unfortunately (and aggravatingly), class String is defined as
final, which precludes extending it.
- See Also:
- Serialized Form
Field Summary |
protected java.lang.String |
value
|
Constructor Summary |
Name(java.lang.String value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
value
protected java.lang.String value
Name
public Name(java.lang.String value)
stringValue
public java.lang.String stringValue()
equals
public boolean equals(Name n)