/** * Returns the existing task whose class is exactly a given class (and not a subclass -- this * will always return null for an abstract type). * * @param clazz the class to look up * @return one of this manager's tasks that's an instance of that class and not a subclass, or * null if no such tasks are registered */ public EntityTask getTask(Class<? extends EntityTask> clazz) { return tasksByClass.get(clazz); }
public void testNull() { try { map.put(null, new Integer(1)); fail(); } catch (NullPointerException expected) { } map.putInstance(Integer.class, null); assertNull(map.get(Integer.class)); assertNull(map.getInstance(Integer.class)); map.put(Long.class, null); assertNull(map.get(Long.class)); assertNull(map.getInstance(Long.class)); }
@SuppressWarnings("unchecked") public <T extends OptionsBean> T getOptionBean(Class<T> clazz){ Object o = optionBeans.get(clazz); checkNotNull(o, "No [%s] found in [%s]", clazz.getSimpleName(), optionBeans); return (T) o; }
public void testNull() { try { map.put(null, new Integer(1)); fail(); } catch (NullPointerException expected) { } map.putInstance(Integer.class, null); assertNull(map.get(Integer.class)); assertNull(map.getInstance(Integer.class)); map.put(Long.class, null); assertNull(map.get(Long.class)); assertNull(map.getInstance(Long.class)); }
@SuppressWarnings("unchecked") public <T extends OptionsBean> T getOptionBean(Class<T> clazz){ Object o = optionBeans.get(clazz); checkNotNull(o, "No [%s] found in [%s]", clazz.getSimpleName(), optionBeans); return (T) o; }
@SuppressWarnings("unchecked") public synchronized <T> T get(@Nullable String name, Class<T> aClass) { ClassToInstanceMap<Object> instanceMap = nameMap.get(ofNullable(name)); if (instanceMap == null) { return null; } return (T) instanceMap.get(aClass); } }
private void checkAllRequiredServices() { for (final Class<? extends D> type : getRequiredDelegates()) { Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.", type); } } }
private void checkAllRequiredServices() { for(final Class<? extends D> type : getRequiredDelegates()) { Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type); } }
private void checkAllRequiredServices() { for (final Class<? extends D> type : getRequiredDelegates()) { Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type); } }
@Override public Object entityFor(Class<?> clazz, Node node, Supplier<Object> newInstance) { ClassToInstanceMap<Object> typeToEntity = nodeToTypeToEntity.computeIfAbsent(node, (x) -> MutableClassToInstanceMap.create()); Object result = newInstance != null ? typeToEntity.computeIfAbsent(clazz, (type) -> newInstance.get()) : typeToEntity.get(clazz); return result; }
@Override public Object entityFor(Class<?> clazz, Node node, Supplier<Object> newInstance) { ClassToInstanceMap<Object> typeToEntity = nodeToTypeToEntity.computeIfAbsent(node, (x) -> MutableClassToInstanceMap.create()); Object result = newInstance != null ? typeToEntity.computeIfAbsent(clazz, (type) -> newInstance.get()) : typeToEntity.get(clazz); return result; }
public static IInjectorProvider getInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { return injectorProviderClassCache.get(injectWith.value()); } return null; }
public static IInjectorProvider getInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { return injectorProviderClassCache.get(injectWith.value()); } return null; }
public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) { super(domDataBroker, codec); // FIXME: this is an invalid lookup final DOMDataTreeService domTreeChange = (DOMDataTreeService) domDataBroker.getExtensions().get(DOMDataTreeService.class); if (domTreeChange != null) { treeService = BindingDOMDataTreeServiceAdapter.create(domTreeChange, codec); } else { treeService = null; } }
public static IInjectorProvider getOrCreateInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
public static IInjectorProvider getOrCreateInjectorProvider(TestClass testClass) { InjectWith injectWith = testClass.getJavaClass().getAnnotation(InjectWith.class); if (injectWith != null) { Class<? extends IInjectorProvider> klass = injectWith.value(); IInjectorProvider injectorProvider = injectorProviderClassCache.get(klass); if (injectorProvider == null) { try { injectorProvider = klass.newInstance(); injectorProviderClassCache.put(klass, injectorProvider); } catch (Exception e) { throwUncheckedException(e); } } return injectorProvider; } return null; }
@Override public ExporterPlugin getExporter(Class<? extends ExporterPlugin> clazz) { if(exporterRegistryCache == null) { exporterRegistryCache = MutableClassToInstanceMap.create(); PluginManagerUtil util = new PluginManagerUtil(getPluginManager()); for (ExporterPlugin e : util.getPlugins(ExporterPlugin.class)) { exporterRegistryCache.put(e.getClass(), e); } } return exporterRegistryCache.get(clazz); }
(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get( org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class); if (delegateTreeChangeService != null) { (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get( org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class); if (delegateCohortRegistry != null) {
public IBrush setCurrentBrush(Class<? extends IBrush> brush) { Preconditions.checkNotNull(brush, "Can't set brush to null."); IBrush brushInstance = this.brushes.get(brush); if (brushInstance == null) { brushInstance = instanciateBrush(brush); Preconditions.checkNotNull(brushInstance, "Could not instanciate brush class."); this.brushes.put(brush, brushInstance); } if (this.snipeData.owner().getPlayer().hasPermission(brushInstance.getPermissionNode())) { Sponge.getCauseStackManager().pushCause(VoxelSniper.getInstance()); Sponge.getCauseStackManager().pushCause(this.snipeData.owner().getPlayer()); ChangeBrushEvent event = new ChangeBrushEvent(Sponge.getCauseStackManager().getCurrentCause(), this.snipeData, brushInstance); Sponge.getEventManager().post(event); Sponge.getCauseStackManager().popCauses(2); this.previousBrush = this.currentBrush; this.currentBrush = brush; return brushInstance; } return null; }