@Override public AbstractEntity configure(Map flags) { this.configureProperties = flags; configureCount++; return super.configure(flags); }
@Override public AbstractEntity configure(Map flags) { configureCount++; return super.configure(flags); }
/** * @deprecated since 0.5; instead use no-arg constructor with EntityManager().createEntity(spec) */ @Deprecated public AbstractEntity(@SuppressWarnings("rawtypes") Map flags, Entity parent) { super(checkConstructorFlags(flags, parent)); // TODO Don't let `this` reference escape during construction entityType = new EntityDynamicType(this); if (isLegacyConstruction()) { AbstractEntity checkWeGetThis = configure(flags); assert this.equals(checkWeGetThis) : this+" configure method does not return itself; returns "+checkWeGetThis+" instead of "+this; boolean deferConstructionChecks = (flags.containsKey("deferConstructionChecks") && TypeCoercions.coerce(flags.get("deferConstructionChecks"), Boolean.class)); if (!deferConstructionChecks) { FlagUtils.checkRequiredFields(this); } } }
@Test public void testAddConfigKeyThroughEntity() throws Exception{ Entities.deproxy(entity).configure(ImmutableList.<ConfigKey<?>>of(NEW_CONFIG)); assertEquals(entity.getEntityType().getConfigKeys(), ImmutableSet.builder().addAll(DEFAULT_CONFIG_KEYS).add(NEW_CONFIG).build()); assertEventuallyListenerEventsEqual(ImmutableList.of(BasicSensorEvent.ofUnchecked(AbstractEntity.CONFIG_KEY_ADDED, entity, NEW_CONFIG))); }
addSpecParameters(spec, theEntity.getMutableEntityType()); theEntity.configure(MutableMap.copyOf(spec.getFlags())); for (Map.Entry<ConfigKey<?>, Object> entry : spec.getConfig().entrySet()) { entity.config().set((ConfigKey)entry.getKey(), entry.getValue());