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

com.launchdarkly.client.files.DataBuilder Maven / Gradle / Ivy

There is a newer version: 4.61
Show newest version
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