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

com.absmartly.sdk.ContextConfig Maven / Gradle / Ivy

The newest version!
package com.absmartly.sdk;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Nonnull;

public class ContextConfig {
	public static ContextConfig create() {
		return new ContextConfig();
	}

	private ContextConfig() {}

	public ContextConfig setUnit(@Nonnull final String unitType, @Nonnull final String uid) {
		if (units_ == null) {
			units_ = new HashMap();
		}

		units_.put(unitType, uid);
		return this;
	}

	public ContextConfig setUnits(@Nonnull final Map units) {
		for (final Map.Entry entry : units.entrySet()) {
			setUnit(entry.getKey(), entry.getValue());
		}
		return this;
	}

	public String getUnit(@Nonnull final String unitType) {
		return units_.get(unitType);
	}

	public Map getUnits() {
		return units_;
	}

	public ContextConfig setAttribute(@Nonnull final String name, @Nonnull final Object value) {
		if (attributes_ == null) {
			attributes_ = new HashMap();
		}
		attributes_.put(name, value);
		return this;
	}

	public ContextConfig setAttributes(@Nonnull final Map attributes) {
		if (attributes_ == null) {
			attributes_ = new HashMap(attributes.size());
		}
		attributes_.putAll(attributes);
		return this;
	}

	public Object getAttribute(@Nonnull final String name) {
		return this.attributes_.get(name);
	}

	public Map getAttributes() {
		return this.attributes_;
	}

	public ContextConfig setOverride(@Nonnull final String experimentName, int variant) {
		if (overrides_ == null) {
			overrides_ = new HashMap();
		}
		overrides_.put(experimentName, variant);
		return this;
	}

	public ContextConfig setOverrides(@Nonnull final Map overrides) {
		if (overrides_ == null) {
			overrides_ = new HashMap(overrides.size());
		}
		overrides_.putAll(overrides);
		return this;
	}

	public Object getOverride(@Nonnull final String experimentName) {
		return this.overrides_.get(experimentName);
	}

	public Map getOverrides() {
		return this.overrides_;
	}

	public ContextConfig setCustomAssignment(@Nonnull final String experimentName, int variant) {
		if (cassigmnents_ == null) {
			cassigmnents_ = new HashMap();
		}
		cassigmnents_.put(experimentName, variant);
		return this;
	}

	public ContextConfig setCustomAssignments(@Nonnull final Map customAssignments) {
		if (cassigmnents_ == null) {
			cassigmnents_ = new HashMap(customAssignments.size());
		}
		cassigmnents_.putAll(customAssignments);
		return this;
	}

	public Object getCustomAssignment(@Nonnull final String experimentName) {
		return this.cassigmnents_.get(experimentName);
	}

	public Map getCustomAssignments() {
		return this.cassigmnents_;
	}

	public ContextEventLogger getEventLogger() {
		return this.eventLogger_;
	}

	public ContextConfig setEventLogger(ContextEventLogger eventLogger) {
		this.eventLogger_ = eventLogger;
		return this;
	}

	public ContextConfig setPublishDelay(long delayMs) {
		this.publishDelay_ = delayMs;
		return this;
	}

	public long getPublishDelay() {
		return this.publishDelay_;
	}

	public ContextConfig setRefreshInterval(long intervalMs) {
		this.refreshInterval_ = intervalMs;
		return this;
	}

	public long getRefreshInterval() {
		return this.refreshInterval_;
	}

	private Map units_;
	private Map attributes_;
	private Map overrides_;
	private Map cassigmnents_;

	private ContextEventLogger eventLogger_;

	private long publishDelay_ = 100;
	private long refreshInterval_ = 0;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy