public abstract class ServiceRegistry<K,S> extends Object
ServiceRegistry
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
protected Map<K,S> |
services |
Modifier | Constructor and Description |
---|---|
protected |
ServiceRegistry(Class<S> serviceClass) |
Modifier and Type | Method and Description |
---|---|
Optional<S> |
add(S service)
Adds a service to the registry.
|
Optional<S> |
get(K key)
Gets the service for the specified key, if any.
|
Collection<S> |
getAll()
Gets all registered services.
|
protected abstract K |
getKey(S service)
Gets the key for the specified service.
|
Set<K> |
getKeys()
Gets the set of registered keys.
|
boolean |
has(K key)
Checks whether a service for the specified key is available.
|
void |
remove(S service)
Removes a service from the registry.
|
public Optional<S> add(S service)
getKey(Object)
) will be replaced with the new service.service
- The service that should be added to the registry.Optional.empty()
if there was no
such service.public void remove(S service)
service
- The service be removed from the registry.public Optional<S> get(K key)
key
- The key identifying which service to get.Optional.empty()
if no such service is avaiable.public boolean has(K key)
key
- The key identifying which service to search for.public Collection<S> getAll()
public Set<K> getKeys()
Copyright © 2015-2019 Eclipse Foundation. All Rights Reserved.