type conversion: address review comments

Fix supports check on FromMessageConverter: make sure the targetType is on the LHS

Fix PojoToStringMessageConverter: handle message payload tuple separately so that the tupleToString converter is set
This commit is contained in:
Ilayaperumal Gopinathan
2015-09-28 18:00:01 -07:00
committed by Mark Fisher
parent 9a865a56d7
commit 1a1ebe7b78
18 changed files with 74 additions and 170 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +20,15 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.integration.transformer.AbstractPayloadTransformer;
import org.springframework.cloud.stream.tuple.Tuple;
import org.springframework.cloud.stream.tuple.TupleBuilder;
import org.springframework.integration.transformer.AbstractPayloadTransformer;
/**
* Converts from a Map to the Tuple data structure.
*
* @author Mark Pollack
* @author Ilayaperumal Gopinathan
*/
public class MapToTupleTransformer extends AbstractPayloadTransformer<Map<Object, Object>, Tuple> {
@@ -36,11 +37,9 @@ public class MapToTupleTransformer extends AbstractPayloadTransformer<Map<Object
List<String> newNames = new ArrayList<String>();
List<Object> newValues = new ArrayList<Object>();
for (Object name : map.keySet()) {
newNames.add(name.toString());
}
for (Object value : map.values()) {
newValues.add(value);
for (Map.Entry<Object, Object> entry: map.entrySet()) {
newNames.add(entry.getKey().toString());
newValues.add(entry.getValue());
}
return TupleBuilder.tuple().ofNamesAndValues(newNames, newValues);

View File

@@ -13,11 +13,12 @@
* limitations under the License.
*/
package org.springframework.cloud.stream.tuple.kryo;
package org.springframework.cloud.stream.tuple.integration;
import java.util.ArrayList;
import java.util.List;
import org.springframework.cloud.stream.tuple.kryo.DefaultTupleSerializer;
import org.springframework.integration.codec.kryo.AbstractKryoRegistrar;
import org.springframework.integration.codec.kryo.KryoRegistrar;
import org.springframework.cloud.stream.tuple.DefaultTuple;
@@ -26,16 +27,15 @@ import com.esotericsoftware.kryo.Registration;
import com.esotericsoftware.kryo.serializers.CollectionSerializer;
/**
* A {@link KryoRegistrar}
* used to register a Tuple serializer.
* A {@link KryoRegistrar} used to register a Tuple serializer.
*
* @author David Turanski
* @since 1.2
*/
public class TupleKryoRegistrar extends AbstractKryoRegistrar {
private final static int TUPLE_REGISTRATION_ID = 41;
private final static int TUPLE_REGISTRATION_ID = 43;
private final static int ARRAY_LIST_REGISTRATION_ID = 42;
private final static int ARRAY_LIST_REGISTRATION_ID = 44;
private final DefaultTupleSerializer defaultTupleSerializer = new DefaultTupleSerializer();

View File

@@ -1,5 +1,5 @@
/**
* Contains classes that supports tuple integration such as tuple transformers etc.,
* Contains classes that support tuple integration such as tuple transformers.
*/
package org.springframework.cloud.stream.tuple.integration;

View File

@@ -18,17 +18,16 @@ package org.springframework.cloud.stream.tuple.kryo;
import java.util.ArrayList;
import java.util.List;
import org.springframework.cloud.stream.tuple.Tuple;
import org.springframework.cloud.stream.tuple.TupleBuilder;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.springframework.cloud.stream.tuple.Tuple;
import org.springframework.cloud.stream.tuple.TupleBuilder;
/**
* Deserializes Tuples by writing the field names and then the values as class/object pairs
* followed by the tuple Id and timestamp.
* Serializes Tuples by writing the field names and then the values as class/object pairs.
*
* @author David Turanski
*/