public class JsonMetadataTypeWriter extends MetadataTypeVisitor implements TypeWriter
TypeWriter that serializes MetadataType objects into a readable and processable JSON file, that
can be deserialized again into a MetadataType using JsonMetadataTypeLoader.
This class is not Thread-safe.| Constructor and Description |
|---|
JsonMetadataTypeWriter()
Creates a new instance which serializes all types explicitly without
handling references
|
JsonMetadataTypeWriter(ObjectTypeReferenceHandler referenceHandler)
Creates a new instance which handles type references through the given
referenceHandler |
| Modifier and Type | Method and Description |
|---|---|
JsonMetadataTypeWriter |
setPrettyPrint(boolean prettyPrint)
Changes the value of PrettyPrint property of the
JsonMetadataTypeWriter. |
String |
toString(MetadataType structure)
Given a
MetadataType, serializes it into JSON format, the result of the serialization will be the output
of the operation as a String |
void |
visitAnyType(AnyType anyType) |
void |
visitArrayType(ArrayType arrayType) |
void |
visitBinaryType(BinaryType binaryType) |
void |
visitBoolean(BooleanType booleanType) |
void |
visitDate(DateType dateType) |
void |
visitDateTime(DateTimeType dateTimeType) |
void |
visitFunction(FunctionType functionType) |
void |
visitIntersection(IntersectionType intersectionType) |
void |
visitNothing(NothingType nothingType) |
void |
visitNull(NullType nullType) |
void |
visitNumber(NumberType numberType) |
void |
visitObject(ObjectType objectType) |
void |
visitString(StringType stringType) |
void |
visitTime(TimeType timeType) |
void |
visitTuple(TupleType tupleType) |
void |
visitUnion(UnionType unionType) |
void |
visitVoid(VoidType voidType) |
void |
write(MetadataType metadataType,
com.google.gson.stream.JsonWriter jsonWriter)
Given a
MetadataType, serializes it into a JSON format, the result of the serialization will be written
by the . |
defaultVisit, visitAttributeField, visitAttributeKey, visitLocalDateTime, visitLocalTime, visitObjectField, visitObjectKey, visitPeriod, visitRegex, visitSimpleType, visitTimeZone, visitTypeParameterpublic JsonMetadataTypeWriter()
public JsonMetadataTypeWriter(ObjectTypeReferenceHandler referenceHandler)
referenceHandlerreferenceHandler - an ObjectTypeReferenceHandlerpublic String toString(MetadataType structure)
MetadataType, serializes it into JSON format, the result of the serialization will be the output
of the operation as a StringtoString in interface TypeWriterstructure - MetadataType to serialize.MetadataSerializingExceptionpublic void write(MetadataType metadataType, com.google.gson.stream.JsonWriter jsonWriter) throws IOException
MetadataType, serializes it into a JSON format, the result of the serialization will be written
by the .metadataType - MetadataType to serialize.jsonWriter - JsonWriter which will be used to write the serialized MetadataTypeIOExceptionpublic JsonMetadataTypeWriter setPrettyPrint(boolean prettyPrint)
JsonMetadataTypeWriter. If it is enabled, when toString(MetadataType)
is executed the output String will be printed in a human readable format, otherwise, by default, the JSON
will be printed in a compact and more performable format.prettyPrint - boolean value indicating if the writer should pretty print the JSONJsonMetadataTypeWriter instancepublic void visitAnyType(AnyType anyType)
visitAnyType in class MetadataTypeVisitorpublic void visitArrayType(ArrayType arrayType)
visitArrayType in class MetadataTypeVisitorpublic void visitBinaryType(BinaryType binaryType)
visitBinaryType in class MetadataTypeVisitorpublic void visitBoolean(BooleanType booleanType)
visitBoolean in class MetadataTypeVisitorpublic void visitDateTime(DateTimeType dateTimeType)
visitDateTime in class MetadataTypeVisitorpublic void visitDate(DateType dateType)
visitDate in class MetadataTypeVisitorpublic void visitNull(NullType nullType)
visitNull in class MetadataTypeVisitorpublic void visitNothing(NothingType nothingType)
visitNothing in class MetadataTypeVisitorpublic void visitVoid(VoidType voidType)
visitVoid in class MetadataTypeVisitorpublic void visitNumber(NumberType numberType)
visitNumber in class MetadataTypeVisitorpublic void visitObject(ObjectType objectType)
visitObject in class MetadataTypeVisitorpublic void visitString(StringType stringType)
visitString in class MetadataTypeVisitorpublic void visitTime(TimeType timeType)
visitTime in class MetadataTypeVisitorpublic void visitTuple(TupleType tupleType)
visitTuple in class MetadataTypeVisitorpublic void visitFunction(FunctionType functionType)
visitFunction in class MetadataTypeVisitorpublic void visitUnion(UnionType unionType)
visitUnion in class MetadataTypeVisitorpublic void visitIntersection(IntersectionType intersectionType)
visitIntersection in class MetadataTypeVisitorCopyright © 2022 MuleSoft, Inc.. All rights reserved.