Package org.mule.metadata.persistence
Interface ObjectTypeReferenceHandler
-
- All Known Implementing Classes:
DefaultObjectTypeReferenceHandler,InnerCatalogObjectTypeReferenceHandler,NullObjectTypeReferenceHandler
public interface ObjectTypeReferenceHandlerAllows to serialize and deserializeObjectTypeinstances which are not explicitly defined but instead pointed at by some means- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<TypeBuilder>readReference(String typeId)Returns aTypeBuilderreferenced by the giventypeId.default booleanshouldWriteReference(ObjectType type)Given anObjectTyperetrieves if should be written as a reference or not.Optional<String>writeReference(ObjectType type, com.google.gson.stream.JsonWriter writer)Uses thewriterto write a reference to the giventype.
-
-
-
Method Detail
-
writeReference
Optional<String> writeReference(ObjectType type, com.google.gson.stream.JsonWriter writer)
Uses thewriterto write a reference to the giventype.This method returns the written reference, so that it can be used as an id to deserialize. However, some implementations might be unable to handle some specific types, which is why the reference might be
Optional.empty().In such case, it's the invoker responsibility to either attempt using a different implementation of this contract or to just treat the type explicitly instead of through a reference.
- Parameters:
type- the type to writewriter- aJsonWriter- Returns:
- the reference that was written or
Optional.empty()
-
shouldWriteReference
default boolean shouldWriteReference(ObjectType type)
Given anObjectTyperetrieves if should be written as a reference or not.Default implementation returns `true` to maintain backwards compatibility.
- Parameters:
type- the type to write- Returns:
- whether the type should be written or not.
-
readReference
Optional<TypeBuilder> readReference(String typeId)
Returns aTypeBuilderreferenced by the giventypeId. If the reference cannot be handled or points to an unknown type it returnsOptional.empty()- Parameters:
typeId- a type id- Returns:
- an
OptionalTypeBuilder
-
-