Example usage for org.springframework.core.codec Encoder canEncode

List of usage examples for org.springframework.core.codec Encoder canEncode

Introduction

In this page you can find the example usage for org.springframework.core.codec Encoder canEncode.

Prototype

boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType);

Source Link

Document

Whether the encoder supports the given source element type and the MIME type for the output stream.

Usage

From source file:org.springframework.messaging.handler.invocation.reactive.AbstractEncoderMethodReturnValueHandler.java

@Nullable
@SuppressWarnings("unchecked")
private <T> Encoder<T> getEncoder(ResolvableType elementType, @Nullable MimeType mimeType) {
    for (Encoder<?> encoder : getEncoders()) {
        if (encoder.canEncode(elementType, mimeType)) {
            return (Encoder<T>) encoder;
        }// w  w  w  . j  a  v a2  s.com
    }
    return null;
}