MCPcopy Create free account
hub / github.com/google/guice / add

Method add

core/src/com/google/inject/internal/WeakKeySet.java:79–99  ·  view source on GitHub ↗
(Key<?> key, InjectorBindingData state, Object source)

Source from the content-addressed store, hash-verified

77 }
78
79 public void add(Key<?> key, InjectorBindingData state, Object source) {
80 if (backingMap == null) {
81 backingMap = Maps.newHashMap();
82 }
83 // if it's an instanceof Class, it was a JIT binding, which we don't
84 // want to retain.
85 if (source instanceof Class || source == SourceProvider.UNKNOWN_SOURCE) {
86 source = null;
87 }
88 Object convertedSource = Errors.convert(source);
89 backingMap.computeIfAbsent(key, k -> LinkedHashMultiset.create()).add(convertedSource);
90
91 // Avoid all the extra work if we can.
92 if (state.parent().isPresent()) {
93 Set<KeyAndSource> keyAndSources = evictionCache.getIfPresent(state);
94 if (keyAndSources == null) {
95 evictionCache.put(state, keyAndSources = Sets.newHashSet());
96 }
97 keyAndSources.add(new KeyAndSource(key, convertedSource));
98 }
99 }
100
101 public boolean contains(Key<?> key) {
102 evictionCache.cleanUp();

Callers 15

getClassPathUrlsMethod · 0.45
moduleMethod · 0.45
afterInjectionMethod · 0.45
onProvisionMethod · 0.45
onProvisionMethod · 0.45
onProvisionMethod · 0.45
configureMethod · 0.45
visitMethod · 0.45
invokeMethod · 0.45
invokeMethod · 0.45
assertDistinctMethod · 0.45

Calls 3

convertMethod · 0.95
createMethod · 0.65
parentMethod · 0.45

Tested by 15

getClassPathUrlsMethod · 0.36
moduleMethod · 0.36
afterInjectionMethod · 0.36
onProvisionMethod · 0.36
onProvisionMethod · 0.36
onProvisionMethod · 0.36
configureMethod · 0.36
visitMethod · 0.36
invokeMethod · 0.36
invokeMethod · 0.36
assertDistinctMethod · 0.36