org.mnode.ical4j.json.jot.JotFreeBusySerializer 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.VFreeBusy;
import java.io.IOException;
/**
* Convert iCal4j {@link VFreeBusy} objects to Jot JSON format.
*
* NOTE: Conversion to jot is "lossy" in that child components are ignored. This is intentional as
* Jot JSON separates calendars and components into separate (not nested) JSON structures.
*/
public class JotFreeBusySerializer extends StdSerializer {
public JotFreeBusySerializer(Class t) {
super(t);
}
@Override
public void serialize(VFreeBusy value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeTree(buildFreebusy(value));
}
private JsonNode buildFreebusy(VFreeBusy freeBusy) {
AbstractJotBuilder builder = new ComponentBuilder().component(freeBusy);
return builder.build();
}
}