@@ -0,0 +1,1546 @@
+package io.github.programminglife2016.pl1_2016.parser;%0A%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0A%0Aimport java.util.ArrayList;%0A%0A/**%0A * Represent segments as a list. Warning: the size of the SegmentList must be set beforehand.%0A */%0Apublic class SegmentList extends ArrayList%3CSegment%3E implements SegmentCollection %7B%0A    /**%0A     * Add a segment to the collection.%0A     *%0A     * @param id      id of the segment%0A     * @param segment the actual segment%0A     * @return the segment parameter%0A     */%0A    public Segment put(Integer id, Segment segment) %7B%0A        add(id, segment);%0A        return segment;%0A    %7D%0A%0A    /**%0A     * Get a segment by id.%0A     *%0A     * @param id id of the segment%0A     * @return segment%0A     */%0A    public Segment get(Object id) %7B%0A        if (id instanceof Integer) %7B%0A            return get((Integer) id);%0A        %7D else %7B%0A            throw new IllegalArgumentException(%22The index must be an integer%22);%0A        %7D%0A    %7D%0A%0A%0A    /**%0A     * Checks if the collection contains a particular key.%0A     *%0A     * @param id id%0A     * @return true if the collection contains an item with this id, otherwise false%0A     */%0A    public boolean containsKey(Object id) %7B%0A        return get(id) != null;%0A    %7D%0A%0A    /**%0A     * Convert the representation to JSON.%0A     *%0A     * @return JSON representation of this object.%0A     */%0A    public String toJson() %7B%0A        Gson gson = new GsonBuilder().registerTypeAdapter(Segment.class, new SegmentSerializer())%0A                .create();%0A        return gson.toJson(this);%0A    %7D%0A%7D%0A

Add a SegmentCollection in the form of a List