Interface TypeAnnotationSerializerExtender


  • public interface TypeAnnotationSerializerExtender
    Interface to be implemented to extend the functionality of MetadataType serialization. The implementation of this class is highly recommended when using custom TypeAnnotations in a MetadataType description to be able to create more human readable serialization output. This implementations will be located using SPI.
    Since:
    1.0
    • Method Detail

      • getNameClassMapping

        default Map<String,​Class<? extends TypeAnnotation>> getNameClassMapping()
        The purpose of this registry is to provide a mapping between a "friendly name" (TypeAnnotation.getName()) and the correspondent concrete class (TypeAnnotation#getClass()), this allows to the serialization to write a more compact and easy to read name, instead of using the full qualifier name of the concrete class.

        Using this mapping the serialization goes from:

         {"org.mule.metadata.api.annotation.TypeIdAnnotation":"java.lang.String"}
         
        To:
         {"typeId":"java.lang.String"}
         
        By default the MetadataType serialization will provide mappings for out of the box TypeAnnotation implementations as TypeIdAnnotation, LabelAnnotation, etc.

        Considerations:

        1. The name used as Key of the map for a class, should be the same in TypeAnnotation.getName()
        2. If a mapping is not found for a given TypeAnnotation the full qualifier name will be used
        3. If a mapping tries to use a taken name from an already provided TypeAnnotation implementation, the serialization will fail
        4. If the class defined for a TypeAnnotation implementation is not found in the in the ClassLoader, the deserialization of this object will be ignored.
        Returns:
        a map with the mapping classes by type annotation name.
      • getAdditionalFeatures

        default Collection<Object> getAdditionalFeatures()
        Provides an unspecific list of additional serialization features. Because this interface is meant to remain agnostic of the actual serialization implementation, these features are represented as simply objects in order to avoid exposing internal classes. Also, because these features might be implementation specific, the consumer of this class is free to skip the features it cannot handle. Thus, the features returned here are to be considered more like a suggestion to the serializer than an actual directive.
        Returns:
        a list with additional serialization features