
com.glassdoor.planout4j.Experiment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of planout4j-core Show documentation
Show all versions of planout4j-core Show documentation
PlanOut for Java core infrastructure (mostly ported from original PlanOut)
The newest version!
package com.glassdoor.planout4j;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
import static com.google.common.base.Preconditions.*;
/**
* Represents an instance of an experiment.
* An experiment has unique (within its namespace) name, reference to experiment definition,
* and collection of segments allocated to it.
* @author ernest.mishkin
*/
public class Experiment {
public final String name;
public final String salt;
public final ExperimentConfig def;
public final Collection usedSegments;
public Experiment(final String name, final String salt, final ExperimentConfig def, final Collection usedSegments) {
checkArgument(StringUtils.isNotEmpty(name));
this.name = name;
checkArgument(StringUtils.isNotEmpty(salt));
this.salt = salt;
checkArgument(def != null);
this.def = def;
// usedSegments param can be null or empty for default experiment
this.usedSegments = usedSegments == null ? Collections.emptySet() : usedSegments;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(final Object obj) {
return obj == this || obj instanceof Experiment && name.equals(((Experiment)obj).name);
}
@Override
public String toString() {
return String.format("exp{%s, %s, %s}", name, usedSegments.size(), def);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy