/* * Recursive descent into subclusters. */ private static void flatten(ArrayList<Cluster> flattened, Collection<Cluster> clusters) { for (Cluster c : clusters) { flattened.add(c); final List<Cluster> subclusters = c.getSubclusters(); if (!subclusters.isEmpty()) { flatten(flattened, subclusters); } } }
/** For JSON serialization only. */ @JsonProperty("clusters") @SuppressWarnings("unused") private List<Cluster> getSubclustersForSerialization() { return subclustersView.isEmpty() ? null : subclustersView; }