com.barchart.ondemand.api.responses.IndexMembers Maven / Gradle / Ivy
package com.barchart.ondemand.api.responses;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
public class IndexMembers extends ResponseBase {
@JsonProperty("results")
private final List results = new ArrayList();
private final Map> indexMap = new HashMap>();
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
}
public Collection all() {
return Collections.unmodifiableCollection(results);
}
public Collection byMember(String index) {
if (indexMap.containsKey(index)) {
return Collections.unmodifiableCollection(indexMap.get(index));
}
final List results = new ArrayList();
for (IndexMember m : this.results) {
if (m.getIndex().equalsIgnoreCase(index)) {
results.add(m);
}
}
indexMap.put(index, results);
return results;
}
}