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.

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.

    $type: textField
    class: info.magnolia.ui.field.ComboBoxFieldDefinition

Overriding the whole field

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)

class: my.text.field

Overriding a class with a class

#$type: myComboBoxField #this would not work (class has always precedence)
class: my.comboBox.field

Introducing a type to a class

MyTextFieldDefinition extends TextFieldDefinition {}
$type: myTextField

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;

@TypeAlias(type = MyDefinitionInterface.class)
public @interface MyDefinitionType {
    String value();

Annotating definition implementations

public class MyDefinitionImplementation implements MyDefinition {}
$type: myDefinitionImplementation