22 package org.matsim.core.mobsim.qsim.components;
24 import java.lang.annotation.Annotation;
25 import java.util.Collections;
26 import java.util.HashSet;
27 import java.util.LinkedList;
28 import java.util.List;
31 import com.google.inject.Key;
32 import com.google.inject.name.Names;
44 private final List<Object>
components =
new LinkedList<>();
45 private final Set<Key<?>>
keys =
new HashSet<>();
54 components.add(annotation);
63 components.add(annotation);
67 if (keys.contains(componentKey)) {
68 throw new IllegalStateException(
keyToString(componentKey) +
" is already registered.");
70 keys.add(componentKey);
87 components.remove(annotation);
96 components.remove(annotation);
100 if (!keys.remove(componentKey)) {
101 throw new IllegalStateException(
keyToString(componentKey) +
" is not registered.");
130 return keys.contains(componentKey);
142 return "Annotation" + componentKey.getAnnotation() != null ?
143 " " + componentKey.getAnnotation() :
144 "Type " + componentKey.getAnnotationType();
161 return Collections.unmodifiableList(components);
String keyToString(Key<?> componentKey)
boolean hasComponent(Key<?> componentKey)
void addComponent(Class<? extends Annotation > annotation)
void removeNamedComponent(String name)
boolean hasNamedComponent(String name)
List< Object > getActiveComponents()
void addComponent(Annotation annotation)
void addComponent(Key<?> componentKey)
void addNamedComponent(String name)
void removeComponent(Class<? extends Annotation > annotation)
boolean hasComponent(Annotation annotation)
void removeComponent(Key<?> componentKey)
boolean hasComponent(Class<? extends Annotation > annotation)
void removeComponent(Annotation annotation)
final List< Object > components