AbstractLocation extends AbstractBrooklynObject implements LocationInternal, HasHostGeoInfo, Configurable { @SuppressWarnings("serial") @Override @Deprecated public AbstractLocation configure(Map<?,?> properties) { assertNotYetManaged(); boolean firstTime = !configured.getAndSet(true); config().putAll(properties); if (properties.containsKey(PARENT_LOCATION.getName())) { setParent(config().get(PARENT_LOCATION)); config().removeKey(PARENT_LOCATION); } properties = ConfigUtilsInternal.setAllConfigKeys(properties, getLocationTypeInternal().getConfigKeys().values(), this); ConfigBag configBag = ConfigBag.newInstance(properties); FlagUtils.setFieldsFromFlagsWithBag(this, properties, configBag, firstTime); FlagUtils.setAllConfigKeys(this, configBag, false); if (properties.containsKey("displayName")) { name.set((String) removeIfPossible(properties, "displayName")); displayNameAutoGenerated = false; } else if (properties.containsKey("name")) { name.set((String) removeIfPossible(properties, "name")); displayNameAutoGenerated = false; } else if (isLegacyConstruction()) { name.set(getClass().getSimpleName()+":"+getId().substring(0, Math.min(getId().length(),4))); displayNameAutoGenerated = true; } if (groovyTruth(properties.get("iso3166"))) { Object rawCodes = removeIfPossible(properties, "iso3166"); Set<String> codes; if (rawCodes instanceof CharSequence) { codes = ImmutableSet.copyOf(Splitter.on(",").trimResults().split((CharSequence)rawCodes)); } else { codes = TypeCoercions.coerce(rawCodes, new TypeToken<Set<String>>() {}); } config().set(LocationConfigKeys.ISO_3166, codes); } return this; } AbstractLocation();  AbstractLocation(Map<?,?> properties); @Override void setManagementContext(ManagementContextInternal managementContext); @SuppressWarnings("serial") @Override @Deprecated AbstractLocation configure(Map<?,?> properties); boolean isManaged(); void onManagementStarted(); void onManagementStopped(); @Override String getDisplayName(); @Override Location getParent(); @Override Collection<Location> getChildren(); @Override void setParent(Location newParent); void setParent(Location newParent, boolean updateChildListParents); @Override ConfigurationSupportInternal config(); @Override @Beta BasicSubscriptionSupport subscriptions(); @Override T getConfig(HasConfigKey<T> key); @Override T getConfig(ConfigKey<T> key); @Override void setDisplayName(String newName); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean containsLocation(Location potentialDescendent); @SuppressWarnings("deprecation") void addChild(Location child); boolean removeChild(Location child); @Override void init(); @Override void rebind(); @Override String toString(); @Override String toVerboseString(); @Override HostGeoInfo getHostGeoInfo(); void setHostGeoInfo(HostGeoInfo hostGeoInfo); @Override RebindSupport<LocationMemento> getRebindSupport(); LocationDynamicType getLocationTypeInternal(); @SuppressWarnings("unchecked") @Override RelationSupportInternal<Location> relations(); @Override boolean hasExtension(Class<?> extensionType); @Override @SuppressWarnings("unchecked") T getExtension(Class<T> extensionType); @Override void addExtension(Class<T> extensionType, T extension); @Override Map<String, String> toMetadataRecord(); static final ConfigKey<Location> PARENT_LOCATION; static final ConfigKey<Boolean> TEMPORARY_LOCATION; }
@Test public void testEqualsUsesId() { Location l1 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class) .configure("overriddenId", "id1") .configure("myfield", "bob")); Location l1b = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class) .configure("overriddenId", "id1") .configure("myfield", "frank")); Location l2 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class) .configure("overriddenId", "id2") .configure("myfield", "bob")); assertEquals(l1, l1b); assertNotEquals(l1, l2); }