protected Experiment(Experiments owner, String name) { this.owner = owner; this.name = name; this.filter = FilterExpression.alwaysTrue(); this.hashAttributes = EMPTY_SET; this.allocations = new Allocations(); this.treatments = Maps.newConcurrentMap(); this.overrides = Maps.newConcurrentMap(); this.seed = (int) IdentityBuilder.seed(0).putString(name).hash(); }
this.treatments = new ConcurrentHashMap<>(treatments); this.overrides = new ConcurrentHashMap<>(Maps.uniqueIndex(overrides, TREATMENT_INDEXER)); this.allocations = new Allocations(allocations); this.seed = seed;
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; }