Class ObjectToMapTransformer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.transformer.AbstractTransformer
org.springframework.integration.transformer.AbstractPayloadTransformer<Object,Map<?,?>>
  
org.springframework.integration.transformer.ObjectToMapTransformer
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ComponentSourceAware,- ExpressionCapable,- GenericTransformer<Message<?>,,- Message<?>> - NamedComponent,- Transformer
Transforms an object graph into a Map. It supports a conventional Map (map of maps)
 where complex attributes are represented as Map values as well as a flat Map
 where keys document the path to the value. By default it will transform to a flat Map.
 If you need to transform to a Map of Maps set the 'shouldFlattenKeys' property to 'false'
 via the 
setShouldFlattenKeys(boolean) method.
 It supports Collections, Maps and Arrays which means that for flat maps it will flatten
 an Object's properties. Below is an example showing how a flattened
 Object hierarchy is represented when 'shouldFlattenKeys' is TRUE.
 The transformation is based on to and then from JSON conversion.
 
 public class Person {
     public String name = "John";
     public Address address = new Address();
 }
 public class Address {
     private String street = "123 Main Street";
 }
 
 The resulting Map would look like this:
 
 {name=John, address.street=123 Main Street}
 
- Since:
- 2.0
- Author:
- Oleg Zhurakousky, Artem Bilan, Gary Russell, Vikas Prasad
- See Also:
- 
Field SummaryFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct with the defaultJsonObjectMapperinstance available viafactory.ObjectToMapTransformer(JsonObjectMapper<?, ?> jsonObjectMapper) Construct with the providedJsonObjectMapperinstance.
- 
Method SummaryModifier and TypeMethodDescriptionSubclasses may implement this method to provide component type information.voidsetShouldFlattenKeys(boolean shouldFlattenKeys) transformPayload(Object payload) Methods inherited from class org.springframework.integration.transformer.AbstractPayloadTransformerdoTransformMethods inherited from class org.springframework.integration.transformer.AbstractTransformertransformMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
- 
Constructor Details- 
ObjectToMapTransformerpublic ObjectToMapTransformer()Construct with the defaultJsonObjectMapperinstance available viafactory.
- 
ObjectToMapTransformerConstruct with the providedJsonObjectMapperinstance.- Parameters:
- jsonObjectMapper- the- JsonObjectMapperto use.
- Since:
- 5.0
 
 
- 
- 
Method Details- 
setShouldFlattenKeyspublic void setShouldFlattenKeys(boolean shouldFlattenKeys) 
- 
transformPayload- Specified by:
- transformPayloadin class- AbstractPayloadTransformer<Object,- Map<?, - ?>> 
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
 
-