public class Document
extends java.lang.Object
DocumentStore.xml
specification.
The specification language supports the built-in basic types: Void, Byte,
Boolean, Character, Integer, Short, Long, Float, Double and String; and
the complex types List[T], Set[T], Map[K,V] and Pair[K,V]. If a
specification declares variables of any other type, this is treated as a
symbolic type, but it is uninterpreted, in the sense that nothing is known
about its structure. It is possible to associate other values with such
symbolic types through the use of Maps in the expression language. The
only necessary feature of symbolic types is that instances must be able
to be distinguished. This is achieved using an ID, which by convention
is the first three letters of the type-name, in lower case, followed by
an incrementing digit, starting from 1.
During verification, symbolic types are modelled as instances of the model type Entity, which records the ID name and the symbolic type name. During testing, we expect these symbolic types to translate into domain-specific object types in the application, having the same type name. Testing will need to create instances of these domain types, which we refer to as witness-types, since they must provide witness-values for use during testing. Any witness-type must provide a default constructor, and a constructor that accepts a String ID value. It must also define the hashCode() method to hash on the ID value, and the equals() method to compare two ID values for equality. Apart from this, it may offer whatever methods are needed (typically, to encode internally properties expressed in the specification through Maps).
The Document class shows how to provide such a witness-type, which requires: a default constructor that generates the first witness value; a constructor-from-String that accepts a String ID value; an equals() method that compares a pair of IDs; and a hashCode() method that hashes on the ID. The Document class has further methods that model information about documents, but this must be consistent with any properties associated with a Document through Maps in the specification. Here, for example, we have encoded the terabyte size of the document as a field, so we must ensure that specific Document IDs map to Documents having the same sizes as witness-values declared in the specification.
The directory path to witness-types must be known to the generated
test-driver. Here, we have copied Document to the folders
client/pojo
, client/rs
and
client/ws
to make it available to generated POJO, SOAP and
REST test-drivers which expect to find it there.
Constructor and Description |
---|
Document()
The default constructor, which always creates the first Document in the
monotonic sequence, with the identifier: "doc1".
|
Document(java.lang.String identifier)
The from-String constructor that is required for a witness-type.
|
Document(java.lang.String identifier,
int terabytes)
A domain-specific constructor that allows creation of any Document
with any ID and terabyte size.
|
public Document()
public Document(java.lang.String identifier)
identifier
- a String identifier.public Document(java.lang.String identifier, int terabytes)
identifier
- a String identifier.terabytes
- a Document size in terabytes.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int size()