All Downloads are FREE. Search and download functionalities are using the official Maven repository.

id.unum.facade.rest.serialization.PresentationVerifiedReceiptOptionsSerializer Maven / Gradle / Ivy

The newest version!
package id.unum.facade.rest.serialization;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import id.unum.protos.presentationRequest.v1.PresentationRequest;
import id.unum.protos.receipt.v1.PresentationVerifiedReceiptOptions;
import lombok.extern.log4j.Log4j2;

import java.lang.reflect.Type;

@Log4j2
public class PresentationVerifiedReceiptOptionsSerializer implements JsonSerializer {
    @Override
    public JsonElement serialize(PresentationVerifiedReceiptOptions receipt, Type type, JsonSerializationContext jsonSerializationContext) {
        try {
            JsonElement output =
                    JsonParser.parseString(JsonFormat.printer().omittingInsignificantWhitespace().print(receipt));
            return output.getAsJsonObject();
        } catch (InvalidProtocolBufferException e) {
            log.error("Error serializing PresentationVerifiedReceiptOptions: " + e.getMessage());
            e.printStackTrace();
        }

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy