package de.kasoki.jfeedly.model;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;

public class Categories implements Iterable<Category> {
    private ArrayList<Category> categories;

    private Categories(ArrayList<Category> categories) {
        this.categories = categories;
    }

    public Iterator<Category> iterator() {
        return categories.iterator();
    }

    public int getNumberOfCategories() {
        return categories.size();
    }

    public static Categories fromJSONArray(JSONArray array) {
        ArrayList<Category> categories = new ArrayList<Category>();

        for(int i = 0; i < array.length(); i++) {
            JSONObject object = array.getJSONObject(i);

            categories.add(Category.fromJSONObject(object));
        }

        return new Categories(categories);
    }

}

@@ -504,32 +504,325 @@
 .size();%0A    %7D%0A%0A
+    public Category get(int index) %7B%0A        return categories.get(index);%0A    %7D%0A%0A    public Category getById(String id) %7B%0A        for(Category c : this.categories) %7B%0A            if(c.getCategoryId().equals(id)) %7B%0A                return c;%0A            %7D%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A
     public stati

add methods get and getById to Categories