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

com.barchart.ondemand.api.responses.IndexMembers Maven / Gradle / Ivy

The newest version!
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 : all()) {
			if (m.getIndex().equalsIgnoreCase(index)) {
				results.add(m);
			}
		}

		indexMap.put(index, results);

		return results;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy