Skip to content

Commit

Permalink
Renaming Serializer to JsonSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
LikeTheSalad committed Jun 6, 2023
1 parent 10a4a7c commit d84d329
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public final class Serializer {
public final class JsonSerializer {

private static final DslJson<Object> dslJson =
new DslJson<>(Settings.basicSetup().skipDefaultValues(true));

private Serializer() {}
private JsonSerializer() {}

public static <T> JsonReader.ReadObject<T> tryFindReader(Class<T> manifest) {
return dslJson.tryFindReader(manifest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.dslplatform.json.JsonConverter;
import com.dslplatform.json.JsonReader;
import com.dslplatform.json.JsonWriter;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.Serializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.JsonSerializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.metrics.MetricDataJson;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.metrics.data.ExponentialHistogram;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.metrics.data.Gauge;
Expand Down Expand Up @@ -101,7 +101,7 @@ public static void write(JsonWriter writer, MetricDataJson value) {
private static <T> JsonReader.ReadObject<T> getReader(Class<T> type) {
JsonReader.ReadObject<?> reader = READERS.get(type);
if (reader == null) {
reader = Serializer.tryFindReader(type);
reader = JsonSerializer.tryFindReader(type);
READERS.put(type, reader);
}

Expand All @@ -111,7 +111,7 @@ private static <T> JsonReader.ReadObject<T> getReader(Class<T> type) {
private static <T> JsonWriter.WriteObject<T> getWriter(Class<T> type) {
JsonWriter.WriteObject<?> writer = WRITERS.get(type);
if (writer == null) {
writer = Serializer.tryFindWriter(type);
writer = JsonSerializer.tryFindWriter(type);
WRITERS.put(type, writer);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.opentelemetry.contrib.disk.buffer.internal.serialization.serializers;

import io.opentelemetry.contrib.disk.buffer.internal.serialization.mapping.logs.ResourceLogsDataMapper;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.Serializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.JsonSerializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.logs.ResourceLogsData;
import io.opentelemetry.sdk.logs.data.LogRecordData;
import java.io.IOException;
Expand All @@ -23,7 +23,7 @@ static LogRecordDataSerializer get() {
@Override
public byte[] serialize(List<LogRecordData> logRecordData) {
try {
return Serializer.serialize(ResourceLogsDataMapper.INSTANCE.toJsonDto(logRecordData));
return JsonSerializer.serialize(ResourceLogsDataMapper.INSTANCE.toJsonDto(logRecordData));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand All @@ -33,7 +33,7 @@ public byte[] serialize(List<LogRecordData> logRecordData) {
public List<LogRecordData> deserialize(byte[] source) {
try {
return ResourceLogsDataMapper.INSTANCE.fromJsonDto(
Serializer.deserialize(ResourceLogsData.class, source));
JsonSerializer.deserialize(ResourceLogsData.class, source));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.opentelemetry.contrib.disk.buffer.internal.serialization.serializers;

import io.opentelemetry.contrib.disk.buffer.internal.serialization.mapping.metrics.ResourceMetricsDataMapper;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.Serializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.JsonSerializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.metrics.ResourceMetricsData;
import io.opentelemetry.sdk.metrics.data.MetricData;
import java.io.IOException;
Expand All @@ -23,7 +23,7 @@ static MetricDataSerializer get() {
@Override
public byte[] serialize(List<MetricData> metricData) {
try {
return Serializer.serialize(ResourceMetricsDataMapper.INSTANCE.toJsonDto(metricData));
return JsonSerializer.serialize(ResourceMetricsDataMapper.INSTANCE.toJsonDto(metricData));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand All @@ -33,7 +33,7 @@ public byte[] serialize(List<MetricData> metricData) {
public List<MetricData> deserialize(byte[] source) {
try {
return ResourceMetricsDataMapper.INSTANCE.fromJsonDto(
Serializer.deserialize(ResourceMetricsData.class, source));
JsonSerializer.deserialize(ResourceMetricsData.class, source));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.opentelemetry.contrib.disk.buffer.internal.serialization.serializers;

import io.opentelemetry.contrib.disk.buffer.internal.serialization.mapping.spans.ResourceSpansDataMapper;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.Serializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.JsonSerializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.models.spans.ResourceSpansData;
import io.opentelemetry.sdk.trace.data.SpanData;
import java.io.IOException;
Expand All @@ -23,7 +23,7 @@ static SpanDataSerializer get() {
@Override
public byte[] serialize(List<SpanData> spanData) {
try {
return Serializer.serialize(ResourceSpansDataMapper.INSTANCE.toJsonDto(spanData));
return JsonSerializer.serialize(ResourceSpansDataMapper.INSTANCE.toJsonDto(spanData));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand All @@ -33,7 +33,7 @@ public byte[] serialize(List<SpanData> spanData) {
public List<SpanData> deserialize(byte[] source) {
try {
return ResourceSpansDataMapper.INSTANCE.fromJsonDto(
Serializer.deserialize(ResourceSpansData.class, source));
JsonSerializer.deserialize(ResourceSpansData.class, source));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package io.opentelemetry.contrib.disk.buffer.testutils;

import io.opentelemetry.contrib.disk.buffer.internal.serialization.Serializer;
import io.opentelemetry.contrib.disk.buffer.internal.serialization.JsonSerializer;
import java.io.IOException;

public abstract class BaseJsonSerializationTest<T> {
protected byte[] serialize(T item) {
try {
return Serializer.serialize(item);
return JsonSerializer.serialize(item);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

protected T deserialize(byte[] json) {
try {
return Serializer.deserialize(getTargetClass(), json);
return JsonSerializer.deserialize(getTargetClass(), json);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit d84d329

Please sign in to comment.