@Retention(value=RUNTIME) @Target(value=TYPE) @Incubating public @interface Managed
Gradle generates implementations for managed types. As such, managed types are declared either as interfaces or abstract classes. The generated implementation integrates with the model space mechanisms, and manages mutability.
Managed types are mostly behaviour-less, as they are data. Instances of managed types should effectively be considered value objects.
Managed types declare their structure as properties, via getter and setter methods. Getter and setter methods are expected to conform to the well-known Java Bean naming conventions. A read/write “name” property would be expressed via the following methods:
void setName(String name); String getName();
A getter and setter must be declared for each property that is not of a managed type or of ManagedSet
.
For properties of managed types or of ManagedSet
the getter is mandatory and the setter is optional.
If no setter is provided the property is considered inherent and defaults to an "empty" instance of the type.
The following JDK types are allowed:
All Enum
types are also allowed.
Properties that are themselves of a managed type are also supported.
Currently, the only collection type that is supported is ManagedSet
.
Properties of any other type must have their getter annotated with Unmanaged
.
An unmanaged property is not transparent to the model infrastructure and is guaranteed to be immutable when realized.
Managed types can be arranged into an inheritance hierarchy. Every type in the hierarchy must conform to the constraints of managed types.
Managed types can contain getter methods that return calculated values, based on other properties. For example, a “name” property may return the concatenation of a “firstName” and “lastName” property. When using Java 8 or later, such properties can be implemented as interface default methods. Alternatively, the managed type can be implemented as an abstract class with the calculated property implemented as a non-abstract getter method. In both cases, the implementation of the calculated property getter may not call any setter method.
A managed type can be implemented as an abstract class.
All property getters and setters must be declared abstract
(with the exception of calculated read-only properties).
The class cannot contain instance variables, constructors, or any methods that are not a getter or setter.
Please see Model
for information on creating model elements of managed types.