private static void toSlime(Application application,
                                Cluster cluster,
                                NodeList applicationNodes,
                                NodeRepository nodeRepository,
                                Cursor clustersObject) {
        NodeList nodes = applicationNodes.not().retired().cluster(cluster.id());
        if (nodes.isEmpty()) return;
        ClusterResources currentResources = nodes.toResources();
        Cursor clusterObject = clustersObject.setObject(cluster.id().value());
        clusterObject.setString("type", nodes.clusterSpec().type().name());
        Limits limits = Limits.of(cluster).fullySpecified(nodes.clusterSpec(), nodeRepository, application.id());
        toSlime(limits.min(), clusterObject.setObject("min"));
        toSlime(limits.max(), clusterObject.setObject("max"));
        if ( ! cluster.groupSize().isEmpty())
            toSlime(cluster.groupSize(), clusterObject.setObject("groupSize"));
        toSlime(currentResources, clusterObject.setObject("current"));
        if (cluster.shouldSuggestResources(currentResources)) {
            toSlime(cluster.suggestions(), clusterObject.setArray("suggestions"));
        }
        toSlime(cluster.target(), clusterObject.setObject("target"));
        scalingEventsToSlime(cluster.scalingEvents(), clusterObject.setArray("scalingEvents"));
        clusterObject.setLong("scalingDuration", cluster.scalingDuration().toMillis());
    }
Serializes application information for nodes/v2/application responses

@author bratseth
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationSerializer.java