You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nizhnegorskiy <ni...@mail.ru> on 2011/08/01 15:45:51 UTC
using enums...
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.
Re: using enums...
Posted by Claus Ibsen <cl...@gmail.com>.
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 <ni...@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/