@Override public Metric deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException { Metric metric = (Metric) defaultDeserializer.deserialize(parser, ctxt); System.out.println(metric); // Check if the data type is a File if (metric.getDataType().equals(MetricDataType.File)) { // Perform the custom logic for File types by building up the File object. MetaData metaData = metric.getMetaData(); String fileName = metaData == null ? null : metaData.getFileName(); File file = new File(fileName, Base64.getDecoder().decode((String)metric.getValue())); metric.setValue(file); } return metric; }
public MetricBuilder(Metric metric) throws SparkplugException { this.name = metric.getName(); this.alias = metric.getAlias(); this.timestamp = metric.getTimestamp(); this.dataType = metric.getDataType(); this.isHistorical = metric.isHistorical(); this.isTransient = metric.isTransient(); this.metaData = metric.getMetaData() != null ? new MetaDataBuilder(metric.getMetaData()).createMetaData() : null; this.properties = metric.getMetaData() != null ? new PropertySetBuilder(metric.getProperties()).createPropertySet() : null; switch (dataType) { case DataSet: this.value = metric.getValue() != null ? new DataSetBuilder((DataSet) metric.getValue()).createDataSet() : null; break; case Template: this.value = metric.getValue() != null ? new TemplateBuilder((Template) metric.getValue()).createTemplate() : null; break; default: this.value = metric.getValue(); } }
if (metric.getMetaData() != null) { builder = setMetaData(builder, metric);
: SparkplugBProto.Payload.MetaData.newBuilder(); MetaData metaData = metric.getMetaData(); if (metaData.getContentType() != null) { metaDataBuilder.setContentType(metaData.getContentType());