All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.thepathfinder.android.Route Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package xyz.thepathfinder.android;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author David Robinson
 */
class Route {

    private final Transport transport;
    private final List actions;

    protected Route(JsonObject routeJson, PathfinderServices services) {
        this.transport = Route.getTransport(routeJson, services);
        this.actions = Route.getActions(routeJson, services);
    }

    public Transport getTransport() {
        return this.transport;
    }

    public List getActions() {
        return this.actions;
    }

    private static Transport getTransport(JsonObject json, PathfinderServices services) {
        return Transport.getInstance(json.getAsJsonObject("model"), services);
    }

    private static List getActions(JsonObject json, PathfinderServices services) {
        JsonArray actions = json.getAsJsonArray("actions");
        List list = new ArrayList();

        for (JsonElement element : actions) {
            list.add(new Action(element.getAsJsonObject(), services));
        }

        return list;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy