package org.opendaylight.transportpce.test.converter;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
@Override
@SuppressWarnings("unchecked")
public <T extends DataObject> Optional<T> getDataObject(
- @Nonnull NormalizedNode normalizedNode,
- @Nonnull QName rootNode) {
+ @NonNull NormalizedNode normalizedNode,
+ @NonNull QName rootNode) {
//Preconditions.checkNotNull(normalizedNode);
if (normalizedNode instanceof ContainerNode) {
YangInstanceIdentifier.PathArgument directChildIdentifier =
if (!directChild.isPresent()) {
throw new IllegalStateException(String.format("Could not get the direct child of %s", rootNode));
}
- normalizedNode = directChild.get();
+ normalizedNode = directChild.orElseThrow();
}
YangInstanceIdentifier rootNodeYangInstanceIdentifier = YangInstanceIdentifier.of(rootNode);
@Override
@SuppressWarnings("unchecked")
- public <T extends DataObject> Optional<T> getDataObjectFromRpc(@Nonnull NormalizedNode normalizedNode) {
+ public <T extends DataObject> Optional<T> getDataObjectFromRpc(@NonNull NormalizedNode normalizedNode) {
if (! (normalizedNode instanceof ContainerNode)) {
LOG.error("converting normalized node is not ContainerNode. It's actual type is {}",
normalizedNode.getClass().getSimpleName());
return Optional.empty();
}
- T rpcDataObject = (T) codecRegistry.fromNormalizedNodeRpcData(
- Absolute.of(QName.create(schemaContext.getClass().getSimpleName())),
- (ContainerNode) normalizedNode);
+ T rpcDataObject = (T) codecRegistry
+ .fromNormalizedNodeRpcData(Absolute.of(EffectiveModelContext.NAME), (ContainerNode) normalizedNode);
return Optional.ofNullable(rpcDataObject);
}
@Override
- public <T extends DataObject> Optional<NormalizedNode> toNormalizedNodes(@Nonnull T object,
+ @SuppressWarnings({"rawtypes","unchecked"})
+ public <T extends DataObject> Optional<NormalizedNode> toNormalizedNodes(@NonNull T object,
Class dataObjectClass) {
- Entry<YangInstanceIdentifier, NormalizedNode> normalizedNode =
- codecRegistry.toNormalizedNode(InstanceIdentifier.create(dataObjectClass), object);
- return Optional.ofNullable(normalizedNode.getValue());
+ return Optional.of(codecRegistry.toNormalizedDataObject(InstanceIdentifier.create(dataObjectClass), object)
+ .node());
}
@Override
}
@Override
+ @SuppressWarnings("rawtypes")
public <T extends Notification> ConvertType<T> notification() {
return (object, objectClass) -> {
ContainerNode normalizedNodeNotification = getCodecRegistry().toNormalizedNodeNotification(object);