public class ComponentMap extends java.util.HashMap<java.lang.Class<? extends Component>,Component>
| Modifier and Type | Field and Description |
|---|---|
ComponentProvider<?> |
provider |
| Constructor and Description |
|---|
ComponentMap(ComponentProvider<?> provider) |
| Modifier and Type | Method and Description |
|---|---|
<C extends Component> |
add(C component)
Adds a component to the provider.
|
<C extends Component> |
add(java.lang.Class<C> componentType)
Adds a new component based on its superclass or interface using dependency injection.
|
<C> C |
get(java.lang.Class<C> componentType)
Gets the component with the specified type.
|
<C> java.util.Optional<C> |
getOp(java.lang.Class<C> componentType)
Gets an optional of the component with the specified type.
|
<C extends Component> |
getOrAdd(C component)
Adds a component to the block if it is not present.
|
<C> java.util.Set<C> |
getSet(java.lang.Class<C> componentType)
Gets the set of the components with the specified type.
|
boolean |
has(java.lang.Class<?> componentType)
Checks if a component type exists in this provider.
|
<C extends Component> |
remove(C component)
Removes a component from the block.
|
<C extends Component> |
remove(java.lang.Class<C> componentType)
Removes the component from the provider.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic final ComponentProvider<?> provider
public ComponentMap(ComponentProvider<?> provider)
public final <C extends Component> C add(java.lang.Class<C> componentType)
C - The component type.componentType - The interface or abstract class associated with the new component.public final <C extends Component> C add(C component)
C - The component type.component - The component to add.ComponentException - when the component already exists on the block.public final <C extends Component> C getOrAdd(C component)
C - The component type.component - The component to add.public final boolean has(java.lang.Class<?> componentType)
componentType - the component type to check.public final <C extends Component> C remove(C component)
C - The component type.component - The component to remove.ComponentException - when the component does not exist.public final <C extends Component> C remove(java.lang.Class<C> componentType)
C - The component type.componentType - the component type.ComponentException - when the component does not exist.public final <C> java.util.Optional<C> getOp(java.lang.Class<C> componentType)
C - The component type.componentType - the type to get.Optional.empty().
if the component was not found.public final <C> C get(java.lang.Class<C> componentType)
C - The component type.componentType - the type to get.ComponentException - if the component doesn't exist.public final <C> java.util.Set<C> getSet(java.lang.Class<C> componentType)
C - The component type.componentType - the type to get.