Modifier and Type | Method and Description |
---|---|
default <T> T |
get(Class<T> type)
Retrieve a service/resource by key.
|
default <T> T |
get(ServiceKey<T> key)
Retrieve a service/resource by key.
|
default <T> T |
getOrNull(Class<T> type)
Retrieve an existing service or
null if not exists. |
<T> T |
getOrNull(ServiceKey<T> key)
Retrieve an existing service or
null if not exists. |
Set<ServiceKey<?>> |
keySet()
Registered service keys.
|
default <T> T |
put(Class<T> type,
T service)
Put a service in this registry.
|
<T> T |
put(ServiceKey<T> key,
T service)
Put a service in this registry.
|
default <T> T |
putIfAbsent(Class<T> type,
T service)
Put/register a service in this registry if there isn't the same service already registered.
|
<T> T |
putIfAbsent(ServiceKey<T> key,
T service)
Put/register a service in this registry if there isn't the same service already registered.
|
default <T> T |
require(Class<T> type)
Provides an instance of the given type.
|
default <T> T |
require(Class<T> type,
String name)
Provides an instance of the given type where name matches it.
|
@Nonnull Set<ServiceKey<?>> keySet()
@Nonnull default <T> T get(@Nonnull ServiceKey<T> key)
T
- Service/resource type.key
- Service/resource key.RegistryException
- If there was a runtime failure while providing an instance.@Nonnull default <T> T get(@Nonnull Class<T> type)
T
- Service/resource type.type
- Service/resource key.RegistryException
- If there was a runtime failure while providing an instance.@Nullable <T> T getOrNull(@Nonnull ServiceKey<T> key)
null
if not exists.T
- Service/resource type.key
- Service/resource key.null
.@Nullable default <T> T getOrNull(@Nonnull Class<T> type)
null
if not exists.T
- Service/resource type.type
- Service/resource key.null
.@Nullable <T> T put(@Nonnull ServiceKey<T> key, T service)
T
- Service type.key
- Service/resource key.service
- Service instance.null
.@Nullable default <T> T put(@Nonnull Class<T> type, T service)
T
- Service type.type
- Service/resource key.service
- Service instance.null
.@Nullable <T> T putIfAbsent(@Nonnull ServiceKey<T> key, T service)
T
- Service type.key
- Service/resource key.service
- Service instance.null
.@Nullable default <T> T putIfAbsent(@Nonnull Class<T> type, T service)
T
- Service type.type
- Service/resource key.service
- Service instance.null
.@Nonnull default <T> T require(@Nonnull Class<T> type)
Registry
Copyright © 2019. All rights reserved.