package com.linkedin.thirdeye.anomaly.views;

import com.linkedin.thirdeye.dashboard.views.TimeBucket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class AnomalyTimelinesView {
  List<TimeBucket> timeBuckets = new ArrayList<>();
  Map<String, String> summary = new HashMap<>();
  List<Double> currentValues = new ArrayList<>();
  List<Double> baselineValues = new ArrayList<>();

  public List<TimeBucket> getTimeBuckets() {
    return timeBuckets;
  }

  public void addTimeBuckets(TimeBucket timeBucket) {
    this.timeBuckets.add(timeBucket);
  }

  public Map<String, String> getSummary() {
    return summary;
  }

  public void addSummary(String key, String value) {
    this.summary.put(key, value);
  }

  public List<Double> getCurrentValues() {
    return currentValues;
  }

  public void addCurrentValues(Double currentValue) {
    this.currentValues.add(currentValue);
  }

  public List<Double> getBaselineValues() {
    return baselineValues;
  }

  public void addBaselineValues(Double baselineValue) {
    this.baselineValues.add(baselineValue);
  }
}

@@ -39,16 +39,75 @@
 views;%0A%0A
+import com.fasterxml.jackson.core.JsonProcessingException;%0A
 import c
@@ -155,16 +155,44 @@
 Bucket;%0A
+import java.io.IOException;%0A
 import j
@@ -286,45 +286,164 @@
 ap;%0A
-%0A%0Apublic class AnomalyTimelinesView %7B
+import com.fasterxml.jackson.databind.ObjectMapper;%0A%0A%0Apublic class AnomalyTimelinesView %7B%0A  private static ObjectMapper OBJECT_MAPPER = new ObjectMapper();%0A
 %0A  L
@@ -1328,11 +1328,1092 @@
 ue);%0A  %7D
+%0A%0A  /**%0A   * Convert current instance into JSON String using ObjectMapper%0A   *%0A   * NOTE, as long as the getter and setter is implemented, the ObjectMapper constructs the JSON String via%0A   * the getter and setter%0A   * @return%0A   *    The JSON String of current instance%0A   * @throws JsonProcessingException%0A   */%0A  public String toJsonString() throws JsonProcessingException %7B%0A    String jsonString = OBJECT_MAPPER.writeValueAsString(this);%0A%0A    return jsonString;%0A  %7D%0A%0A  /**%0A   * Given the JSON String of an AnomalyTimelinesView, return an instance of AnomalyTimelinesView%0A   *%0A   * NOTE, as long as the getter and setter is implemented, the ObjectMapper constructs the JSON String via%0A   * the getter and setter%0A   * @param jsonString%0A   *    The JSON String of an instance%0A   * @return%0A   *    An instance based on the given JSON String%0A   * @throws IOException%0A   */%0A  public static AnomalyTimelinesView fromJsonString(String jsonString) throws IOException %7B%0A    AnomalyTimelinesView view = OBJECT_MAPPER.readValue(jsonString, AnomalyTimelinesView.class);%0A    return view;%0A  %7D
 %0A%7D%0A

Implement parsing function from and to JSON String (#1272)