Type aliases
The $type
property allows developers to use easy-to-remember shortcuts for definition classes in YAML definitions instead of fully classified Java class names.
-
See in which definitions you can use type aliases.
-
See a list of all aliases for
DatasourceType
.
Overriding a type or class
If you inherit or decorate a definition, you might need to override the original type or class. You do not need to worry when overriding a type with another type or a class with another class. However, be careful when overriding a type with a class because there is no type for the class you want to use and vice versa.
/moduleA/dialogs/myDialog.yaml
properties:
myField:
$type: textField
anotherField:
class: info.magnolia.ui.field.ComboBoxFieldDefinition
Overriding the whole field
/moduleB/decorations/moduleA/dialogs/myDialog.properties.yaml
myField: !override #everything from the original definition is removed
$type: myTextField
#class: my.text.field #this would work as well
Overriding a type with a class (class takes precedence)
/moduleB/decorations/moduleA/dialogs/myDialog.properties.myField.yaml
class: my.text.field
Custom aliases
Introducing type annotation to a custom type
import info.magnolia.config.resolver.TypeAlias;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@TypeAlias(type = MyDefinitionInterface.class)
public @interface MyDefinitionType {
String value();
}