public class EntityToMultiDeviceIdIndex extends DeviceIndex
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentHashMap<IndexedEntity,java.util.Collection<java.lang.Long>> |
index
The index
|
keyFields
Constructor and Description |
---|
EntityToMultiDeviceIdIndex(java.util.EnumSet<IDeviceService.DeviceField> keyFields)
Construct a new device index using the provided key fields.
|
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<java.lang.Long> |
getAll()
Gets all device keys in the index.
|
java.util.Iterator<java.lang.Long> |
queryByEntity(Entity entity)
Finds all device keys in the index that match the given entity
on all the key fields for this index.
|
void |
removeEntity(Entity entity)
Removes the entry for the given entity.
|
void |
removeEntity(Entity entity,
java.lang.Long deviceKey)
Removes the given device key from the index for the given entity.
|
boolean |
updateIndex(Device device,
java.lang.Long deviceKey)
Attempts to update an index with the entities in the provided
Device . |
void |
updateIndex(Entity entity,
java.lang.Long deviceKey)
Adds a mapping from the given entity to the given device key.
|
removeEntityIfNeeded
private java.util.concurrent.ConcurrentHashMap<IndexedEntity,java.util.Collection<java.lang.Long>> index
public EntityToMultiDeviceIdIndex(java.util.EnumSet<IDeviceService.DeviceField> keyFields)
keyFields
- public java.util.Iterator<java.lang.Long> queryByEntity(Entity entity)
DeviceIndex
queryByEntity
in class DeviceIndex
entity
- the entity to search forpublic java.util.Iterator<java.lang.Long> getAll()
DeviceIndex
getAll
in class DeviceIndex
public boolean updateIndex(Device device, java.lang.Long deviceKey)
DeviceIndex
Device
. If the update fails because of a concurrent update,
will return false.updateIndex
in class DeviceIndex
device
- the device to updatedeviceKey
- the device key for the devicepublic void updateIndex(Entity entity, java.lang.Long deviceKey)
DeviceIndex
updateIndex
in class DeviceIndex
entity
- the entity to updatedeviceKey
- the device key for the devicepublic void removeEntity(Entity entity)
DeviceIndex
removeEntity
in class DeviceIndex
entity
- the entity to removepublic void removeEntity(Entity entity, java.lang.Long deviceKey)
DeviceIndex
removeEntity
in class DeviceIndex
entity
- the entity to search fordeviceKey
- the key to remove