camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nizhnegorskiy <nizhnegors...@mail.ru>
Subject using enums...
Date Mon, 01 Aug 2011 13:45:51 GMT
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.

Mime
View raw message