@@ -50,15 +50,16 @@ following constraints:
5050The general naming rule for accessors is that a slot named _ foo_ must
5151have a ` getFoo() ` read accessor and a ` setFoo() ` write accessor.
5252
53- Two specific rules apply to boolean-typed slots:
53+ Two specific rules apply to ** required, boolean-typed** slots:
5454
5555* the read accessor of a boolean-typed slot named _ foo_ must be
5656 ` isFoo() ` , rather than ` getFoo() ` ;
5757
58- * if the name of the slot already starts with ` is ` , then the read
59- accessor is named as the underlying field (for example, if the slot is
60- named ` isFoo ` , then the read accessor must be ` isFoo() ` ; the write
61- accessor will still be ` setIsFoo() ` as per the general rule).
58+ * if the name of the slot already starts with ` is ` followed by an
59+ uppercase letter, that ` is ` prefix is removed before applying the
60+ previous rule (so for example, a slot named ` isFoo ` must have a read
61+ accessor that is also named ` isFoo() ` and a write accessor that is
62+ named ` setFoo ` , as if the slot had been named simply ` Foo ` ).
6263
6364Those rules were chosen because they correspond to the behaviour of the
6465[ Lombok] ( https://projectlombok.org ) annotation processor, which can then
@@ -115,6 +116,60 @@ namespace. They are:
115116| SlotName | Provide the original name of a slot |
116117| Converter | Indicate that the class or slot requires a custom converter |
117118
119+ Example
120+ -------
121+ Here is an example of a class ready to be used with the runtime (import
122+ declarations omitted for brevity):
123+
124+ ``` java
125+ @LinkURI (" https://example.org/myschema/classes/MyClass" )
126+ public class MyClass {
127+
128+ // The unique identifier for objects of that class
129+ @Identifier
130+ @LinkURI (" https://example.org/myschema/slots/id" )
131+ private String id;
132+
133+ // Contains the runtime type of an object (to distinguish between
134+ // the various subclasses of MyClass)
135+ @TypeDesignator
136+ @LinkURI (" https://example.org/myschema/slots/type" )
137+ private String type;
138+
139+ // The values of this slot (instances of AnotherClass) are expected
140+ // to be inlined (rather than referenced) as a list (rather than as
141+ // dictionary)
142+ @Inlined (asList = true )
143+ @LinkURI (" https://example.org/myschema/slots/foos" )
144+ public List<AnotherClass > foos;
145+
146+ // Accessors for all the slots
147+ public String getId () {
148+ return id;
149+ }
150+
151+ public void setId (String id ) {
152+ this . id = id;
153+ }
154+
155+ public String getType () {
156+ return type;
157+ }
158+
159+ public void setType (String type ) {
160+ this . type = type;
161+ }
162+
163+ public List<AnotherClass > getFoos () {
164+ return foos;
165+ }
166+
167+ public void setFoos (List<AnotherClass > foos ) {
168+ this . foos = foos;
169+ }
170+ }
171+ ```
172+
118173Generating the Java code
119174------------------------
120175In the future, the LinkML-Java project will most likely provide its own
0 commit comments