/** * Determines if this object currently contains any plugins (in any state of registration). If * this object has any {@link #defer(Runnable) deferred registrations}, it is assumed that * executing them will result in at least one plugin being registered. */ public boolean isEmpty() { if (parent != null && !parent.isEmpty()) { return false; } UnmodifiableEconomicMap<ResolvedJavaMethod, InvocationPlugin> resolvedRegs = resolvedRegistrations; if (resolvedRegs != null) { if (!resolvedRegs.isEmpty()) { return false; } } List<Runnable> deferred = deferredRegistrations; if (deferred != null) { if (!deferred.isEmpty()) { return false; } } for (LateClassPlugins late = lateRegistrations; late != null; late = late.next) { if (!late.bindings.isEmpty()) { return false; } } return registrations.size() == 0; }
/** * Updates this object with the key/value pairs in {@code values}. * * @see #UNSET_KEY */ public void update(UnmodifiableEconomicMap<OptionKey<?>, Object> values) { if (values.isEmpty()) { return; } UnmodifiableEconomicMap<OptionKey<?>, Object> expect; EconomicMap<OptionKey<?>, Object> newMap; do { expect = v.get(); newMap = EconomicMap.create(Equivalence.IDENTITY, expect); UnmodifiableMapCursor<OptionKey<?>, Object> cursor = values.getEntries(); while (cursor.advance()) { OptionKey<?> key = cursor.getKey(); Object value = cursor.getValue(); if (value == UNSET_KEY) { newMap.removeKey(key); } else { key.update(newMap, value); // Need to do the null encoding here as `key.update()` doesn't do it newMap.put(key, encodeNull(value)); } } } while (!v.compareAndSet(expect, newMap)); }