private final BindingNormalizedNodeSerializer codec;
private final NotificationListener delegate;
- private final Map<SchemaPath,NotificationListenerInvoker> invokers;
+ private final ImmutableMap<SchemaPath, NotificationListenerInvoker> invokers;
BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
final NotificationListener delegate) {
return invokers.keySet();
}
- public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
+ private static ImmutableMap<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
public class BindingDOMRpcProviderServiceAdapter extends AbstractBindingAdapter<DOMRpcProviderService>
implements RpcProviderService {
- private static final Set<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.builder().build());
+ private static final ImmutableSet<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.EMPTY);
public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry,
final BindingToNormalizedNodeCodec codec) {
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
-import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
return new NotificationListenerInvoker(createInvokerMap(key));
}
- private Map<QName, MethodHandle> createInvokerMap(final Class<? extends NotificationListener> key) {
+ private ImmutableMap<QName, MethodHandle> createInvokerMap(
+ final Class<? extends NotificationListener> key) {
final Builder<QName, MethodHandle> ret = ImmutableMap.builder();
for (final Method method : key.getMethods()) {
if (BindingReflections.isNotificationCallback(method)) {
}
});
- private final Map<QName, MethodHandle> methodInvokers;
+ private final ImmutableMap<QName, MethodHandle> methodInvokers;
- NotificationListenerInvoker(final Map<QName, MethodHandle> map) {
+ NotificationListenerInvoker(final ImmutableMap<QName, MethodHandle> map) {
this.methodInvokers = map;
}
*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import java.util.Set;
+import com.google.common.collect.ImmutableSet;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
*/
abstract class AbstractBindingNormalizedNodeCacheHolder {
- private final Set<Class<? extends DataObject>> cachedValues;
+ private final ImmutableSet<Class<? extends DataObject>> cachedValues;
private final LoadingCache<DataContainerCodecContext<?, ?>, BindingNormalizedNodeCache> caches = CacheBuilder
.newBuilder().build(new CacheLoader<DataContainerCodecContext<?, ?>, BindingNormalizedNodeCache>() {
@Override
}
});
- protected AbstractBindingNormalizedNodeCacheHolder(final Set<Class<? extends DataObject>> cacheSpec) {
- cachedValues = Preconditions.checkNotNull(cacheSpec);
+ AbstractBindingNormalizedNodeCacheHolder(final ImmutableSet<Class<? extends DataObject>> cacheSpec) {
+ cachedValues = requireNonNull(cacheSpec);
}
BindingNormalizedNodeCache getCachingSerializer(final DataContainerCodecContext<?, ?> childCtx) {
*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.lang.invoke.MethodHandle;
private static final MethodType CONSTRUCTOR_INVOKE_TYPE = MethodType.methodType(Object.class, Boolean[].class);
// Ordered by position
- private final Map<String, Method> getters;
+ private final ImmutableMap<String, Method> getters;
// Ordered by lexical name
- private final Set<String> ctorArgs;
+ private final ImmutableSet<String> ctorArgs;
private final MethodHandle ctor;
private BitsCodec(final Class<?> typeClass, final MethodHandle ctor, final Set<String> ctorArgs,
final Map<String, Method> getters) {
super(typeClass);
- this.ctor = Preconditions.checkNotNull(ctor);
+ this.ctor = requireNonNull(ctor);
this.ctorArgs = ImmutableSet.copyOf(ctorArgs);
this.getters = ImmutableMap.copyOf(getters);
}
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Object deserialize(final Object input) {
- Preconditions.checkArgument(input instanceof Set);
+ checkArgument(input instanceof Set);
@SuppressWarnings("unchecked")
final Set<String> casted = (Set<String>) input;
*/
package org.opendaylight.mdsal.binding.dom.codec.impl;
-import com.google.common.base.Preconditions;
-import java.util.Set;
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ImmutableSet;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeCachingCodec;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
private final DataContainerCodecContext<D, ?> context;
CachingNormalizedNodeCodec(final DataContainerCodecContext<D, ?> subtreeRoot,
- final Set<Class<? extends DataObject>> cacheSpec) {
+ final ImmutableSet<Class<? extends DataObject>> cacheSpec) {
super(cacheSpec);
- this.context = Preconditions.checkNotNull(subtreeRoot);
+ this.context = requireNonNull(subtreeRoot);
}
@Override
if (cacheSpecifier.isEmpty()) {
return new NonCachingCodec<>(this);
}
- return new CachingNormalizedNodeCodec<>(this,ImmutableSet.copyOf(cacheSpecifier));
+ return new CachingNormalizedNodeCodec<>(this, ImmutableSet.copyOf(cacheSpecifier));
}
BindingStreamEventWriter createWriter(final NormalizedNodeStreamWriter domWriter) {
@ThreadSafe
public final class BindingRuntimeTypes implements Immutable {
- private final Map<Type, AugmentationSchemaNode> typeToAugmentation;
- private final BiMap<Type, WithStatus> typeToSchema;
- private final Multimap<Type, Type> choiceToCases;
- private final Map<QName, Type> identities;
+ private final ImmutableMap<Type, AugmentationSchemaNode> typeToAugmentation;
+ private final ImmutableBiMap<Type, WithStatus> typeToSchema;
+ private final ImmutableMultimap<Type, Type> choiceToCases;
+ private final ImmutableMap<QName, Type> identities;
public BindingRuntimeTypes(final Map<Type, AugmentationSchemaNode> typeToAugmentation,
final BiMap<Type, WithStatus> typeToDefiningSchema, final Multimap<Type, Type> choiceToCases,
@NotThreadSafe
abstract class AbstractJavaGeneratedType {
private final Map<JavaTypeName, @Nullable String> nameCache = new HashMap<>();
- private final Map<String, NestedJavaGeneratedType> enclosedTypes;
- private final Set<String> conflictingNames;
+ private final ImmutableMap<String, NestedJavaGeneratedType> enclosedTypes;
+ private final ImmutableSet<String> conflictingNames;
private final JavaTypeName name;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
-import java.util.Map;
import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.model.api.ConcreteType;
abstract class AbstractRangeGenerator<T extends Number & Comparable<T>> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractRangeGenerator.class);
- private static final Map<String, AbstractRangeGenerator<?>> GENERATORS;
+ private static final ImmutableMap<String, AbstractRangeGenerator<?>> GENERATORS;
private static void addGenerator(final Builder<String, AbstractRangeGenerator<?>> builder,
final AbstractRangeGenerator<?> generator) {