com.eg.agent.android.harvest.HistoryTransformer Maven / Gradle / Ivy
The newest version!
package com.eg.agent.android.harvest;
import com.eg.agent.android.harvest.type.ArrayTransformer;
import com.eg.google.gson.JsonArray;
import com.eg.google.gson.JsonElement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class HistoryTransformer extends ArrayTransformer {
private final List activityHistory;
public HistoryTransformer(List activityHistory) {
this.activityHistory = activityHistory;
}
public int size() {
return this.activityHistory.size();
}
public JsonArray asJsonArray() {
JsonArray data = new JsonArray();
for (VisibilityTransformer sighting : this.activityHistory) {
data.add(sighting.asJsonArray());
}
return data;
}
public JsonArray asJsonArrayWithoutDuration() {
JsonArray data = new JsonArray();
for (VisibilityTransformer sighting : this.activityHistory) {
data.add(sighting.asJsonArrayWithoutDuration());
}
return data;
}
public static HistoryTransformer newFromJson(JsonArray jsonArray) {
List sightings = new ArrayList();
Iterator i$ = jsonArray.iterator();
while (i$.hasNext()) {
sightings.add(VisibilityTransformer.newFromJson(((JsonElement) i$.next()).getAsJsonArray()));
}
return new HistoryTransformer(sightings);
}
}