36 lines
981 B
Plaintext
36 lines
981 B
Plaintext
= Attributes (and inheritance)
|
|
|
|
|
|
[source]
|
|
----
|
|
class Customer {
|
|
Integer id;
|
|
String name;
|
|
Address address;
|
|
int quota;
|
|
}
|
|
|
|
class DomesticCustomer extends Customer {
|
|
String taxId;
|
|
String attr1;
|
|
String attr2;
|
|
}
|
|
|
|
class ForeignCustomer extends Customer {
|
|
String vat;
|
|
String attr3;
|
|
String attr4;
|
|
}
|
|
----
|
|
|
|
The general idea is that the attributes are ordered alphabetically, super attributes first. Subtypes are sorted
|
|
depth-first and the attributes are sorted alphabetically within each sub-type. So the order of the attributes
|
|
depends on where we start.
|
|
|
|
Starting from Customer we have: `[address, name, quota, attr1, attr2, taxId, attr3, attr4, vat]`
|
|
Starting from DomesticCustomer we have: `[address, name, quota, attr1, attr2]`
|
|
Starting from ForeignCustomer we have: `[address, name, quota, attr3, attr4, vat]`
|
|
|
|
This is why we cannot really have the position be an inherent part of the attribute itself - it changes depending on
|
|
where we start.
|