public <M extends net.morimekta.providence.PMessage<M, F>, F extends net.morimekta.providence.descriptor.PField>
    M unwrapMessage(@javax.annotation.Nonnull net.morimekta.providence.descriptor.PMessageDescriptor<M,F> descriptor, @javax.annotation.Nonnull net.morimekta.providence.serializer.SerializerProvider provider) {
        if (!descriptor.getQualifiedName().equals(getType())) {
            throw new IllegalStateException("Any type " + getType() + " does not match requested " + descriptor.getQualifiedName());
        }

        try {
            net.morimekta.providence.serializer.Serializer serializer = provider.getSerializer(getMediaType());
            if (hasData()) {
                return serializer.deserialize(getData().getInputStream(), descriptor);
            } else if (hasText()) {
                java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(getText().getBytes(java.nio.charset.StandardCharsets.UTF_8));
                return serializer.deserialize(bais, descriptor);
            } else {
                throw new net.morimekta.providence.serializer.SerializerException("Neither data, nor text de deserialize.");
            }
        } catch (java.io.IOException e) {
            throw new java.io.UncheckedIOException(e.getMessage(), e);
        }
    }
public < M extends net . morimekta . providence . PMessage < M , F > , F extends net . morimekta . providence . descriptor . PField > M unwrapMessage ( @ javax . annotation . Nonnull net . morimekta . providence . descriptor . PMessageDescriptor < M , F > descriptor , @ javax . annotation . Nonnull net . morimekta . providence . serializer . SerializerProvider provider ) { if ( ! descriptor . getQualifiedName ( ) . equals ( getType ( ) ) ) { throw new IllegalStateException ( "Any type " + getType ( ) + " does not match requested " + descriptor . getQualifiedName ( ) ) ; } try { net . morimekta . providence . serializer . Serializer serializer = provider . getSerializer ( getMediaType ( ) ) ; if ( hasData ( ) ) { return serializer . deserialize ( getData ( ) . getInputStream ( ) , descriptor ) ; } else if ( hasText ( ) ) { java . io . ByteArrayInputStream bais = new java . io . ByteArrayInputStream ( getText ( ) . getBytes ( java . nio . charset . StandardCharsets . UTF_8 ) ) ; return serializer . deserialize ( bais , descriptor ) ; } else { throw new net . morimekta . providence . serializer . SerializerException ( "Neither data, nor text de deserialize." ) ; } } catch ( java . io . IOException e ) { throw new java . io . UncheckedIOException ( e . getMessage ( ) , e ) ; } }
Unwrap a message from this wrapper message. This will use the provided
serializer provider to find a suitable serializer to use to deserialize
the wrapped message. If no serializer is available, or the message
cannot be deserialized an unchecked IO exception is thrown.

@param descriptor The message type to unpack from the content.
@param provider Serializer provider to get serializer from.
@param <M> The message type
@param <F> The message field type
@return The unwrapped message.