public final class AttributeMap
extends java.lang.Object
Map
of Entity
attribute values.Constructor and Description |
---|
AttributeMap(AbstractEntity entity)
Creates a new AttributeMap.
|
AttributeMap(AbstractEntity entity,
java.util.Map<java.util.Collection<java.lang.String>,java.lang.Object> storage)
Creates a new AttributeMap.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
asMap() |
java.util.Map<java.util.Collection<java.lang.String>,java.lang.Object> |
asRawMap() |
java.util.concurrent.locks.Lock |
getLockInternal()
Internal
Lock used when publishing values. |
<T> T |
getValue(AttributeSensor<T> sensor) |
java.lang.Object |
getValue(java.util.Collection<java.lang.String> path)
Deprecated.
since 1.0.0 becoming private; callers should only ever use
getValue(AttributeSensor) |
<T> T |
modify(AttributeSensor<T> attribute,
<any> modifier)
Where atomicity is desired, this method wraps an acquisition of
getLockInternal()
while applying the given Function . |
void |
remove(AttributeSensor<?> attribute)
Removes a sensor.
|
void |
remove(java.util.Collection<java.lang.String> path)
Deprecated.
since 1.0.0 becoming private; callers should only ever use
remove(AttributeSensor) |
<T> T |
update(AttributeSensor<T> attribute,
T newValue)
Sets a value and published it.
|
<T> T |
update(java.util.Collection<java.lang.String> path,
T newValue)
Deprecated.
since 1.0.0 becoming private; callers should only ever use
update(AttributeSensor, Object) |
<T> T |
updateInternalWithoutLockOrPublish(AttributeSensor<T> attribute,
T newValue) |
<T> T |
updateWithoutPublishing(AttributeSensor<T> attribute,
T newValue)
Deprecated.
since 1.0.0 this is becoming an internal method,
updateInternalWithoutLockOrPublish(AttributeSensor, Object) |
public AttributeMap(AbstractEntity entity)
entity
- the Entity this AttributeMap belongs to.java.lang.NullPointerException
- if entity is nullpublic AttributeMap(AbstractEntity entity, java.util.Map<java.util.Collection<java.lang.String>,java.lang.Object> storage)
entity
- the Entity this AttributeMap belongs to.storage
- the Map in which to store the values - should be concurrent or synchronized.java.lang.NullPointerException
- if entity is nullpublic java.util.concurrent.locks.Lock getLockInternal()
Lock
used when publishing values.
When needed -- and carefully -- callers can lock on this to ensure no values are changed by other
threads while they are active.
To prevent deadlock, Brooklyn code generally call this _before_ getting any lower-level
monitor (ie synchronized
) and before locking on any descendant entity.
In other words, this lock should generally *not* be acquired inside a synchronized
block
nor by the holder of a similar Lock
on an entity except self or ancestor,
unless a clear canonical order is set forth.
public java.util.Map<java.util.Collection<java.lang.String>,java.lang.Object> asRawMap()
public java.util.Map<java.lang.String,java.lang.Object> asMap()
@Deprecated public <T> T update(java.util.Collection<java.lang.String> path, T newValue)
update(AttributeSensor, Object)
path
- the path to the value.newValue
- the new valuejava.lang.IllegalArgumentException
- if path is null or emptypublic <T> T update(AttributeSensor<T> attribute, T newValue)
Constraints of getLockInternal()
apply, with lock-holder being the supplied Function
.
@Deprecated public <T> T updateWithoutPublishing(AttributeSensor<T> attribute, T newValue)
updateInternalWithoutLockOrPublish(AttributeSensor, Object)
public <T> T updateInternalWithoutLockOrPublish(AttributeSensor<T> attribute, T newValue)
public <T> T modify(AttributeSensor<T> attribute, <any> modifier)
getLockInternal()
while applying the given Function
.
Constraints of getLockInternal()
apply, with lock-holder being the supplied Function
.
public void remove(AttributeSensor<?> attribute)
getLockInternal()
is acquired,
and constraints on the caller described there apply to callers of this method.
The caller is responsible for any subsequent actions needed, including publishing
the removal of the sensor and triggering persistence. Caller may wish to
have the getLockInternal()
while doing that.
@Deprecated public void remove(java.util.Collection<java.lang.String> path)
remove(AttributeSensor)
@Deprecated public java.lang.Object getValue(java.util.Collection<java.lang.String> path)
getValue(AttributeSensor)
path
- the path of the value to getjava.lang.IllegalArgumentException
- path is null or empty.public <T> T getValue(AttributeSensor<T> sensor)