camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: using enums...
Date Mon, 01 Aug 2011 14:31:29 GMT
Hi

You should be able to use

marshal(jacksonDataFormat)

To use the data format you have configured.


On Mon, Aug 1, 2011 at 3:45 PM, nizhnegorskiy <nizhnegorskiy@mail.ru> wrote:
> Hi,
>
> Can you tell me please, how do I use enum with Camel?
> F.e. I have something like this:
> public class Profile{
>        public ArrayList<Days> daypart_targets;
>
>        public enum Days {
>                MONDAY("monday"),
>                TUESDAY("tuesday");
>
>                private Days(String name) {
>                        this.name = name;
>                }
>
>                private final String name;
>
>                @Override
>                public String toString() {
>                        return name;
>                }
>        }
> }
> //...............
>                context.addRoutes(new RouteBuilder() {
>                        public void configure() {
>                                JacksonDataFormat jacksonDataFormat =
new JacksonDataFormat();
>                                ObjectMapper objectMapper = jacksonDataFormat.getObjectMapper();
>
> objectMapper.getDeserializationConfig().set(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,
> true);
>
>
>                                from("direct:testProfile")
>                                .marshal().json(JsonLibrary.Jackson)
>                                .to("file:///home/kirill/tmp")
>                                ;
>                }
>
> // ...............
>                p.daypart_targets = new ArrayList<Profile.Days>();
>                p.daypart_targets.add(Profile.Days.MONDAY);
>                p.daypart_targets.add(Profile.Days.TUESDAY);
>                pt.requestBody("direct:testProfile", p);
> How do I use this jacksonDataFormat? Is this the right way? Thanks in
> advance!
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-enums-tp4655056p4655056.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message