Public:BWmeta service/Java mapping

From YaddaWiki

(Difference between revisions)
Jump to: navigation, search
Line 3: Line 3:
== General contracts ==
== General contracts ==
-
* Every class has a public empty constructor.
+
Unless explicitly stated in the documentation, every "Y" class has the following properties:
-
* Every setter and every list adder in every class returns <code>this</code>, which allows chained setting, e.g.:
+
 
 +
* has a public empty constructor.
 +
* every property is protected, but has a public getter and setter.
 +
* every setter and every list adder returns <code>this</code>, which allows chained setting, e.g.:
  new YElement()
  new YElement()
     .setId("bwmeta1.element.foo")
     .setId("bwmeta1.element.foo")
     .addName(new YName().setText("Foo").setLanguage(YLanguage.English))
     .addName(new YName().setText("Foo").setLanguage(YLanguage.English))
     .addDescription(new YDescription().setText("Lorem ipsum").setLanguage(YLanguage.Latin));
     .addDescription(new YDescription().setText("Lorem ipsum").setLanguage(YLanguage.Latin));
-
* Every property is protected, but has a public getter and setter.
+
* getters of <code>String</code>, <code>YLanguage</code> and <code>List</code> properties can never return <code>null</code>.  Instead, an empty <code>String</code>, <code>YLanguage.Undetermined</code> or an empty <code>List</code> is returned, respectively.
-
* Getters of <code>String</code>, <code>YLanguage</code> and <code>List</code> properties can never return <code>null</code>.  Instead, they return an empty <code>String</code>, <code>YLanguage.Undetermined</code> or an empty <code>List</code>, respectively.
+
* every <code>List</code> property has an adder (which returns <code>this</code>).
 +
* for every <code>List&lt;T&gt;</code> property:
 +
** its getter returns a modifiable <code>List&lt;T&gt;</code>;
 +
** its getter returns the same reference all the time;
 +
** its setter accepts any <code>Collection&lt;T&gt;</code> (and copies the contents);
 +
** there's an adder (which returns <code>this</code>).
 +
 
 +
The folowing contracts are to be implemented/verified in the future:
 +
* <code>hashCode()</code> and <code>equals()</code> methods are based on the values of all the properties, i.e., two "Y" objects are equal iff they are of the same type and all their properties are equal.
<!-- * Only the following property types are present: a primitive type, a String, another "Y" object, a List of Strings or "Y" objects. -->
<!-- * Only the following property types are present: a primitive type, a String, another "Y" object, a List of Strings or "Y" objects. -->

Revision as of 10:35, 27 September 2010

Service details
NameBWmeta
Code location
(relative to SVN root)
projects/dir/bwmeta-core
Javadoc
Contact personJakub Jurkiewicz

General contracts

Unless explicitly stated in the documentation, every "Y" class has the following properties:

  • has a public empty constructor.
  • every property is protected, but has a public getter and setter.
  • every setter and every list adder returns this, which allows chained setting, e.g.:
new YElement()
    .setId("bwmeta1.element.foo")
    .addName(new YName().setText("Foo").setLanguage(YLanguage.English))
    .addDescription(new YDescription().setText("Lorem ipsum").setLanguage(YLanguage.Latin));
  • getters of String, YLanguage and List properties can never return null. Instead, an empty String, YLanguage.Undetermined or an empty List is returned, respectively.
  • every List property has an adder (which returns this).
  • for every List<T> property:
    • its getter returns a modifiable List<T>;
    • its getter returns the same reference all the time;
    • its setter accepts any Collection<T> (and copies the contents);
    • there's an adder (which returns this).

The folowing contracts are to be implemented/verified in the future:

  • hashCode() and equals() methods are based on the values of all the properties, i.e., two "Y" objects are equal iff they are of the same type and all their properties are equal.


Personal tools