Class DatadogActionConverter<T>
- java.lang.Object
-
- org.datadog.jenkins.plugins.datadog.util.conversion.DatadogActionConverter<T>
-
- Type Parameters:
T
- The type of converted objects (should be as narrow as possible, so that different converters do not conflict)
- All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter
,com.thoughtworks.xstream.converters.ConverterMatcher
- Direct Known Subclasses:
BuildSpanAction.ConverterImpl
,DequeueAction.ConverterImpl
,EnqueueAction.ConverterImpl
,GitCommitAction.ConverterImpl
,GitRepositoryAction.ConverterImpl
,NodeInfoAction.ConverterImpl
,PipelineNodeInfoAction.ConverterImpl
,PipelineQueueInfoAction.ConverterImpl
,StatusAction.ConverterImpl
,TraceInfoAction.ConverterImpl
,TraceSpan.TraceSpanContext.ConverterImpl
public abstract class DatadogActionConverter<T> extends Object implements com.thoughtworks.xstream.converters.Converter
Converter that supports data versioning. Different data version = different serialization format for objects of the given type. Each version is handled by a childVersionedConverter
that encapsulates serialization/deserialization logic for that specific version.Serialized data contains version in an attribute. When data is deserialized, the version is used to determine which child converter should handle deserialization.
If you want to change serialization format for a specific type, leave the previous
VersionedConverter
instances in place (they will be used to deserialize older data) and add a new one with a higher version number.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DatadogActionConverter(VersionedConverter<T>... converters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(Class type)
void
marshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
Object
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
-
-
-
Constructor Detail
-
DatadogActionConverter
@SafeVarargs protected DatadogActionConverter(@Nonnull VersionedConverter<T>... converters)
- Parameters:
converters
- The list of versioned converters. Writing is always done with the most up-to-date converter (the one with the maximum version). Reading is done with the appropriate converter (the one that has version that matches the data version). If converter with the specified version does not exist, or data has no version attribute (written by an old version of the plugin), no deserialization is performed.
-
-
Method Detail
-
canConvert
public boolean canConvert(Class type)
- Specified by:
canConvert
in interfacecom.thoughtworks.xstream.converters.ConverterMatcher
-
marshal
public void marshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
- Specified by:
marshal
in interfacecom.thoughtworks.xstream.converters.Converter
-
unmarshal
@Nullable public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
- Specified by:
unmarshal
in interfacecom.thoughtworks.xstream.converters.Converter
-
-