Class DynamicSet<T>
java.lang.Object
com.google.gerrit.extensions.registration.DynamicSet<T>
- All Implemented Interfaces:
Iterable<T>
A set of members that can be modified as plugins reload.
DynamicSets are always mapped as singletons in Guice. Sets store Providers internally, and resolve the provider to an instance on demand. This enables registrations to decide between singleton and non-singleton members.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd one new element that may be hot-replaceable in the future.Add one new element to the set.Add one new element to the set.static <T> com.google.inject.binder.LinkedBindingBuilder<T>
bind
(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> type) Bind one implementation into the set using a unique annotation.static <T> com.google.inject.binder.LinkedBindingBuilder<T>
bind
(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> type, com.google.inject.name.Named name) Bind a named implementation into the set.static <T> com.google.inject.binder.LinkedBindingBuilder<T>
Bind one implementation into the set using a unique annotation.static <T> com.google.inject.binder.LinkedBindingBuilder<T>
Bind a named implementation into the set.ImmutableSet<com.google.inject.Provider<T>>
Get the items exported by a single plugin.boolean
Returnstrue
if this set contains the given item.static <T> DynamicSet<T>
emptySet()
entries()
iterator()
plugins()
Get the names of all running plugins supplying this type.static <T> void
setOf
(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> member) Declare a singletonDynamicSet<T>
with a binder.static <T> void
Declare a singletonDynamicSet<T>
with a binder.stream()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DynamicSet
public DynamicSet()
-
-
Method Details
-
setOf
Declare a singletonDynamicSet<T>
with a binder.Sets must be defined in a Guice module before they can be bound:
DynamicSet.setOf(binder(), Interface.class); DynamicSet.bind(binder(), Interface.class).to(Impl.class);
- Parameters:
binder
- a new binder created in the module.member
- type of entry in the set.
-
setOf
public static <T> void setOf(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> member) Declare a singletonDynamicSet<T>
with a binder.Sets must be defined in a Guice module before they can be bound:
DynamicSet.setOf(binder(), new TypeLiteral<Thing<Foo>>() {});
- Parameters:
binder
- a new binder created in the module.member
- type of entry in the set.
-
bind
public static <T> com.google.inject.binder.LinkedBindingBuilder<T> bind(com.google.inject.Binder binder, Class<T> type) Bind one implementation into the set using a unique annotation.- Parameters:
binder
- a new binder created in the module.type
- type of entries in the set.- Returns:
- a binder to continue configuring the new set member.
-
bind
public static <T> com.google.inject.binder.LinkedBindingBuilder<T> bind(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> type) Bind one implementation into the set using a unique annotation.- Parameters:
binder
- a new binder created in the module.type
- type of entries in the set.- Returns:
- a binder to continue configuring the new set member.
-
bind
public static <T> com.google.inject.binder.LinkedBindingBuilder<T> bind(com.google.inject.Binder binder, Class<T> type, com.google.inject.name.Named name) Bind a named implementation into the set.- Parameters:
binder
- a new binder created in the module.type
- type of entries in the set.name
-@Named
annotation to apply instead of a unique annotation.- Returns:
- a binder to continue configuring the new set member.
-
bind
public static <T> com.google.inject.binder.LinkedBindingBuilder<T> bind(com.google.inject.Binder binder, com.google.inject.TypeLiteral<T> type, com.google.inject.name.Named name) Bind a named implementation into the set.- Parameters:
binder
- a new binder created in the module.type
- type of entries in the set.name
-@Named
annotation to apply instead of a unique annotation.- Returns:
- a binder to continue configuring the new set member.
-
emptySet
-
iterator
-
entries
-
contains
Returnstrue
if this set contains the given item.- Parameters:
item
- item to check whether or not it is contained.- Returns:
true
if this set contains the given item.
-
plugins
Get the names of all running plugins supplying this type.- Returns:
- sorted set of active plugins that supply at least one item.
-
byPlugin
Get the items exported by a single plugin.- Parameters:
pluginName
- name of the plugin.- Returns:
- items exported by a plugin.
-
add
Add one new element to the set.- Parameters:
item
- the item to add to the collection. Must not be null.- Returns:
- handle to remove the item at a later point in time.
-
add
Add one new element to the set.- Parameters:
item
- the item to add to the collection. Must not be null.- Returns:
- handle to remove the item at a later point in time.
-
add
public ReloadableRegistrationHandle<T> add(String pluginName, com.google.inject.Key<T> key, com.google.inject.Provider<T> item) Add one new element that may be hot-replaceable in the future.- Parameters:
pluginName
- unique name of the plugin providing the item.key
- unique description from the item's Guice binding. This can be later obtained from the registration handle to facilitate matching with the new equivalent instance during a hot reload.item
- the item to add to the collection right now. Must not be null.- Returns:
- a handle that can remove this item later, or hot-swap the item without it ever leaving the collection.
-
stream
-