import org.codehaus.jackson.map.module.SimpleModule;
public class IMetricSerializer {
public ObjectMapper getObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
SimpleModule metricModule = new SimpleModule("IMetricSerializerModule", new Version(1, 0, 0, null));
metricModule.setMixInAnnotation(IMetric.class, IMetricMixin.class);
metricModule.setMixInAnnotation(Locator.class, LocatorMixin.class);
metricModule.setMixInAnnotation(PreaggregatedMetric.class, PreaggMetricMixin.class);
metricModule.setMixInAnnotation(Rollup.class, RollupMixin.class);
metricModule.setMixInAnnotation(BasicRollup.class, BasicRollupMixin.class);
metricModule.setMixInAnnotation(AbstractRollupStat.class, AbstractRollupStatMixin.class);
metricModule.setMixInAnnotation(GaugeRollup.class, GaugeRollupMixin.class);
metricModule.setMixInAnnotation(TimerRollup.class, TimerRollupMixin.class);
metricModule.setMixInAnnotation(TimerRollup.Percentile.class, PercentileMixin.class);
metricModule.addSerializer(AbstractRollupStat.class, new AbstractRollupStatSerializer());
metricModule.addDeserializer(Metric.class, new MetricDeserializer());
metricModule.addDeserializer(GaugeRollup.class, new GaugeRollupDeserializer());
mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(metricModule);