@SuppressWarnings("unchecked") public static ImmutableClassToInstanceMap<Annotation> annotationMap(Symbol symbol) { ImmutableClassToInstanceMap.Builder<Annotation> builder = ImmutableClassToInstanceMap.builder(); for (Compound compound : symbol.getAnnotationMirrors()) { Name qualifiedAnnotationType = ((TypeElement) compound.getAnnotationType().asElement()).getQualifiedName(); try { Class<? extends Annotation> annotationClazz = Class.forName(qualifiedAnnotationType.toString()).asSubclass(Annotation.class); builder.put( (Class) annotationClazz, AnnotationProxyMaker.generateAnnotation(compound, annotationClazz)); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Unrecognized annotation type", e); } } return builder.build(); } }
/** * Associates all of {@code map's} keys and values in the built map. Duplicate keys are not * allowed, and will cause {@link #build} to fail. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type specified by its key */ @CanIgnoreReturnValue public <T extends B> Builder<B> putAll(Map<? extends Class<? extends T>, ? extends T> map) { for (Entry<? extends Class<? extends T>, ? extends T> entry : map.entrySet()) { Class<? extends T> type = entry.getKey(); T value = entry.getValue(); mapBuilder.put(type, cast(type, value)); } return this; }
org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class); if (delegateTreeChangeService != null) { extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { @Override public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener( org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class); if (delegateCohortRegistry != null) { extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort); extensions = extBuilder.build();
public void start() { checkState(controllerRoot == null, "Binding Aware Broker was already started."); LOG.info("Starting Binding Aware Broker: {}", identifier); controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker()); final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap .builder(); consBuilder.put(NotificationService.class, getRoot()); consBuilder.put(DataBrokerService.class, getRoot()); consBuilder.put(RpcConsumerRegistry.class, getRoot()); if (dataBroker != null) { consBuilder.put(DataBroker.class, dataBroker); } consBuilder.put(MountPointService.class, mountService); consBuilder.put(MountService.class, legacyMount).build(); supportedConsumerServices = consBuilder.build(); final ImmutableClassToInstanceMap.Builder<BindingAwareService> provBuilder = ImmutableClassToInstanceMap .builder(); provBuilder.putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot()) .put(DataProviderService.class, getRoot()).put(RpcProviderRegistry.class, getRoot()) .put(MountProviderService.class, legacyMount); if (notificationPublishService != null) { provBuilder.put(NotificationPublishService.class, notificationPublishService); } supportedConsumerServices = consBuilder.build(); supportedProviderServices = provBuilder.build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If {@code map} somehow * contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose * comparator is not <i>consistent with equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an {@code * ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If {@code map} somehow * contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose * comparator is not <i>consistent with equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an {@code * ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type specified by its key */ public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) // Eclipse won't compile if we cast to the parameterized type. ImmutableClassToInstanceMap<B> cast = (ImmutableClassToInstanceMap) map; return cast; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { return (ImmutableClassToInstanceMap<B>) (Map) map; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { return (ImmutableClassToInstanceMap<B>) (Map) map; } return new Builder<B>().putAll(map).build(); }
/** * Associates all of {@code map's} keys and values in the built map. * Duplicate keys are not allowed, and will cause {@link #build} to fail. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public <T extends B> Builder<B> putAll( Map<? extends Class<? extends T>, ? extends T> map) { for (Entry<? extends Class<? extends T>, ? extends T> entry : map.entrySet()) { Class<? extends T> type = entry.getKey(); T value = entry.getValue(); mapBuilder.put(type, cast(type, value)); } return this; }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { return (ImmutableClassToInstanceMap<B>) (Map) map; } return new Builder<B>().putAll(map).build(); }
/** * Returns an immutable map containing the same entries as {@code map}. If * {@code map} somehow contains entries with duplicate keys (for example, if * it is a {@code SortedMap} whose comparator is not <i>consistent with * equals</i>), the results of this method are undefined. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is * an {@code ImmutableClassToInstanceMap}, no copy will actually be performed. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ @SuppressWarnings("unchecked") // covariant casts safe (unmodifiable) public static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf( Map<? extends Class<? extends S>, ? extends S> map) { if (map instanceof ImmutableClassToInstanceMap) { return (ImmutableClassToInstanceMap<B>) (Map) map; } return new Builder<B>().putAll(map).build(); }
/** * Associates all of {@code map's} keys and values in the built map. * Duplicate keys are not allowed, and will cause {@link #build} to fail. * * @throws NullPointerException if any key or value in {@code map} is null * @throws ClassCastException if any value is not an instance of the type * specified by its key */ public <T extends B> Builder<B> putAll( Map<? extends Class<? extends T>, ? extends T> map) { for (Entry<? extends Class<? extends T>, ? extends T> entry : map.entrySet()) { Class<? extends T> type = entry.getKey(); T value = entry.getValue(); mapBuilder.put(type, cast(type, value)); } return this; }