org.mnode.ical4j.json.jot.JotAvailableSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ical4j-json Show documentation
Show all versions of ical4j-json Show documentation
Custom marshalling between iCal4j objects and JSON formats
The newest version!
package org.mnode.ical4j.json.jot;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import net.fortuna.ical4j.model.component.Available;
import java.io.IOException;
/**
* Convert iCal4j {@link Available} objects to Jot JSON format.
*/
public class JotAvailableSerializer extends StdSerializer {
public JotAvailableSerializer(Class t) {
super(t);
}
@Override
public void serialize(Available value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeTree(buildAvailable(value));
}
private JsonNode buildAvailable(Available available) {
AbstractJotBuilder builder = new ComponentBuilder().component(available);
return builder.build();
}
}