Source:
<code>public JsonElement serialize(ITmfStateInterval src, @Nullable Type typeOfSrc, @Nullable JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(TmfIntervalStrings.START, src.getStartTime()); jsonObject.addProperty(TmfIntervalStrings.END, src.getEndTime()); jsonObject.addProperty(TmfIntervalStrings.QUARK, src.getAttribute()); Object value = src.getValue(); if (value == null) { jsonObject.addProperty(TmfIntervalStrings.TYPE, TmfIntervalStrings.NULL); return jsonObject; } if (value.getClass().isInstance(CustomStateValue.class)) { jsonObject.addProperty(TmfIntervalStrings.TYPE, <START> CustomStateValue.class.toString()); <END> } else { jsonObject.addProperty(TmfIntervalStrings.TYPE, value.getClass().getName()); } if (value instanceof CustomStateValue) { CustomStateValue customValue = (CustomStateValue) value; int size = customValue.getSerializedSize(); ByteBuffer buffer = ByteBuffer.allocate(size); buffer.clear(); ISafeByteBufferWriter sbbw = SafeByteBufferFactory.wrapWriter(buffer, size); customValue.serialize(sbbw); byte[] serializedValue = buffer.array(); jsonObject.addProperty(TmfIntervalStrings.VALUE, Base64.getEncoder().encodeToString(serializedValue)); } else if (value instanceof Number) { Number number = (Number) value; jsonObject.addProperty(TmfIntervalStrings.VALUE, number); } else if (value instanceof String) { jsonObject.addProperty(TmfIntervalStrings.VALUE, (String) value); } else { jsonObject.addProperty(TmfIntervalStrings.VALUE, value.toString()); } return jsonObject; }</code><technical_language>safer getName() parameter Class.forName(String)</technical_language>

Target:
public JsonElement serialize(ITmfStateInterval src, @Nullable Type typeOfSrc, @Nullable JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(TmfIntervalStrings.START, src.getStartTime()); jsonObject.addProperty(TmfIntervalStrings.END, src.getEndTime()); jsonObject.addProperty(TmfIntervalStrings.QUARK, src.getAttribute()); Object value = src.getValue(); if (value == null) { jsonObject.addProperty(TmfIntervalStrings.TYPE, TmfIntervalStrings.NULL); return jsonObject; } if (value.getClass().isInstance(CustomStateValue.class)) { jsonObject.addProperty(TmfIntervalStrings.TYPE, CustomStateValue.class.getName()); } else { jsonObject.addProperty(TmfIntervalStrings.TYPE, value.getClass().getName()); } if (value instanceof CustomStateValue) { CustomStateValue customValue = (CustomStateValue) value; int size = customValue.getSerializedSize(); ByteBuffer buffer = ByteBuffer.allocate(size); buffer.clear(); ISafeByteBufferWriter sbbw = SafeByteBufferFactory.wrapWriter(buffer, size); customValue.serialize(sbbw); byte[] serializedValue = buffer.array(); jsonObject.addProperty(TmfIntervalStrings.VALUE, Base64.getEncoder().encodeToString(serializedValue)); } else if (value instanceof Number) { Number number = (Number) value; jsonObject.addProperty(TmfIntervalStrings.VALUE, number); } else if (value instanceof String) { jsonObject.addProperty(TmfIntervalStrings.VALUE, (String) value); } else { jsonObject.addProperty(TmfIntervalStrings.VALUE, value.toString()); } return jsonObject; }