public IdentityMetadata(String typeName, Class<? extends Identity> identityType, Class<? extends IdentityDto> dtoType, Class<? extends Mapper> mapperType) { this.typeName = typeName; this.identityType = identityType; this.dtoType = dtoType; this.mapperType = mapperType; this.attributes = Identity.getSupportedAttributes(identityType); }
/** * Returns all active treatments for all active experiments for an identity, taking overrides into account */ public Map<Experiment, Treatment> getActiveTreatments(Identity identity) { strategy.onCacheRead(context); final Map<Experiment, Treatment> result = Maps.newHashMap(); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); for (final Experiment experiment : cache.getActiveExperiments().values()) { if (!experiment.getFilter().evaluate(attributes)) { continue; } final Treatment treatment = getTreatmentWithOverrides(experiment, identity, attributes); if (treatment == null) { continue; } result.put(experiment, treatment); } return result; }
/** * Returns the current active treatment for an experiment name and identity, taking overrides into account */ public Treatment getActiveTreatment(String experimentName, Identity identity) { strategy.onCacheRead(experimentName, context); final Experiment experiment = cache.getActiveExperiments().get(experimentName); final AttributesMap attributes = identity .computeAttributes() .filter(Identity.getSupportedAttributes(identity.getClass())); if (experiment == null || !experiment.getFilter().evaluate(attributes)) { return null; } return getTreatmentWithOverrides(experiment, identity, attributes); }