enhancement
TypedAnnotatable allows you to store dynamic properties on objects; see TL/TypedAnnotatable.
Improvement
Properties with Collection Types
- Property<List<T>> TypedAnnotatable.propertyList(...),
- Property<Set<T>> TypedAnnotatable.propertySet(...),
- Property<Map<K,V>> TypedAnnotatable.propertyMap(...),
Creates properties that return an empty collection as the default value. If you want to store something in such a collection, you must call mkList(MY_LIST_PROPERTY) instead of get(MY_LIST_PROPERTY) to create a mutable list and store it under the property.
Properties with a Dynamic Default Value
If you do not want to specify a constant default value when defining the property, but rather calculate the default value, you can create a dynamic property:
#!java Property<String> MY_PROPERTY = TypedAnnotatable.propertyDynamic(String.class, "myProp", x -> computeDefault(x));
The function takes as an argument the object on which the property is to be looked up, but on which the property has not yet been set.
Code Migration
- Instead of calling the constructor of ` TypedAnnotation.Property ` directly, you must use a factory method: ` TypedAnnotation.propertyXXX(...)`.
Test
- test.com.top_logic.basic.col.AbstractTypedAnnotationTest.testDynamicDefault()
- test.com.top_logic.basic.col.AbstractTypedAnnotationTest.testListProperty()
- test.com.top_logic.basic.col.AbstractTypedAnnotationTest.testSetProperty()
- test.com.top_logic.basic.col.AbstractTypedAnnotationTest.testMapProperty()