</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
<scm>
for (final Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
try {
- final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(entry);
+ final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential
+ = getCodec().toBinding(entry);
if (potential.isPresent()) {
final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = potential.get();
newMap.put(binding.getKey(), binding.getValue());
final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
for (final YangInstanceIdentifier normalizedPath : normalized) {
try {
- final Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
+ final Optional<InstanceIdentifier<? extends DataObject>> potential
+ = getCodec().toBinding(normalizedPath);
if (potential.isPresent()) {
final InstanceIdentifier<? extends DataObject> binding = potential.get();
hashSet.add(binding);
- } else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) {
+ } else if (normalizedPath.getLastPathArgument()
+ instanceof YangInstanceIdentifier.AugmentationIdentifier) {
hashSet.add(path);
}
} catch (final DeserializationException e) {
if (path.isWildcarded()) {
return Optional.absent();
}
- return (Optional<DataObject>) getCodec().deserializeFunction(path).apply(Optional.<NormalizedNode<?, ?>> of(data));
+ return (Optional<DataObject>) getCodec().deserializeFunction(path).apply(
+ Optional.<NormalizedNode<?, ?>>of(data));
}
@Override
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.common.api.AsyncTransaction;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import org.opendaylight.mdsal.common.api.AsyncTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture;
private final T delegate;
private final BindingToNormalizedNodeCodec codec;
- public AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
+ AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
this.delegate = Preconditions.checkNotNull(delegateTx, "Delegate must not be null");
this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
}
}
@SuppressWarnings("unchecked")
- protected final <S extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>> S getDelegateChecked(final Class<S> txType) {
+ protected final <S extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>> S getDelegateChecked(
+ final Class<S> txType) {
Preconditions.checkState(txType.isInstance(delegate));
return (S) delegate;
}
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.Map.Entry;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- *
* Abstract Base Transaction for transactions which are backed by
- * {@link DOMDataTreeWriteTransaction}
+ * {@link DOMDataTreeWriteTransaction}.
*/
public abstract class AbstractWriteTransaction<T extends DOMDataTreeWriteTransaction> extends
AbstractForwardedTransaction<T> {
}
/**
- *
* Ensures list parent if item is list, otherwise noop.
*
* <p>
* put("/nodes/node/node[key]",domNode);
* </pre>
*
- *
+ * <p>
* In order to allow that to be inserted if necessary, if we know
* item is list item, we will try to merge empty MapNode or OrderedNodeMap
* to ensure list exists.
}
/**
- * @deprecated Use {@link YangInstanceIdentifier#getParent()} instead.
+ * Use {@link YangInstanceIdentifier#getParent()} instead.
*/
@Deprecated
protected static Optional<YangInstanceIdentifier> getParent(final YangInstanceIdentifier child) {
* Subclasses of this class are required to implement creation of parent nodes based on
* behaviour of their underlying transaction.
*
- * @param store
- * @param domPath
- * @param path
+ * @param store an instance of LogicalDatastoreType
+ * @param domPath an instance of YangInstanceIdentifier
+ * @param path an instance of InstanceIdentifier
*/
protected final void ensureParentsByMerge(final LogicalDatastoreType store, final YangInstanceIdentifier domPath,
final InstanceIdentifier<?> path) {
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableClassToInstanceMap;
protected abstract T createInstance(ClassToInstanceMap<D> delegates);
private void checkAllRequiredServices() {
- for(final Class<? extends D> type : getRequiredDelegates()) {
+ for (final Class<? extends D> type : getRequiredDelegates()) {
Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type);
}
}
- public final <V extends D>void addDelegate(final Class<V> type,final D impl) {
+ public final <V extends D> void addDelegate(final Class<V> type,final D impl) {
delegates.put(type,impl);
}
public Optional<T> load(final Class<? extends T> key) {
final AdapterBuilder<? extends T, D> builder = createBuilder(key);
- for(final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
+ for (final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
final D deleg = getDelegate(reqDeleg);
- if(deleg != null) {
+ if (deleg != null) {
builder.addDelegate(reqDeleg,deleg);
} else {
return Optional.absent();
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMService;
-
-import org.opendaylight.mdsal.binding.api.BindingService;
import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
+import org.opendaylight.mdsal.binding.api.BindingService;
+import org.opendaylight.mdsal.dom.api.DOMService;
abstract class BindingDOMAdapterBuilder<T extends BindingService> extends AdapterBuilder<T, DOMService> {
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMService;
-
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
import org.opendaylight.mdsal.binding.api.BindingService;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
+import org.opendaylight.mdsal.dom.api.DOMService;
public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingService, DOMService> {
- private static final Map<Class<?>,BindingDOMAdapterBuilder.Factory<?>> FACTORIES = ImmutableMap.<Class<?>,BindingDOMAdapterBuilder.Factory<?>>builder()
+ private static final Map<Class<?>,BindingDOMAdapterBuilder.Factory<?>> FACTORIES = ImmutableMap.<Class<?>,
+ BindingDOMAdapterBuilder.Factory<?>>builder()
.put(NotificationService.class,BindingDOMNotificationServiceAdapter.BUILDER_FACTORY)
.put(NotificationPublishService.class,BindingDOMNotificationPublishServiceAdapter.BUILDER_FACTORY)
.put(DataBroker.class,BindingDOMDataBrokerAdapter.BUILDER_FACTORY)
}
@Override
- protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(final Class<? extends BindingService> key) {
+ protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(
+ final Class<? extends BindingService> key) {
final Factory<?> factory = FACTORIES.get(key);
Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-public class BindingDOMCursorAwareWriteTransactionAdapter<T extends DOMDataTreeCursorAwareTransaction> implements CursorAwareWriteTransaction {
+public class BindingDOMCursorAwareWriteTransactionAdapter<T extends DOMDataTreeCursorAwareTransaction>
+ implements CursorAwareWriteTransaction {
private T delegate;
private BindingToNormalizedNodeCodec codec;
@Override
public <T extends DataObject> DataTreeWriteCursor createCursor(final DataTreeIdentifier<T> path) {
final YangInstanceIdentifier yPath = codec.toNormalized(path.getRootIdentifier());
- final DOMDataTreeWriteCursor cursor = delegate.createCursor(new DOMDataTreeIdentifier(path.getDatastoreType(), yPath));
+ final DOMDataTreeWriteCursor cursor = delegate.createCursor(
+ new DOMDataTreeIdentifier(path.getDatastoreType(), yPath));
return new BindingDOMDataTreeWriteCursorAdapter<>(path, cursor, codec);
}
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-
-import org.opendaylight.mdsal.common.api.TransactionChainListener;
-
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.mdsal.dom.api.DOMService;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
import org.opendaylight.mdsal.binding.api.BindingTransactionChain;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.mdsal.dom.api.DOMService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
+
/**
* The DataBrokerImpl simply defers to the DOMDataBroker for all its operations.
* All transactions and listener registrations are wrapped by the DataBrokerImpl
* to allow binding aware components to use the DataBroker transparently.
*
+ * <p>
* Besides this the DataBrokerImpl and it's collaborators also cache data that
* is already transformed from the binding independent to binding aware format
*
-
*/
-public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker implements DataBroker, DataTreeChangeService {
+public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker implements
+ DataBroker, DataTreeChangeService {
static final Factory<DataBroker> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<DataBroker>() {
public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
super(domDataBroker, codec);
- final DOMDataTreeChangeService domTreeChange = (DOMDataTreeChangeService) domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
- if(domTreeChange != null) {
+ final DOMDataTreeChangeService domTreeChange
+ = (DOMDataTreeChangeService) domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
+ if (domTreeChange != null) {
treeChangeService = BindingDOMDataTreeChangeServiceAdapter.create(codec, domTreeChange);
} else {
treeChangeService = null;
}
@Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
+ registerDataTreeChangeListener(
final DataTreeIdentifier<T> treeId, final L listener) {
- if(treeChangeService == null) {
+ if (treeChangeService == null) {
throw new UnsupportedOperationException("Underlying data broker does not expose DOMDataTreeChangeService.");
}
return treeChangeService.registerDataTreeChangeListener(treeId, listener);
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
import com.google.common.base.Preconditions;
import java.util.Collection;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
private final DataTreeChangeListener<T> listener;
private final LogicalDatastoreType store;
- BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec, final DataTreeChangeListener<T> listener,
- final LogicalDatastoreType store) {
+ BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
+ final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
this.codec = Preconditions.checkNotNull(codec);
this.listener = Preconditions.checkNotNull(listener);
this.store = Preconditions.checkNotNull(store);
@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
- final Collection<DataTreeModification<T>> bindingChanges = LazyDataTreeModification.from(codec, domChanges, store);
+ final Collection<DataTreeModification<T>> bindingChanges
+ = LazyDataTreeModification.from(codec, domChanges, store);
listener.onDataTreeChanged(bindingChanges);
}
}
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-
+import com.google.common.base.Preconditions;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeChangeService;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import com.google.common.base.Preconditions;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
/**
- *
* Adapter exposing Binding {@link DataTreeChangeService} and wrapping
* {@link DOMDataTreeChangeService} and is responsible for translation
* and instantiation of {@link BindingDOMDataTreeChangeListenerAdapter}
* adapters.
*
+ * <p>
* Each registered {@link DataTreeChangeListener} is wrapped using
* adapter and registered directly to DOM service.
*/
}
@Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(
- final DataTreeIdentifier<T> treeId, final L listener) {
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
+ registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) {
final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId);
- final BindingDOMDataTreeChangeListenerAdapter<T> domListener = new BindingDOMDataTreeChangeListenerAdapter<>(codec,listener, treeId.getDatastoreType());
- final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg = dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener);
+ final BindingDOMDataTreeChangeListenerAdapter<T> domListener
+ = new BindingDOMDataTreeChangeListenerAdapter<>(codec,listener, treeId.getDatastoreType());
+ final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg
+ = dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener);
return new BindingDataTreeChangeListenerRegistration<>(listener,domReg);
}
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeProducer;
import org.opendaylight.mdsal.binding.api.DataTreeProducerException;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducerBusyException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
class BindingDOMDataTreeProducerAdapter implements DataTreeProducer {
private final DOMDataTreeService delegate;
private final BindingToNormalizedNodeCodec codec;
- private BindingDOMDataTreeServiceAdapter(final DOMDataTreeService delegate, final BindingToNormalizedNodeCodec codec) {
+ private BindingDOMDataTreeServiceAdapter(final DOMDataTreeService delegate,
+ final BindingToNormalizedNodeCodec codec) {
this.delegate = Preconditions.checkNotNull(delegate, "delegate");
this.codec = Preconditions.checkNotNull(codec, "codec");
}
private BindingToNormalizedNodeCodec codec;
private final Deque<PathArgument> stack = new ArrayDeque<>();
- public BindingDOMDataTreeWriteCursorAdapter(final DataTreeIdentifier<?> path, final T delegate, final BindingToNormalizedNodeCodec codec) {
+ public BindingDOMDataTreeWriteCursorAdapter(final DataTreeIdentifier<?> path, final T delegate,
+ final BindingToNormalizedNodeCodec codec) {
this.delegate = delegate;
this.codec = codec;
return ret.getLastPathArgument();
}
- private <T extends DataObject> Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> convertToNormalized(final PathArgument child, final T data) {
+ private <T extends DataObject> Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> convertToNormalized(
+ final PathArgument child, final T data) {
stack.push(child);
final InstanceIdentifier<?> iid = InstanceIdentifier.create(stack);
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codec.toNormalizedNode(new SimpleEntry<>(iid, data));
+ final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry
+ = codec.toNormalizedNode(new SimpleEntry<>(iid, data));
stack.pop();
return entry;
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-final class BindingDOMMountPointListenerAdapter<T extends MountPointListener> implements ListenerRegistration<T>, DOMMountPointListener {
+final class BindingDOMMountPointListenerAdapter<T extends MountPointListener> implements
+ ListenerRegistration<T>, DOMMountPointListener {
private final T listener;
private final ListenerRegistration<DOMMountPointListener> registration;
private final BindingToNormalizedNodeCodec codec;
- public BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec, final DOMMountPointService mountService) {
+ BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec,
+ final DOMMountPointService mountService) {
this.listener = listener;
this.codec = codec;
this.registration = mountService.registerProvisionListener(this);
final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
listener.onMountPointCreated(bindingPath);
} catch (final DeserializationException e) {
- BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",path,e);
+ BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}."
+ + " Omitting event.",path,e);
}
}
- private InstanceIdentifier<? extends DataObject> toBinding(final YangInstanceIdentifier path) throws DeserializationException {
+ private InstanceIdentifier<? extends DataObject> toBinding(final YangInstanceIdentifier path)
+ throws DeserializationException {
final Optional<InstanceIdentifier<? extends DataObject>> instanceIdentifierOptional = codec.toBinding(path);
- if(instanceIdentifierOptional.isPresent()) {
+ if (instanceIdentifierOptional.isPresent()) {
return instanceIdentifierOptional.get();
} else {
throw new DeserializationException("Deserialization unsuccessful, " + instanceIdentifierOptional);
final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
listener.onMountPointRemoved(bindingPath);
} catch (final DeserializationException e) {
- BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",path,e);
+ BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}."
+ + " Omitting event.",path,e);
}
}
}
\ No newline at end of file
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.mdsal.dom.api.DOMMountPointService;
-
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.MountPointService;
import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint);
Optional<DOMMountPoint> domMount = mountService.getMountPoint(domPath);
- if(domMount.isPresent()) {
+ if (domMount.isPresent()) {
return Optional.<MountPoint>fromNullable(bindingMountpoints.getUnchecked(domMount.get()));
}
return Optional.absent();
private final NotificationListener delegate;
private final Map<SchemaPath,NotificationListenerInvoker> invokers;
- public BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final NotificationListener delegate) {
+ BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
+ final NotificationListener delegate) {
this.codec = codec;
this.delegate = delegate;
this.invokers = createInvokerMapFor(delegate.getClass());
}
private Notification deserialize(final DOMNotification notification) {
- if(notification instanceof LazySerializedDOMNotification) {
+ if (notification instanceof LazySerializedDOMNotification) {
return ((LazySerializedDOMNotification) notification).getBindingData();
}
return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
return invokers.keySet();
}
- public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
+ public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
+ final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
- for(final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
+ for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
Class<?> iface = ifaceToken.getRawType();
- if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
+ if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
+ final Class<? extends NotificationListener> listenerType
+ = (Class<? extends NotificationListener>) iface;
final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for(final SchemaPath path : getNotificationTypes(listenerType)) {
+ for (final SchemaPath path : getNotificationTypes(listenerType)) {
builder.put(path, invoker);
}
}
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
- for(final Method method : type.getMethods()) {
- if(BindingReflections.isNotificationCallback(method)) {
+ for (final Method method : type.getMethods()) {
+ if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMNotification;
-import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.mdsal.dom.api.DOMService;
-
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.mdsal.dom.api.DOMService;
import org.opendaylight.yangtools.yang.binding.Notification;
public class BindingDOMNotificationPublishServiceAdapter implements NotificationPublishService, AutoCloseable {
- static final Factory<NotificationPublishService> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<NotificationPublishService>() {
+ static final Factory<NotificationPublishService> BUILDER_FACTORY
+ = new BindingDOMAdapterBuilder.Factory<NotificationPublishService>() {
- @Override
- public BindingDOMAdapterBuilder<NotificationPublishService> newBuilder() {
- return new Builder();
- }
+ @Override
+ public BindingDOMAdapterBuilder<NotificationPublishService> newBuilder() {
+ return new Builder();
+ }
- };
+ };
private final BindingToNormalizedNodeCodec codecRegistry;
private final DOMNotificationPublishService domPublishService;
- public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMNotificationPublishService domPublishService) {
+ public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec,
+ final DOMNotificationPublishService domPublishService) {
this.codecRegistry = codec;
this.domPublishService = domPublishService;
}
}
@Override
- public ListenableFuture<? extends Object> offerNotification(final Notification notification, final int timeout, final TimeUnit unit) throws InterruptedException {
- ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification), timeout, unit);
+ public ListenableFuture<? extends Object> offerNotification(final Notification notification,
+ final int timeout, final TimeUnit unit) throws InterruptedException {
+ ListenableFuture<?> offerResult = domPublishService.offerNotification(
+ toDomNotification(notification), timeout, unit);
return DOMNotificationPublishService.REJECTED.equals(offerResult)
? NotificationPublishService.REJECTED
: offerResult;
private final BindingNormalizedNodeSerializer codec;
private final DOMNotificationService domNotifService;
- public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, final DOMNotificationService domNotifService) {
+ public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec,
+ final DOMNotificationService domNotifService) {
this.codec = codec;
this.domNotifService = domNotifService;
}
@Override
public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
- final BindingDOMNotificationListenerAdapter domListener = new BindingDOMNotificationListenerAdapter(codec, listener);
+ final BindingDOMNotificationListenerAdapter domListener
+ = new BindingDOMNotificationListenerAdapter(codec, listener);
final ListenerRegistration<BindingDOMNotificationListenerAdapter> domRegistration =
domNotifService.registerNotificationListener(domListener, domListener.getSupportedNotifications());
return new ListenerRegistrationImpl<>(listener, domRegistration);
}
- private static class ListenerRegistrationImpl<T extends NotificationListener> extends AbstractListenerRegistration<T> {
+ private static class ListenerRegistrationImpl<T extends NotificationListener>
+ extends AbstractListenerRegistration<T> {
private final ListenerRegistration<?> listenerRegistration;
- public ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
+ ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
super(listener);
this.listenerRegistration = listenerRegistration;
}
*/
package org.opendaylight.mdsal.binding.dom.adapter;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-
class BindingDOMReadTransactionAdapter extends AbstractForwardedTransaction<DOMDataTreeReadTransaction> implements
ReadTransaction {
package org.opendaylight.mdsal.binding.dom.adapter;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.binding.RpcService;
-class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
private final DOMRpcImplementationRegistration<?> reg;
- public BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+ BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
super(instance);
this.reg = reg;
}
public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation {
- private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS = CacheBuilder.newBuilder().weakKeys().build();
+ private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS
+ = CacheBuilder.newBuilder().weakKeys().build();
private final BindingNormalizedNodeCodecRegistry codec;
private final RpcServiceInvoker invoker;
private final RpcService delegate;
private final QName inputQname;
- public <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeCodecRegistry codec, final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
+ public <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeCodecRegistry codec,
+ final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
try {
this.invoker = SERVICE_INVOKERS.get(type, new Callable<RpcServiceInvoker>() {
@Override
}
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc,
+ final NormalizedNode<?, ?> input) {
final SchemaPath schemaPath = rpc.getType();
final DataObject bindingInput = input != null ? deserilialize(rpc.getType(),input) : null;
final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath,bindingInput);
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-
import com.google.common.collect.ImmutableSet;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
public class BindingDOMRpcProviderServiceAdapter {
private static final Set<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.builder().build());
private final BindingToNormalizedNodeCodec codec;
private final DOMRpcProviderService domRpcRegistry;
- public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry, final BindingToNormalizedNodeCodec codec) {
+ public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry,
+ final BindingToNormalizedNodeCodec codec) {
this.codec = codec;
this.domRpcRegistry = domRpcRegistry;
}
return register(type, implementation, toYangInstanceIdentifiers(paths));
}
- private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type, final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
+ private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
+ final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
final Map<SchemaPath, Method> rpcs = codec.getRpcMethodToSchemaPath(type).inverse();
- final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(codec.getCodecRegistry(), type, rpcs, implementation);
+ final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(
+ codec.getCodecRegistry(), type, rpcs, implementation);
final Set<DOMRpcIdentifier> domRpcs = createDomRpcIdentifiers(rpcs.keySet(), rpcContextPaths);
final DOMRpcImplementationRegistration<?> domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs);
return new BindingRpcAdapterRegistration<>(implementation, domReg);
}
- private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs, final Collection<YangInstanceIdentifier> paths) {
+ private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs,
+ final Collection<YangInstanceIdentifier> paths) {
final Set<DOMRpcIdentifier> ret = new HashSet<>();
for (final YangInstanceIdentifier path : paths) {
for (final SchemaPath rpc : rpcs) {
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
-import org.opendaylight.mdsal.dom.api.DOMService;
-
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMService;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+
public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry {
protected static final Factory<RpcConsumerRegistry> BUILDER_FACTORY = new Factory<RpcConsumerRegistry>() {
*/
package org.opendaylight.mdsal.binding.dom.adapter;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import org.opendaylight.mdsal.binding.api.BindingTransactionChain;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.AsyncTransaction;
import org.opendaylight.mdsal.common.api.TransactionChain;
import org.opendaylight.mdsal.common.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.binding.api.BindingTransactionChain;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import org.opendaylight.yangtools.concepts.Delegator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final DelegateChainListener domListener;
private final TransactionChainListener bindingListener;
- public BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
+ BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
this.domListener = new DelegateChainListener();
final WriteTransaction tx, final CheckedFuture<Void, TransactionCommitFailedException> future) {
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
- public void onFailure(final Throwable t) {
- failTransactionChain(tx,t);
+ public void onFailure(final Throwable throwable) {
+ failTransactionChain(tx, throwable);
}
@Override
return future;
}
- private void failTransactionChain(final WriteTransaction tx, final Throwable t) {
+ private void failTransactionChain(final WriteTransaction tx, final Throwable throwable) {
/*
* We asume correct state change for underlaying transaction
*
* chain, so we are not changing any of our internal state
* to mark that we failed.
*/
- this.bindingListener.onTransactionChainFailed(this, tx, t);
+ this.bindingListener.onTransactionChainFailed(this, tx, throwable);
}
@Override
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
class BindingDOMWriteTransactionAdapter<T extends DOMDataTreeWriteTransaction> extends
AbstractWriteTransaction<T> implements WriteTransaction {
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-
import com.google.common.base.Preconditions;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener<?>> extends AbstractListenerRegistration<L> {
+class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener<?>>
+ extends AbstractListenerRegistration<L> {
private final ListenerRegistration<?> domReg;
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.mdsal.dom.api.DOMService;
-
-import org.opendaylight.mdsal.binding.api.BindingService;
-import org.opendaylight.mdsal.binding.api.MountPoint;
import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LoadingCache;
+import org.opendaylight.mdsal.binding.api.BindingService;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMService;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
public class BindingMountPointAdapter implements MountPoint {
private final InstanceIdentifier<?> identifier;
@Override
public <T extends BindingService> Optional<T> getService(Class<T> service) {
Optional<BindingService> potential = services.getUnchecked(service);
- if(potential.isPresent()) {
+ if (potential.isPresent()) {
return Optional.of(service.cast(potential.get()));
}
return Optional.absent();
package org.opendaylight.mdsal.binding.dom.adapter;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.binding.RpcService;
-class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
private final DOMRpcImplementationRegistration<?> reg;
- public BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+ BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
super(instance);
this.reg = reg;
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
/**
- *
* Defines structural mapping of Normalized Node to Binding data
* addressable by Instance Identifier.
*
+ * <p>
* Not all binding data are addressable by instance identifier
* and there are some differences.
*
+ * <p>
* See {@link #NOT_ADDRESSABLE},{@link #INVISIBLE_CONTAINER},{@link #VISIBLE_CONTAINER}
* for more details.
- *
- *
*/
enum BindingStructuralType {
* DOM Item is not addressable in Binding Instance Identifier,
* data is not lost, but are available only via parent object.
*
+ * <p>
* Such types of data are leaf-lists, leafs, list without keys
* or anyxml.
*
* Data container is addressable in NormalizedNode format,
* but in Binding it is not represented in Instance Identifier.
*
+ * <p>
* This are choice / case nodes.
*
+ * <p>
* This data is still accessible using parent object and their
* children are addressable.
*
* Data container is addressable in NormalizedNode format,
* but in Binding it is not represented in Instance Identifier.
*
+ * <p>
* This are list nodes.
*
+ * <p>
* This data is still accessible using parent object and their
* children are addressable.
*
static BindingStructuralType from(final DataTreeCandidateNode domChildNode) {
final Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter().or(domChildNode.getDataBefore());
- if(dataBased.isPresent()) {
+ if (dataBased.isPresent()) {
return from(dataBased.get());
}
return from(domChildNode.getIdentifier());
}
private static BindingStructuralType from(final PathArgument identifier) {
- if(identifier instanceof NodeIdentifierWithPredicates || identifier instanceof AugmentationIdentifier) {
+ if (identifier instanceof NodeIdentifierWithPredicates || identifier instanceof AugmentationIdentifier) {
return VISIBLE_CONTAINER;
}
- if(identifier instanceof NodeWithValue) {
+ if (identifier instanceof NodeWithValue) {
return NOT_ADDRESSABLE;
}
return UNKNOWN;
}
static BindingStructuralType from(final NormalizedNode<?, ?> data) {
- if(isNotAddressable(data)) {
+ if (isNotAddressable(data)) {
return NOT_ADDRESSABLE;
}
- if(data instanceof MapNode) {
+ if (data instanceof MapNode) {
return INVISIBLE_LIST;
}
- if(data instanceof ChoiceNode) {
+ if (data instanceof ChoiceNode) {
return INVISIBLE_CONTAINER;
}
- if(isVisibleContainer(data)) {
+ if (isVisibleContainer(data)) {
return VISIBLE_CONTAINER;
}
return UNKNOWN;
return data instanceof MapEntryNode || data instanceof ContainerNode || data instanceof AugmentationNode;
}
- private static boolean isNotAddressable(final NormalizedNode<?, ?> d) {
- return d instanceof LeafNode
- || d instanceof AnyXmlNode
- || d instanceof LeafSetNode
- || d instanceof LeafSetEntryNode;
+ private static boolean isNotAddressable(final NormalizedNode<?, ?> normalizedNode) {
+ return normalizedNode instanceof LeafNode
+ || normalizedNode instanceof AnyXmlNode
+ || normalizedNode instanceof LeafSetNode
+ || normalizedNode instanceof LeafSetEntryNode;
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFactory, BindingNormalizedNodeSerializer, SchemaContextListener, AutoCloseable {
+public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFactory,
+ BindingNormalizedNodeSerializer, SchemaContextListener, AutoCloseable {
private static final long WAIT_DURATION_SEC = 5;
private static final Logger LOG = LoggerFactory.getLogger(BindingToNormalizedNodeCodec.class);
}
/**
- * Converts Binding Map.Entry to DOM Map.Entry
+ * Converts Binding Map.Entry to DOM Map.Entry.
*
+ * <p>
* Same as {@link #toNormalizedNode(InstanceIdentifier, DataObject)}.
*
* @param binding Map Entry with InstanceIdentifier as key and DataObject as value.
}
/**
- *
* Returns a Binding-Aware instance identifier from normalized
* instance-identifier if it is possible to create representation.
*
+ * <p>
* Returns Optional.absent for cases where target is mixin node except
* augmentation.
*
public Optional<InstanceIdentifier<? extends DataObject>> toBinding(final YangInstanceIdentifier normalized)
throws DeserializationException {
try {
- return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(codecRegistry.fromYangInstanceIdentifier(normalized));
+ return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(
+ codecRegistry.fromYangInstanceIdentifier(normalized));
} catch (final IllegalArgumentException e) {
return Optional.absent();
}
throws DeserializationException {
try {
/*
- * This cast is required, due to generics behaviour in openjdk / oracle javac
+ * This cast is required, due to generics behaviour in openjdk / oracle javac.
*
+ * <p>
* InstanceIdentifier has definition InstanceIdentifier<T extends DataObject>,
* this means '?' is always  <? extends DataObject>. Eclipse compiler
* is able to determine this relationship and treats
* as assignable. However openjdk / oracle javac treats this two types
* as incompatible and issues a compile error.
*
+ * <p>
* It is safe to loose generic information and cast it to other generic signature.
*
*/
@SuppressWarnings("unchecked")
- final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
+ final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(
+ codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
return Optional.fromNullable(binding);
} catch (final IllegalArgumentException e) {
return Optional.absent();
public void onGlobalContextUpdated(final SchemaContext arg0) {
runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
- if(futureSchema != null) {
+ if (futureSchema != null) {
futureSchema.onRuntimeContextUpdated(runtimeContext);
}
}
- public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>> deserializeFunction(final InstanceIdentifier<T> path) {
+ public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>>
+ deserializeFunction(final InstanceIdentifier<T> path) {
return codecRegistry.deserializeFunction(path);
}
BindingRuntimeContext localRuntimeContext = runtimeContext;
Module module = localRuntimeContext == null ? null :
localRuntimeContext.getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
- if(module == null && futureSchema != null && futureSchema.waitForSchema(namespace,revision)) {
+ if (module == null && futureSchema != null && futureSchema.waitForSchema(namespace,revision)) {
localRuntimeContext = runtimeContext;
Preconditions.checkState(localRuntimeContext != null, "BindingRuntimeContext is not available.");
module = localRuntimeContext.getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
return module;
}
- private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException e) {
- if(futureSchema != null) {
- LOG.warn("Blocking thread to wait for schema convergence updates for {} {}",futureSchema.getDuration(), futureSchema.getUnit());
- if(!futureSchema.waitForSchema(binding)) {
+ private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException exception) {
+ if (futureSchema != null) {
+ LOG.warn("Blocking thread to wait for schema convergence updates for {} {}",
+ futureSchema.getDuration(), futureSchema.getUnit());
+ if (!futureSchema.waitForSchema(binding)) {
return;
}
}
- throw e;
+ throw exception;
}
- private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException {
+ private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef)
+ throws NoSuchMethodException {
final String methodName = BindingMapping.getMethodName(rpcDef.getQName());
- if(rpcDef.getInput() != null) {
+ if (rpcDef.getInput() != null) {
final Class<?> inputClz = runtimeContext.getClassForSchema(rpcDef.getInput());
return key.getMethod(methodName, inputClz);
}
private static Collection<Class<?>> decompose(final InstanceIdentifier<?> path) {
final Set<Class<?>> clazzes = new HashSet<>();
- for(final InstanceIdentifier.PathArgument arg : path.getPathArguments()) {
+ for (final InstanceIdentifier.PathArgument arg : path.getPathArguments()) {
clazzes.add(arg.getType());
}
return clazzes;
* Binding DataObject.
*
* @param obj DataObject from which context reference
- * should be extracted.
+ * should be extracted.
*
* @return Instance Identifier representing context reference
- * or null, if data object does not contain context reference.
+ * or null, if data object does not contain context reference.
*/
abstract @Nullable InstanceIdentifier<?> extract(DataObject obj);
private static Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
try {
final Method method = type.getMethod(GET_VALUE_NAME);
- if(returnType.equals(method.getReturnType())) {
+ if (returnType.equals(method.getReturnType())) {
return method;
}
} catch (final NoSuchMethodException e) {
final class DirectGetterRouteContextExtractor extends ContextReferenceExtractor {
- private final static Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
+ private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
private final MethodHandle handle;
private DirectGetterRouteContextExtractor(final MethodHandle rawHandle) {
handle = rawHandle.asType(MethodType.methodType(InstanceIdentifier.class, DataObject.class));
}
- static final ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException {
+ static ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException {
final MethodHandle getterHandle = PUBLIC_LOOKUP.unreflect(getterMethod);
return new DirectGetterRouteContextExtractor(getterHandle);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
InstanceIdentifier<?> extract(final DataObject obj) {
try {
final class GetValueRouteContextExtractor extends ContextReferenceExtractor {
- private final static Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
+ private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
private final MethodHandle contextHandle;
private final MethodHandle valueHandle;
return new GetValueRouteContextExtractor(rawContextHandle, rawValueHandle);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
InstanceIdentifier<?> extract(final DataObject obj) {
try {
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
-
-import org.opendaylight.mdsal.dom.api.DOMRpcException;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
* Lazily translated {@link DataObjectModification} based on {@link DataTreeCandidateNode}.
*
+ * <p>
* {@link LazyDataObjectModification} represents Data tree change event,
* but whole tree is not translated or resolved eagerly, but only child nodes
* which are directly accessed by user of data object modification.
*/
final class LazyDataObjectModification<T extends DataObject> implements DataObjectModification<T> {
- private final static Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
+ private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
private final BindingCodecTreeNode<T> codec;
private final DataTreeCandidateNode domData;
return new LazyDataObjectModification<>(codec,domData);
}
- private static Collection<DataObjectModification<? extends DataObject>> from(final BindingCodecTreeNode<?> parentCodec,
- final Collection<DataTreeCandidateNode> domChildNodes) {
+ private static Collection<DataObjectModification<? extends DataObject>> from(final BindingCodecTreeNode<?>
+ parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
final List<DataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
populateList(result, parentCodec, domChildNodes);
return result;
case UNKNOWN:
case VISIBLE_CONTAINER:
result.add(create(childCodec, domChildNode));
- default:
break;
+ default:
}
}
@Override
public DataObjectModification.ModificationType getModificationType() {
- switch(domData.getModificationType()) {
+ switch (domData.getModificationType()) {
case APPEARED:
case WRITE:
return DataObjectModification.ModificationType.WRITE;
@SuppressWarnings("unchecked")
@Override
- public <C extends ChildOf<? super T>> Collection<DataObjectModification<C>> getModifiedChildren(Class<C> childType) {
+ public <C extends ChildOf<? super T>> Collection<DataObjectModification<C>>
+ getModifiedChildren(Class<C> childType) {
List<DataObjectModification<C>> children = new ArrayList<>();
for (DataObjectModification<? extends DataObject> potential : getModifiedChildren()) {
if (childType.isAssignableFrom(potential.getDataType())) {
@Override
@SuppressWarnings("unchecked")
- public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(
- final Class<C> listItem, final K listKey) {
- return (DataObjectModification<C>) getModifiedChild(new InstanceIdentifier.IdentifiableItem<>(listItem, listKey));
+ public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C>
+ getModifiedChildListItem(final Class<C> listItem, final K listKey) {
+ return (DataObjectModification<C>) getModifiedChild(new InstanceIdentifier.IdentifiableItem<>(
+ listItem, listKey));
}
@Override
/**
* Lazily translated {@link DataTreeModification} based on {@link DataTreeCandidate}.
*
+ * <p>
* {@link DataTreeModification} represents Data tree change event,
* but whole tree is not translated or resolved eagerly, but only child nodes
* which are directly accessed by user of data object modification.
}
@SuppressWarnings({"unchecked", "rawtypes"})
- static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec, final DataTreeCandidate domChange,
- final LogicalDatastoreType datastoreType) {
+ static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec,
+ final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) {
final Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> codecCtx =
codec.getSubtreeCodec(domChange.getRootPath());
final DataTreeIdentifier<?> path = DataTreeIdentifier.create(datastoreType, codecCtx.getKey());
return new LazyDataTreeModification(path, modification);
}
- static <T extends DataObject> Collection<DataTreeModification<T>> from(final BindingToNormalizedNodeCodec codec,
- final Collection<DataTreeCandidate> domChanges, final LogicalDatastoreType datastoreType) {
- final List<DataTreeModification<T>> result = new ArrayList<>(domChanges.size());
- for (final DataTreeCandidate domChange : domChanges) {
- result.add(LazyDataTreeModification.<T>create(codec, domChange, datastoreType));
- }
- return result;
- }
-
@SuppressWarnings({"unchecked", "rawtypes"})
static <T extends DataObject> DataTreeModification<T> create(BindingToNormalizedNodeCodec codec,
DOMDataTreeCandidate candidate) {
return new LazyDataTreeModification(path, modification);
}
+ static <T extends DataObject> Collection<DataTreeModification<T>> from(final BindingToNormalizedNodeCodec codec,
+ final Collection<DataTreeCandidate> domChanges, final LogicalDatastoreType datastoreType) {
+ final List<DataTreeModification<T>> result = new ArrayList<>(domChanges.size());
+ for (final DataTreeCandidate domChange : domChanges) {
+ result.add(LazyDataTreeModification.<T>create(codec, domChange, datastoreType));
+ }
+ return result;
+ }
+
}
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
- *
- * FIXME: Should this be moved to binding-data-codec?
+ * FIXME: Should this be moved to binding-data-codec.
*
*/
class LazySerializedContainerNode implements ContainerNode {
/**
* Lazy serialized implementation of DOM Notification.
*
+ * <p>
* This implementation performs serialization of data, only if receiver
* of notification actually accessed data from notification.
*
private ContainerNode domBody;
- private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data, final SchemaPath type) {
+ private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec,
+ final Notification data, final SchemaPath type) {
super();
this.codec = codec;
this.data = data;
package org.opendaylight.mdsal.binding.dom.adapter;
-import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
-
-import org.opendaylight.mdsal.dom.api.DOMRpcException;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map.Entry;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
private ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
final CheckedFuture<DOMRpcResult, DOMRpcException> result = delegate.invokeRpc(schemaPath, input);
- if(result instanceof LazyDOMRpcResultFuture) {
+ if (result instanceof LazyDOMRpcResultFuture) {
return ((LazyDOMRpcResultFuture) result).getBindingFuture();
}
throw new UnsupportedOperationException("Method " + method.toString() + "is unsupported.");
}
- private static boolean isObjectMethod(final Method m) {
- switch (m.getName()) {
+ private static boolean isObjectMethod(final Method method) {
+ switch (method.getName()) {
case "toString":
- return (m.getReturnType().equals(String.class) && m.getParameterTypes().length == 0);
+ return (method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0);
case "hashCode":
- return (m.getReturnType().equals(int.class) && m.getParameterTypes().length == 0);
+ return (method.getReturnType().equals(int.class) && method.getParameterTypes().length == 0);
case "equals":
- return (m.getReturnType().equals(boolean.class) && m.getParameterTypes().length == 1 && m
+ return (method.getReturnType().equals(boolean.class) && method.getParameterTypes().length == 1 && method
.getParameterTypes()[0] == Object.class);
default:
return false;
}
}
- private Object callObjectMethod(final Object self, final Method m, final Object[] args) {
- switch (m.getName()) {
+ private Object callObjectMethod(final Object self, final Method method, final Object[] args) {
+ switch (method.getName()) {
case "toString":
return type.getName() + "$Adapter{delegate=" + delegate.toString() + "}";
case "hashCode":
@Test
public void createChainTest() throws Exception {
- bindingDOMDataBrokerAdapter = (BindingDOMDataBrokerAdapter) bindingDOMAdapterLoader.load(DataBroker.class).get();
+ bindingDOMDataBrokerAdapter
+ = (BindingDOMDataBrokerAdapter) bindingDOMAdapterLoader.load(DataBroker.class).get();
assertNotNull(bindingDOMDataBrokerAdapter.createTransactionChain(null));
}
@Test(expected = UnsupportedOperationException.class)
public void registerWithException() throws Exception {
- bindingDOMDataBrokerAdapter = (BindingDOMDataBrokerAdapter) bindingDOMAdapterLoader.load(DataBroker.class).get();
+ bindingDOMDataBrokerAdapter
+ = (BindingDOMDataBrokerAdapter) bindingDOMAdapterLoader.load(DataBroker.class).get();
bindingDOMDataBrokerAdapter.registerDataTreeChangeListener(null,null);
}
}
\ No newline at end of file
@Test
public void basicTest() throws Exception {
final DataTreeIdentifier identifier =
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(DataObject.class));
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(DataObject.class));
final DOMDataTreeWriteCursor delegate = mock(DOMDataTreeWriteCursor.class);
final BindingNormalizedNodeCodecRegistry registry = mock(BindingNormalizedNodeCodecRegistry.class);
final BindingToNormalizedNodeCodec codec =
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import org.opendaylight.mdsal.binding.dom.adapter.ContextReferenceExtractor;
-
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder;
final InstanceIdentifier<?> extractedValue = extractor.extract(TEST_GROUPING);
assertSame(TEST_ROUTE,extractedValue);
}
- }
+}
assertNotNull(lazyDOMRpcResultFuture.get());
}
+ @SuppressWarnings({"checkstyle:IllegalThrows","checkstyle:IllegalCatch"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException() throws Throwable {
doThrow(InterruptedException.class).when(future).get();
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows","checkstyle:IllegalCatch"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException2() throws Throwable {
doThrow(InterruptedException.class).when(future).get(1, TimeUnit.SECONDS);
assertTrue(lazySerializedContainerNode.getAttributes().isEmpty());
assertTrue(lazySerializedContainerNode.getValue().isEmpty());
- assertEquals(lazySerializedContainerNode.getIdentifier().getNodeType(), lazySerializedContainerNode.getNodeType());
+ assertEquals(lazySerializedContainerNode.getIdentifier().getNodeType(),
+ lazySerializedContainerNode.getNodeType());
assertEquals(rpcName.getLastComponent(), lazySerializedContainerNode.getIdentifier().getNodeType());
assertNull(lazySerializedContainerNode.getAttributeValue(null));
assertEquals(dataObject, lazySerializedContainerNode.bindingData());
public class RpcServiceAdapterTest {
+ @SuppressWarnings("checkstyle:IllegalThrows")
@Test
public void invoke() throws Throwable {
final BindingBrokerTestFactory bindingBrokerTestFactory = new BindingBrokerTestFactory();
private interface TestRpcService extends RpcService {
String toString();
+
int hashCode();
- boolean equals(Object o);
+
+ boolean equals(Object object);
}
}
\ No newline at end of file
*/
package org.opendaylight.mdsal.binding.dom.adapter.test;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-
-import org.opendaylight.mdsal.binding.api.DataBroker;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.util.concurrent.ListenableFuture;
public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
// Intentionally left No-op, subclasses may customize it
}
- protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
return new DataBrokerTestCustomizer();
}
*/
package org.opendaylight.mdsal.binding.dom.adapter.test;
-import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter;
-
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
+import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class AbstractNotificationBrokerTest extends AbstractSchemaAwareTest{
+public class AbstractNotificationBrokerTest extends AbstractSchemaAwareTest {
private BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec;
private DOMNotificationRouter domNotificationRouter;
private NotificationService notificationService;
}
- public static void assertNotContains(final Collection<?> set, final Object... values) {
+ public static void assertContains(final Map<?,?> map, final Object... values) {
for (Object key : values) {
- Assert.assertFalse(set.contains(key));
+ Assert.assertTrue(map.containsKey(key));
}
}
- public static void assertContains(final Map<?,?> map, final Object... values) {
+ public static void assertNotContains(final Collection<?> set, final Object... values) {
for (Object key : values) {
- Assert.assertTrue(map.containsKey(key));
+ Assert.assertFalse(set.contains(key));
}
}
Assert.assertFalse(map.containsKey(key));
}
}
+
+
+
}
package org.opendaylight.mdsal.binding.dom.adapter.test;
import static org.junit.Assert.assertTrue;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
+
import javassist.ClassPool;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
.builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).toInstance();
- private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
- private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
+ private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY
+ = BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
+ private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES
+ = BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
- private BindingToNormalizedNodeCodec codec;
+ private BindingToNormalizedNodeCodec codec;
@Override
protected void setupWithSchema(final SchemaContext context) {
- final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
+ final DataObjectSerializerGenerator streamWriter
+ = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(streamWriter);
codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry);
codec.onGlobalContextUpdated(context);
- };
+ }
@Test
public void testComplexAugmentationSerialization() {
@Test
public void testBug5224() throws Exception {
- final BindingToNormalizedNodeCodec mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+ final BindingToNormalizedNodeCodec mappingService = new BindingToNormalizedNodeCodec(
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(
+ StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Module4Main.class));
mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
new ContainerModule4Builder().setListModule11(Collections.singletonList(
new ListModule11Builder().setListModule12(Collections.singletonList(
new ListModule12Builder().setContainerModule1(
- new ContainerModule1Builder().addAugmentation(ContainerModule11.class, new ContainerModule11Builder().build()).build())
- .build())).build())).build()).build();
+ new ContainerModule1Builder().addAugmentation(ContainerModule11.class,
+ new ContainerModule11Builder().build()).build())
+ .build())).build())).build()).build();
final Module4Main manualModule4Main = new Module4MainBuilder().setContainerModule4(
new ContainerModule4Builder().setManualListModule11(Collections.singletonList(
new ManualListModule11Builder().setManualListModule12(Collections.singletonList(
new ManualListModule12Builder().setManualContainerModule1(
- new ManualContainerModule1Builder().addAugmentation(ManualContainerModule11.class, new ManualContainerModule11Builder().build()).build())
- .build())).build())).build()).build();
+ new ManualContainerModule1Builder().addAugmentation(
+ ManualContainerModule11.class, new ManualContainerModule11Builder()
+ .build()).build()).build())).build())).build()).build();
final Module4Main contManualModule4Main = new Module4MainBuilder().setContainerModule4(
new ContainerModule4Builder().setContainerManualListModule11(Collections.singletonList(
- new ContainerManualListModule11Builder().setContainerManualListModule12(Collections.singletonList(
+ new ContainerManualListModule11Builder().setContainerManualListModule12(
+ Collections.singletonList(
new ContainerManualListModule12Builder().setContainerManualContainerModule1(
- new ContainerManualContainerModule1Builder().setContainerManualContainerModule2
- (new ContainerManualContainerModule2Builder().build()).build())
+ new ContainerManualContainerModule1Builder().setContainerManualContainerModule2(
+ new ContainerManualContainerModule2Builder().build()).build())
.build())).build())).build()).build();
final BindingCodecTree codecContext = mappingService.getCodecFactory().getCodecContext();
- final BindingCodecTreeNode<Module4Main> subtreeCodec = codecContext.getSubtreeCodec(InstanceIdentifier.create(Module4Main.class));
+ final BindingCodecTreeNode<Module4Main> subtreeCodec = codecContext.getSubtreeCodec(
+ InstanceIdentifier.create(Module4Main.class));
final NormalizedNode<?, ?> serialized = subtreeCodec.serialize(module4Main);
final NormalizedNode<?, ?> manualSerialized = subtreeCodec.serialize(manualModule4Main);
final NormalizedNode<?, ?> containerManualSerialized = subtreeCodec.serialize(contManualModule4Main);
@Test
public void testBug5845() throws Exception {
- final BindingToNormalizedNodeCodec mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+ final BindingToNormalizedNodeCodec mappingService = new BindingToNormalizedNodeCodec(
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(
+ StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BooleanContainer.class));
mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
.build();
final BindingCodecTree codecContext = mappingService.getCodecFactory().getCodecContext();
- final BindingCodecTreeNode<BooleanContainer> subtreeCodec = codecContext.getSubtreeCodec(InstanceIdentifier.create(BooleanContainer.class));
+ final BindingCodecTreeNode<BooleanContainer> subtreeCodec = codecContext.getSubtreeCodec(
+ InstanceIdentifier.create(BooleanContainer.class));
final NormalizedNode<?, ?> serializedInt = subtreeCodec.serialize(booleanContainerInt);
assertNotNull(serializedInt);
final NormalizedNode<?, ?> serialized = subtreeCodec.serialize(booleanContainer);
*/
package org.opendaylight.mdsal.binding.dom.adapter.test;
-import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
-
-import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMNotificationServiceAdapter;
import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
import org.opendaylight.mdsal.binding.dom.adapter.test.util.MockSchemaService;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter;
import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
}
private DOMDataBroker getDOMDataBroker() {
- if(domDataBroker == null) {
+ if (domDataBroker == null) {
domDataBroker = createDOMDataBroker();
}
return domDataBroker;
public class DataTreeChangeListenerTest extends AbstractDataBrokerTest {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
- private static final PathArgument TOP_ARGUMENT= TOP_PATH.getPathArguments().iterator().next();
+ private static final PathArgument TOP_ARGUMENT = TOP_PATH.getPathArguments().iterator().next();
private static final InstanceIdentifier<TopLevelList> FOO_PATH = path(TOP_FOO_KEY);
private static final PathArgument FOO_ARGUMENT = Iterables.getLast(FOO_PATH.getPathArguments());
private static final TopLevelList FOO_DATA = topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY));
private static final InstanceIdentifier<TopLevelList> BAR_PATH = path(TOP_BAR_KEY);
private static final PathArgument BAR_ARGUMENT = Iterables.getLast(BAR_PATH.getPathArguments());
private static final TopLevelList BAR_DATA = topLevelList(TOP_BAR_KEY);
- private static final DataTreeIdentifier<Top> TOP_IDENTIFIER = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
- TOP_PATH);
+ private static final DataTreeIdentifier<Top> TOP_IDENTIFIER
+ = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, TOP_PATH);
private static final Top TOP_INITIAL_DATA = top(FOO_DATA);
createAndVerifyTop(listener);
putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
- final DataObjectModification<Top> afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
+ final DataObjectModification<Top> afterBarPutEvent
+ = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
verifyModification(afterBarPutEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
+ final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent.getModifiedChildListItem(
+ TopLevelList.class, TOP_BAR_KEY);
assertNotNull(barPutMod);
verifyModification(barPutMod, BAR_ARGUMENT, ModificationType.WRITE);
deleteTx(BAR_PATH).submit().checkedGet();
- final DataObjectModification<Top> afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
+ final DataObjectModification<Top> afterBarDeleteEvent
+ = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
verifyModification(afterBarDeleteEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
+ final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent.getModifiedChildListItem(
+ TopLevelList.class, TOP_BAR_KEY);
verifyModification(barDeleteMod, BAR_ARGUMENT, ModificationType.DELETE);
dataBrokerImpl.registerDataTreeChangeListener(TOP_IDENTIFIER, listener).close();
@Test
public void testWildcardedListListener() throws Exception {
final EventCapturingListener<TopLevelList> listener = new EventCapturingListener<>();
- final DataTreeIdentifier<TopLevelList> wildcard = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
+ final DataTreeIdentifier<TopLevelList> wildcard = DataTreeIdentifier.create(
+ LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener);
putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet();
assertEquals(TOP_INITIAL_DATA, initialNode.getDataAfter());
}
- private void verifyModification(final DataObjectModification<? extends DataObject> barWrite, final PathArgument pathArg,
- final ModificationType eventType) {
+ private void verifyModification(final DataObjectModification<? extends DataObject> barWrite,
+ final PathArgument pathArg, final ModificationType eventType) {
assertEquals(pathArg.getType(), barWrite.getDataType());
assertEquals(eventType,barWrite.getModificationType());
assertEquals(pathArg, barWrite.getIdentifier());
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.concurrent.TimeoutException;
import org.junit.Assert;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.OpendaylightMdsalBindingTestListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
private final CountDownLatch latch;
- public TestNotifListener(final CountDownLatch latch) {
+ TestNotifListener(final CountDownLatch latch) {
this.latch = latch;
}
public class LeafDefaultValueTest extends AbstractDataBrokerTest {
- private static final InstanceIdentifier<TinyIntContainer> TINY_INT_NODE_PATH = InstanceIdentifier.create
- (TinyIntContainer.class);
- private static final InstanceIdentifier<SmallIntContainer> SMALL_INT_NODE_PATH = InstanceIdentifier.create
- (SmallIntContainer.class);
- private static final InstanceIdentifier<NormalIntContainer> NORMAL_INT_NODE_PATH = InstanceIdentifier.create
- (NormalIntContainer.class);
- private static final InstanceIdentifier<BigIntContainer> BIG_INT_NODE_PATH = InstanceIdentifier.create
- (BigIntContainer.class);
+ private static final InstanceIdentifier<TinyIntContainer> TINY_INT_NODE_PATH
+ = InstanceIdentifier.create(TinyIntContainer.class);
+ private static final InstanceIdentifier<SmallIntContainer> SMALL_INT_NODE_PATH
+ = InstanceIdentifier.create(SmallIntContainer.class);
+ private static final InstanceIdentifier<NormalIntContainer> NORMAL_INT_NODE_PATH
+ = InstanceIdentifier.create(NormalIntContainer.class);
+ private static final InstanceIdentifier<BigIntContainer> BIG_INT_NODE_PATH
+ = InstanceIdentifier.create(BigIntContainer.class);
- private static final InstanceIdentifier<TinyUintContainer> TINY_UINT_NODE_PATH = InstanceIdentifier.create
- (TinyUintContainer.class);
- private static final InstanceIdentifier<SmallUintContainer> SMALL_UINT_NODE_PATH = InstanceIdentifier.create
- (SmallUintContainer.class);
- private static final InstanceIdentifier<NormalUintContainer> NORMAL_UINT_NODE_PATH = InstanceIdentifier.create
- (NormalUintContainer.class);
- private static final InstanceIdentifier<BigUintContainer> BIG_UINT_NODE_PATH = InstanceIdentifier.create
- (BigUintContainer.class);
+ private static final InstanceIdentifier<TinyUintContainer> TINY_UINT_NODE_PATH
+ = InstanceIdentifier.create(TinyUintContainer.class);
+ private static final InstanceIdentifier<SmallUintContainer> SMALL_UINT_NODE_PATH
+ = InstanceIdentifier.create(SmallUintContainer.class);
+ private static final InstanceIdentifier<NormalUintContainer> NORMAL_UINT_NODE_PATH
+ = InstanceIdentifier.create(NormalUintContainer.class);
+ private static final InstanceIdentifier<BigUintContainer> BIG_UINT_NODE_PATH
+ = InstanceIdentifier.create(BigUintContainer.class);
- private static final InstanceIdentifier<DecimalContainer> DECIMAL_NODE_PATH = InstanceIdentifier.create
- (DecimalContainer.class);
+ private static final InstanceIdentifier<DecimalContainer> DECIMAL_NODE_PATH
+ = InstanceIdentifier.create(DecimalContainer.class);
- private static final InstanceIdentifier<StringContainer> STRING_NODE_PATH = InstanceIdentifier.create
- (StringContainer.class);
+ private static final InstanceIdentifier<StringContainer> STRING_NODE_PATH
+ = InstanceIdentifier.create(StringContainer.class);
- private static final InstanceIdentifier<BooleanContainer> BOOLEAN_NODE_PATH = InstanceIdentifier.create
- (BooleanContainer.class);
+ private static final InstanceIdentifier<BooleanContainer> BOOLEAN_NODE_PATH
+ = InstanceIdentifier.create(BooleanContainer.class);
- private static final InstanceIdentifier<EnumContainer> ENUM_NODE_PATH = InstanceIdentifier.create(EnumContainer
- .class);
+ private static final InstanceIdentifier<EnumContainer> ENUM_NODE_PATH
+ = InstanceIdentifier.create(EnumContainer.class);
- private static final InstanceIdentifier<BitsContainer> BITS_NODE_PATH = InstanceIdentifier.create(BitsContainer
- .class);
+ private static final InstanceIdentifier<BitsContainer> BITS_NODE_PATH
+ = InstanceIdentifier.create(BitsContainer.class);
- private static final InstanceIdentifier<BinaryContainer> BINARY_NODE_PATH = InstanceIdentifier.create
- (BinaryContainer.class);
+ private static final InstanceIdentifier<BinaryContainer> BINARY_NODE_PATH
+ = InstanceIdentifier.create(BinaryContainer.class);
- private static final InstanceIdentifier<IdentityrefContainer> IDENTITYREF_NODE_PATH = InstanceIdentifier.create
- (IdentityrefContainer.class);
+ private static final InstanceIdentifier<IdentityrefContainer> IDENTITYREF_NODE_PATH
+ = InstanceIdentifier.create(IdentityrefContainer.class);
@Test
- public void testTinyIntDefaultValue() throws ExecutionException, InterruptedException, TransactionCommitFailedException {
+ public void testTinyIntDefaultValue() throws ExecutionException, InterruptedException,
+ TransactionCommitFailedException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, TINY_INT_NODE_PATH, new TinyIntContainerBuilder().build());
writeTx.submit().checkedGet();
assertTrue(tinyIntContainerNode.isPresent());
- TinyIntContainer tIntCont = tinyIntContainerNode.get();
- assertEquals(-18, tIntCont.getTinyIntLeaf().getValue().byteValue());
- assertEquals(-18, tIntCont.getTinyIntLeaf2().getValue().byteValue());
- assertEquals(-15, tIntCont.getTinyIntLeaf3().getValue().byteValue());
- assertEquals(-18, tIntCont.getTinyIntLeaf4().getValue().byteValue());
- assertEquals(-120, tIntCont.getTinyIntLeaf5().byteValue());
- assertEquals(null, tIntCont.getTinyIntLeaf6());
+ TinyIntContainer tinyIntContainer = tinyIntContainerNode.get();
+ assertEquals(-18, tinyIntContainer.getTinyIntLeaf().getValue().byteValue());
+ assertEquals(-18, tinyIntContainer.getTinyIntLeaf2().getValue().byteValue());
+ assertEquals(-15, tinyIntContainer.getTinyIntLeaf3().getValue().byteValue());
+ assertEquals(-18, tinyIntContainer.getTinyIntLeaf4().getValue().byteValue());
+ assertEquals(-120, tinyIntContainer.getTinyIntLeaf5().byteValue());
+ assertEquals(null, tinyIntContainer.getTinyIntLeaf6());
}
@Test
- public void testSmallIntDefaultValue() throws ExecutionException, InterruptedException, TransactionCommitFailedException {
+ public void testSmallIntDefaultValue() throws ExecutionException, InterruptedException,
+ TransactionCommitFailedException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, SMALL_INT_NODE_PATH, new SmallIntContainerBuilder().build());
writeTx.submit().checkedGet();
assertTrue(smallIntContainerNode.isPresent());
- SmallIntContainer sIntCont = smallIntContainerNode.get();
- assertEquals(-20000, sIntCont.getSmallIntLeaf().getValue().shortValue());
- assertEquals(-20000, sIntCont.getSmallIntLeaf2().getValue().shortValue());
- assertEquals(-15000, sIntCont.getSmallIntLeaf3().getValue().shortValue());
- assertEquals(-20000, sIntCont.getSmallIntLeaf4().getValue().shortValue());
- assertEquals(-5000, sIntCont.getSmallIntLeaf5().shortValue());
- assertEquals(null, sIntCont.getSmallIntLeaf6());
+ SmallIntContainer smallIntContainer = smallIntContainerNode.get();
+ assertEquals(-20000, smallIntContainer.getSmallIntLeaf().getValue().shortValue());
+ assertEquals(-20000, smallIntContainer.getSmallIntLeaf2().getValue().shortValue());
+ assertEquals(-15000, smallIntContainer.getSmallIntLeaf3().getValue().shortValue());
+ assertEquals(-20000, smallIntContainer.getSmallIntLeaf4().getValue().shortValue());
+ assertEquals(-5000, smallIntContainer.getSmallIntLeaf5().shortValue());
+ assertEquals(null, smallIntContainer.getSmallIntLeaf6());
}
@Test
assertTrue(normalIntContainerNode.isPresent());
- NormalIntContainer nIntCont = normalIntContainerNode.get();
- assertEquals(-200000, nIntCont.getNormalIntLeaf().getValue().intValue());
- assertEquals(-200000, nIntCont.getNormalIntLeaf2().getValue().intValue());
- assertEquals(-130000, nIntCont.getNormalIntLeaf3().getValue().intValue());
- assertEquals(-200000, nIntCont.getNormalIntLeaf4().getValue().intValue());
- assertEquals(-95000, nIntCont.getNormalIntLeaf5().intValue());
- assertEquals(null, nIntCont.getNormalIntLeaf6());
+ NormalIntContainer normalIntContainer = normalIntContainerNode.get();
+ assertEquals(-200000, normalIntContainer.getNormalIntLeaf().getValue().intValue());
+ assertEquals(-200000, normalIntContainer.getNormalIntLeaf2().getValue().intValue());
+ assertEquals(-130000, normalIntContainer.getNormalIntLeaf3().getValue().intValue());
+ assertEquals(-200000, normalIntContainer.getNormalIntLeaf4().getValue().intValue());
+ assertEquals(-95000, normalIntContainer.getNormalIntLeaf5().intValue());
+ assertEquals(null, normalIntContainer.getNormalIntLeaf6());
}
@Test
assertTrue(bigIntContainerNode.isPresent());
- BigIntContainer bIntCont = bigIntContainerNode.get();
- assertEquals(-3300000000L, bIntCont.getBigIntLeaf().getValue().longValue());
- assertEquals(-3300000000L, bIntCont.getBigIntLeaf2().getValue().longValue());
- assertEquals(-2800000000L, bIntCont.getBigIntLeaf3().getValue().longValue());
- assertEquals(-3300000000L, bIntCont.getBigIntLeaf4().getValue().longValue());
- assertEquals(-2500000000L, bIntCont.getBigIntLeaf5().longValue());
- assertEquals(null, bIntCont.getBigIntLeaf6());
+ BigIntContainer bigIntContainer = bigIntContainerNode.get();
+ assertEquals(-3300000000L, bigIntContainer.getBigIntLeaf().getValue().longValue());
+ assertEquals(-3300000000L, bigIntContainer.getBigIntLeaf2().getValue().longValue());
+ assertEquals(-2800000000L, bigIntContainer.getBigIntLeaf3().getValue().longValue());
+ assertEquals(-3300000000L, bigIntContainer.getBigIntLeaf4().getValue().longValue());
+ assertEquals(-2500000000L, bigIntContainer.getBigIntLeaf5().longValue());
+ assertEquals(null, bigIntContainer.getBigIntLeaf6());
}
@Test
assertTrue(tinyUintContainerNode.isPresent());
- TinyUintContainer tUintCont = tinyUintContainerNode.get();
- assertEquals(150, tUintCont.getTinyUintLeaf().getValue().shortValue());
- assertEquals(150, tUintCont.getTinyUintLeaf2().getValue().shortValue());
- assertEquals(170, tUintCont.getTinyUintLeaf3().getValue().shortValue());
- assertEquals(150, tUintCont.getTinyUintLeaf4().getValue().shortValue());
- assertEquals(155, tUintCont.getTinyUintLeaf5().shortValue());
- assertEquals(null, tUintCont.getTinyUintLeaf6());
+ TinyUintContainer tinyUintContainer = tinyUintContainerNode.get();
+ assertEquals(150, tinyUintContainer.getTinyUintLeaf().getValue().shortValue());
+ assertEquals(150, tinyUintContainer.getTinyUintLeaf2().getValue().shortValue());
+ assertEquals(170, tinyUintContainer.getTinyUintLeaf3().getValue().shortValue());
+ assertEquals(150, tinyUintContainer.getTinyUintLeaf4().getValue().shortValue());
+ assertEquals(155, tinyUintContainer.getTinyUintLeaf5().shortValue());
+ assertEquals(null, tinyUintContainer.getTinyUintLeaf6());
}
@Test
assertTrue(smallUintContainerNode.isPresent());
- SmallUintContainer sUintCont = smallUintContainerNode.get();
- assertEquals(35000, sUintCont.getSmallUintLeaf().getValue().intValue());
- assertEquals(35000, sUintCont.getSmallUintLeaf2().getValue().intValue());
- assertEquals(45000, sUintCont.getSmallUintLeaf3().getValue().intValue());
- assertEquals(35000, sUintCont.getSmallUintLeaf4().getValue().intValue());
- assertEquals(62000, sUintCont.getSmallUintLeaf5().intValue());
- assertEquals(null, sUintCont.getSmallUintLeaf6());
+ SmallUintContainer smallUintContainer = smallUintContainerNode.get();
+ assertEquals(35000, smallUintContainer.getSmallUintLeaf().getValue().intValue());
+ assertEquals(35000, smallUintContainer.getSmallUintLeaf2().getValue().intValue());
+ assertEquals(45000, smallUintContainer.getSmallUintLeaf3().getValue().intValue());
+ assertEquals(35000, smallUintContainer.getSmallUintLeaf4().getValue().intValue());
+ assertEquals(62000, smallUintContainer.getSmallUintLeaf5().intValue());
+ assertEquals(null, smallUintContainer.getSmallUintLeaf6());
}
@Test
assertTrue(normalUintContainerNode.isPresent());
- NormalUintContainer nUintCont = normalUintContainerNode.get();
- assertEquals(100000, nUintCont.getNormalUintLeaf().getValue().longValue());
- assertEquals(100000, nUintCont.getNormalUintLeaf2().getValue().longValue());
- assertEquals(250000, nUintCont.getNormalUintLeaf3().getValue().longValue());
- assertEquals(100000, nUintCont.getNormalUintLeaf4().getValue().longValue());
- assertEquals(150000, nUintCont.getNormalUintLeaf5().longValue());
- assertEquals(null, nUintCont.getNormalUintLeaf6());
+ NormalUintContainer normalUintContainer = normalUintContainerNode.get();
+ assertEquals(100000, normalUintContainer.getNormalUintLeaf().getValue().longValue());
+ assertEquals(100000, normalUintContainer.getNormalUintLeaf2().getValue().longValue());
+ assertEquals(250000, normalUintContainer.getNormalUintLeaf3().getValue().longValue());
+ assertEquals(100000, normalUintContainer.getNormalUintLeaf4().getValue().longValue());
+ assertEquals(150000, normalUintContainer.getNormalUintLeaf5().longValue());
+ assertEquals(null, normalUintContainer.getNormalUintLeaf6());
}
@Test
assertTrue(bigUintContainerNode.isPresent());
- BigUintContainer bUintCont = bigUintContainerNode.get();
- assertEquals(5000000000L, bUintCont.getBigUintLeaf().getValue().longValue());
- assertEquals(5000000000L, bUintCont.getBigUintLeaf2().getValue().longValue());
- assertEquals(5800000000L, bUintCont.getBigUintLeaf3().getValue().longValue());
- assertEquals(5000000000L, bUintCont.getBigUintLeaf4().getValue().longValue());
- assertEquals(6500000000L, bUintCont.getBigUintLeaf5().longValue());
- assertEquals(null, bUintCont.getBigUintLeaf6());
+ BigUintContainer bigUintContainer = bigUintContainerNode.get();
+ assertEquals(5000000000L, bigUintContainer.getBigUintLeaf().getValue().longValue());
+ assertEquals(5000000000L, bigUintContainer.getBigUintLeaf2().getValue().longValue());
+ assertEquals(5800000000L, bigUintContainer.getBigUintLeaf3().getValue().longValue());
+ assertEquals(5000000000L, bigUintContainer.getBigUintLeaf4().getValue().longValue());
+ assertEquals(6500000000L, bigUintContainer.getBigUintLeaf5().longValue());
+ assertEquals(null, bigUintContainer.getBigUintLeaf6());
}
@Test
import static org.junit.Assert.assertTrue;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
import com.google.common.base.Optional;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
public class WriteTransactionTest extends AbstractDataBrokerTest {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
+
@Test
public void test() throws InterruptedException, ExecutionException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
}
@Test
- public void testPutCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+ public void testPutCreateParentsSuccess() throws TransactionCommitFailedException,
+ InterruptedException, ExecutionException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
}
@Test
- public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+ public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException,
+ InterruptedException, ExecutionException {
final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
*/
package org.opendaylight.mdsal.binding.dom.adapter.test.util;
-import java.util.concurrent.ExecutorService;
-
-import javassist.ClassPool;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.ExecutorService;
+import javassist.ClassPool;
@Beta
public class BindingBrokerTestFactory {
}
public ClassPool getClassPool() {
- if(classPool == null) {
+ if (classPool == null) {
return CLASS_POOL;
}
return codec;
}
- protected BindingTestContext(final ListeningExecutorService executor, final ClassPool classPool, final boolean startWithSchema) {
+ protected BindingTestContext(final ListeningExecutorService executor,
+ final ClassPool classPool, final boolean startWithSchema) {
this.executor = executor;
this.classPool = classPool;
this.startWithSchema = startWithSchema;
public void startBindingToDomMappingService() {
checkState(classPool != null, "ClassPool needs to be present");
- final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(classPool));
+ final DataObjectSerializerGenerator generator
+ = StreamWriterGenerator.create(JavassistUtils.forClassPool(classPool));
final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
codec = new BindingToNormalizedNodeCodec(loading, codecRegistry);