/** * Add a treatment override for an identity * @param treatmentName The treatment an identity should receive * @param overrideName The name of the override * @param filter A filter expression that describes which attributes this override should apply for */ public Experiment addOverride(String overrideName, String treatmentName, String filter) { final FilterExpression filterExp = FilterExpression.of(filter); final TreatmentOverride override = new TreatmentOverride(overrideName, filterExp, treatment(treatmentName)); overrides.put(overrideName, override); return this; }
public Builder addOverride(String name, String filter, String treatmentName) { overrides.add(new TreatmentOverride(name, FilterExpression.of(filter), getTreatment(treatmentName))); return this; }
private Experiment(Experiment toCopy) { this.owner = toCopy.owner; this.name = toCopy.name; this.treatments = Maps.newConcurrentMap(); for (final Treatment treatment : toCopy.getTreatments()) { this.treatments.put(treatment.getName(), new Treatment(treatment.getName(), treatment.getDescription())); } final List<Allocation> allocations = Lists.newArrayList(); for (final Allocation allocation : toCopy.getAllocations()) { final Treatment treatment = this.treatments.get(allocation.getTreatment().getName()); allocations.add(new Allocation(treatment, allocation.getOffset(), allocation.getSize())); } this.allocations = new Allocations(allocations); this.overrides = Maps.newConcurrentMap(); for (final TreatmentOverride override : toCopy.getOverrides()) { final Treatment treatment = this.treatments.get(override.getTreatment().getName()); final TreatmentOverride newOverride = new TreatmentOverride(override.getName(), override.getFilter(), treatment); overrides.put(override.getName(), newOverride); } this.seed = toCopy.seed; this.description = toCopy.description; this.filter = toCopy.filter; this.hashAttributes = Sets.newLinkedHashSet(toCopy.getHashAttributes()); this.active = toCopy.active; this.created = toCopy.created; this.modified = toCopy.modified; this.activated = toCopy.activated; this.deactivated = toCopy.deactivated; }