com.launchdarkly.client.files.DataBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of launchdarkly-client Show documentation
Show all versions of launchdarkly-client Show documentation
Official LaunchDarkly SDK for Java
package com.launchdarkly.client.files;
import com.launchdarkly.client.VersionedData;
import com.launchdarkly.client.VersionedDataKind;
import java.util.HashMap;
import java.util.Map;
/**
* Internal data structure that organizes flag/segment data into the format that the feature store
* expects. Will throw an exception if we try to add the same flag or segment key more than once.
*/
class DataBuilder {
private final Map, Map> allData = new HashMap<>();
public Map, Map> build() {
return allData;
}
public void add(VersionedDataKind> kind, VersionedData item) throws DataLoaderException {
@SuppressWarnings("unchecked")
Map items = (Map)allData.get(kind);
if (items == null) {
items = new HashMap();
allData.put(kind, items);
}
if (items.containsKey(item.getKey())) {
throw new DataLoaderException("in " + kind.getNamespace() + ", key \"" + item.getKey() + "\" was already defined", null, null);
}
items.put(item.getKey(), item);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy