Package org.mule.metadata.persistence
Class NullObjectTypeReferenceHandler
- java.lang.Object
-
- org.mule.metadata.persistence.NullObjectTypeReferenceHandler
-
- All Implemented Interfaces:
ObjectTypeReferenceHandler
public final class NullObjectTypeReferenceHandler extends Object implements ObjectTypeReferenceHandler
A null object implementation ofObjectTypeReferenceHandlerwhich handles no reference. Take into account that according to the contract defined inObjectTypeReferenceHandler, each time any of these methods returnOptional.empty()the invoker has the responsibility to resolve the type somehow else.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description NullObjectTypeReferenceHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<TypeBuilder>readReference(String typeId)Returns aTypeBuilderreferenced by the giventypeId.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
public 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.
- Specified by:
writeReferencein interfaceObjectTypeReferenceHandler- Parameters:
type- the type to writewriter- aJsonWriter- Returns:
- the reference that was written or
Optional.empty()
-
shouldWriteReference
public boolean shouldWriteReference(ObjectType type)
Description copied from interface:ObjectTypeReferenceHandlerGiven anObjectTyperetrieves if should be written as a reference or not.Default implementation returns `true` to maintain backwards compatibility.
- Specified by:
shouldWriteReferencein interfaceObjectTypeReferenceHandler- Parameters:
type- the type to write- Returns:
- whether the type should be written or not.
-
readReference
public 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()- Specified by:
readReferencein interfaceObjectTypeReferenceHandler- Parameters:
typeId- a type id- Returns:
- an
OptionalTypeBuilder
-
-