Class Transformers
java.lang.Object
org.springframework.integration.dsl.Transformers
An utility class to provide methods for out-of-the-box
Transformer
s.- Since:
- 5.0
- Author:
- Artem Bilan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
U> PayloadTypeConvertingTransformer<T, U> static <T> DecodingTransformer<T>
The factory method for theDecodingTransformer
.static <T> DecodingTransformer<T>
The factory method for theDecodingTransformer
.static <T> DecodingTransformer<T>
The factory method for theDecodingTransformer
.static <T> DecodingTransformer<T>
decoding
(Codec codec, Expression typeExpression) The factory method for theDecodingTransformer
.deserializer
(String... allowedPatterns) deserializer
(Deserializer<Object> deserializer, String... allowedPatterns) static <T> EncodingPayloadTransformer<T>
The factory method for theEncodingPayloadTransformer
.static JsonToObjectTransformer
fromJson()
static JsonToObjectTransformer
static JsonToObjectTransformer
fromJson
(Class<?> targetClass, JsonObjectMapper<?, ?> jsonObjectMapper) static JsonToObjectTransformer
fromJson
(ResolvableType targetType) Construct aJsonToObjectTransformer
based on the providedResolvableType
.static JsonToObjectTransformer
fromJson
(ResolvableType targetType, JsonObjectMapper<?, ?> jsonObjectMapper) static JsonToObjectTransformer
fromJson
(JsonObjectMapper<?, ?> jsonObjectMapper) static MapToObjectTransformer
static MapToObjectTransformer
static StreamTransformer
The factory method for theStreamTransformer
.static StreamTransformer
fromStream
(String charset) Create an instance with the charset to convert the stream to a String; if null abyte[]
will be produced instead.static ObjectToStringTransformer
static ObjectToStringTransformer
objectToString
(String charset) serializer
(Serializer<Object> serializer) static SyslogToMapTransformer
static ObjectToJsonTransformer
toJson()
static ObjectToJsonTransformer
static ObjectToJsonTransformer
toJson
(ObjectToJsonTransformer.ResultType resultType) Factory for theObjectToJsonTransformer
based on the providedObjectToJsonTransformer.ResultType
.static ObjectToJsonTransformer
toJson
(ObjectToJsonTransformer.ResultType resultType, String contentType) static ObjectToJsonTransformer
toJson
(JsonObjectMapper<?, ?> jsonObjectMapper) static ObjectToJsonTransformer
toJson
(JsonObjectMapper<?, ?> jsonObjectMapper, String contentType) static ObjectToJsonTransformer
toJson
(JsonObjectMapper<?, ?> jsonObjectMapper, ObjectToJsonTransformer.ResultType resultType) static ObjectToJsonTransformer
toJson
(JsonObjectMapper<?, ?> jsonObjectMapper, ObjectToJsonTransformer.ResultType resultType, String contentType) static ObjectToMapTransformer
toMap()
static ObjectToMapTransformer
toMap
(boolean shouldFlattenKeys) static ObjectToMapTransformer
toMap
(JsonObjectMapper<?, ?> jsonObjectMapper) static ObjectToMapTransformer
toMap
(JsonObjectMapper<?, ?> jsonObjectMapper, boolean shouldFlattenKeys)
-
Constructor Details
-
Transformers
public Transformers()
-
-
Method Details
-
objectToString
-
objectToString
-
toMap
-
toMap
-
toMap
-
toMap
public static ObjectToMapTransformer toMap(JsonObjectMapper<?, ?> jsonObjectMapper, boolean shouldFlattenKeys) -
fromMap
-
fromMap
-
toJson
-
toJson
-
toJson
public static ObjectToJsonTransformer toJson(@Nullable JsonObjectMapper<?, ?> jsonObjectMapper, @Nullable ObjectToJsonTransformer.ResultType resultType) -
toJson
-
toJson
public static ObjectToJsonTransformer toJson(@Nullable JsonObjectMapper<?, ?> jsonObjectMapper, @Nullable String contentType) -
toJson
public static ObjectToJsonTransformer toJson(@Nullable ObjectToJsonTransformer.ResultType resultType) Factory for theObjectToJsonTransformer
based on the providedObjectToJsonTransformer.ResultType
.- Parameters:
resultType
- theObjectToJsonTransformer.ResultType
to use. Defaults toObjectToJsonTransformer.ResultType.STRING
.- Returns:
- the ObjectToJsonTransformer
- Since:
- 5.0.9
-
toJson
public static ObjectToJsonTransformer toJson(@Nullable ObjectToJsonTransformer.ResultType resultType, @Nullable String contentType) -
toJson
public static ObjectToJsonTransformer toJson(@Nullable JsonObjectMapper<?, ?> jsonObjectMapper, @Nullable ObjectToJsonTransformer.ResultType resultType, @Nullable String contentType) -
fromJson
-
fromJson
-
fromJson
Construct aJsonToObjectTransformer
based on the providedResolvableType
.- Parameters:
targetType
- theResolvableType
top use.- Returns:
- the
JsonToObjectTransformer
instance. - Since:
- 5.2
-
fromJson
-
fromJson
public static JsonToObjectTransformer fromJson(@Nullable Class<?> targetClass, @Nullable JsonObjectMapper<?, ?> jsonObjectMapper) -
fromJson
public static JsonToObjectTransformer fromJson(ResolvableType targetType, @Nullable JsonObjectMapper<?, ?> jsonObjectMapper) - Parameters:
targetType
- theResolvableType
top use.jsonObjectMapper
- theJsonObjectMapper
top use.- Returns:
- the
JsonToObjectTransformer
instance. - Since:
- 5.2
-
serializer
-
serializer
-
deserializer
-
deserializer
public static PayloadDeserializingTransformer deserializer(@Nullable Deserializer<Object> deserializer, String... allowedPatterns) -
converter
-
syslogToMap
-
encoding
The factory method for theEncodingPayloadTransformer
.- Type Parameters:
T
- thepayload
type.- Parameters:
codec
- theCodec
to use.- Returns:
- the
EncodingPayloadTransformer
instance.
-
decoding
The factory method for theDecodingTransformer
.- Type Parameters:
T
- the target type.- Parameters:
codec
- theCodec
to use.type
- the target type to transform to.- Returns:
- the
DecodingTransformer
instance.
-
decoding
The factory method for theDecodingTransformer
.- Type Parameters:
T
- the target type.- Parameters:
codec
- theCodec
to use.typeExpression
- the target type SpEL expression.- Returns:
- the
DecodingTransformer
instance.
-
decoding
public static <T> DecodingTransformer<T> decoding(Codec codec, Function<Message<?>, Class<T>> typeFunction) The factory method for theDecodingTransformer
.- Type Parameters:
T
- the target type.- Parameters:
codec
- theCodec
to use.typeFunction
- the target type function.- Returns:
- the
DecodingTransformer
instance.
-
decoding
The factory method for theDecodingTransformer
.- Type Parameters:
T
- the target type.- Parameters:
codec
- theCodec
to use.typeExpression
- the target type SpEL expression.- Returns:
- the
DecodingTransformer
instance.
-
fromStream
The factory method for theStreamTransformer
.- Returns:
- the
StreamTransformer
instance.
-
fromStream
Create an instance with the charset to convert the stream to a String; if null abyte[]
will be produced instead.- Parameters:
charset
- the charset.- Returns:
- the
StreamTransformer
instance.
-