public AbstractLocation(Map properties) { configure(properties); boolean deferConstructionChecks = (properties.containsKey("deferConstructionChecks") && TypeCoercions.coerce(properties.get("deferConstructionChecks"), Boolean.class)); if (!deferConstructionChecks) { FlagUtils.checkRequiredFields(this); } }
/** * Construct a new instance of an AbstractLocation. * * <p>The properties map recognizes the following keys: * * <ul> * <li>name - a name for the location * <li>parentLocation - the parent {@link Location} * </ul> * * Other common properties (retrieved via get/findLocationProperty) include: * * <ul> * <li>latitude * <li>longitude * <li>displayName * <li>iso3166 - list of iso3166-2 code strings * <li>timeZone * <li>abbreviatedName * </ul> */ public AbstractLocation(Map properties) { inConstruction = true; _legacyConstruction = !InternalLocationFactory.FactoryConstructionTracker.isConstructing(); if (!_legacyConstruction && properties != null && !properties.isEmpty()) { LOG.warn( "Forcing use of deprecated old-style location construction for " + getClass().getName() + " because properties were specified (" + properties + ")"); _legacyConstruction = true; } // When one calls getConfig(key), we want to use the default value specified on *this* location // if it overrides the default config. The easiest way to look up all our config keys is to // reuse the code for Entity (and this will become identical when locations become first-class // entities). See {@link #getConfig(ConfigKey)} entityType = new EntityDynamicType((Class) getClass()); if (_legacyConstruction) { LOG.warn( "Deprecated use of old-style location construction for " + getClass().getName() + "; instead use LocationManager().createLocation(spec)"); if (LOG.isDebugEnabled()) LOG.debug( "Source of use of old-style location construction", new Throwable("Source of use of old-style location construction")); configure(properties); boolean deferConstructionChecks = (properties.containsKey("deferConstructionChecks") && TypeCoercions.coerce(properties.get("deferConstructionChecks"), Boolean.class)); if (!deferConstructionChecks) { FlagUtils.checkRequiredFields(this); } } inConstruction = false; }
/** @deprecated in 0.5.0, not used or exposed; use configure(Map) */ public final void configure() { configure(Maps.newLinkedHashMap()); }