19package denoptim.graph;
21import java.lang.reflect.Type;
22import java.util.HashSet;
23import java.util.LinkedHashMap;
24import java.util.Map.Entry;
26import java.util.TreeMap;
28import com.google.gson.JsonElement;
29import com.google.gson.JsonSerializationContext;
30import com.google.gson.JsonSerializer;
42public class APTreeMap extends LinkedHashMap<AttachmentPoint, AttachmentPoint>
59 JsonSerializationContext context)
61 TreeMap<Integer,AttachmentPoint> jsonableMap =
new TreeMap<>();
62 Set<Integer> foundIDs =
new HashSet<Integer>();
63 for (Entry<AttachmentPoint, AttachmentPoint> entry
66 int keyID = entry.getKey().getID();
67 if (foundIDs.contains(keyID))
68 throw new Error(
"Found diplicate AP ID for APs that are "
69 +
"expected to have unique IDs.");
70 jsonableMap.put(keyID, entry.getValue());
72 return context.serialize(jsonableMap);
81 return super.put(key, value);
89 return super.remove(key);
97 return super.get(key);
Method that serializes this class without creating loops of references.
JsonElement serialize(APTreeMap apmap, Type typeOfSrc, JsonSerializationContext context)
Attachment point mapping where keys are sorted by natural ordering, i.e., by AttachmentPoint#compareT...
static final long serialVersionUID
Version identifier.
AttachmentPoint put(AttachmentPoint key, AttachmentPoint value)
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....