package org.msgpack.jackson.dataformat;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.IOException;

@JsonSerialize(using = MessagePackExtensionType.Serializer.class)
public class MessagePackExtensionType
{
    private final int type;
    private final byte[] data;

    public MessagePackExtensionType(int extType, byte[] extData)
    {
        this.type = extType;
        this.data = extData;
    }

    public int getType()
    {
        return type;
    }

    public byte[] getData()
    {
        return data;
    }

    public static class Serializer extends JsonSerializer<MessagePackExtensionType>
    {
        @Override
        public void serialize(MessagePackExtensionType value, JsonGenerator gen, SerializerProvider serializers)
                throws IOException, JsonProcessingException
        {
            if (gen instanceof MessagePackGenerator) {
                MessagePackGenerator msgpackGenerator = (MessagePackGenerator)gen;
                msgpackGenerator.writeExtendedType(value);
            }
            else {
                throw new IllegalStateException("'gen' is expected to be MessagePackGenerator but it's " + gen.getClass());
            }
        }
    }
}

@@ -472,19 +472,20 @@
 e final 
-int
+byte
  type;%0A 
@@ -551,19 +551,20 @@
 ionType(
-int
+byte
  extType
@@ -667,11 +667,12 @@
 lic 
-int
+byte
  get

Change type of MessagePackExtensionType#type