use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project controller by opendaylight.
the class LocalReadWriteProxyTransaction method flushState.
@Override
Optional<ModifyTransactionRequest> flushState() {
final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(getIdentifier(), localActor());
b.setSequence(0);
sealedModification.applyToCursor(new AbstractDataTreeModificationCursor() {
@Override
public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
b.addModification(new TransactionWrite(current().node(child), data));
}
@Override
public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
b.addModification(new TransactionMerge(current().node(child), data));
}
@Override
public void delete(final PathArgument child) {
b.addModification(new TransactionDelete(current().node(child)));
}
});
return Optional.of(b.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project controller by opendaylight.
the class DataNormalizer method toLegacy.
public YangInstanceIdentifier toLegacy(final YangInstanceIdentifier normalized) throws DataNormalizationException {
ImmutableList.Builder<PathArgument> legacyArgs = ImmutableList.builder();
DataNormalizationOperation<?> currentOp = operation;
for (PathArgument normalizedArg : normalized.getPathArguments()) {
currentOp = currentOp.getChild(normalizedArg);
if (!currentOp.isMixin()) {
legacyArgs.add(normalizedArg);
}
}
return YangInstanceIdentifier.create(legacyArgs.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project controller by opendaylight.
the class DataNormalizer method toNormalized.
public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) {
ImmutableList.Builder<PathArgument> normalizedArgs = ImmutableList.builder();
DataNormalizationOperation<?> currentOp = operation;
Iterator<PathArgument> arguments = legacy.getPathArguments().iterator();
try {
while (arguments.hasNext()) {
PathArgument legacyArg = arguments.next();
currentOp = currentOp.getChild(legacyArg);
checkArgument(currentOp != null, "Legacy Instance Identifier %s is not correct. Normalized Instance Identifier so far %s", legacy, normalizedArgs.build());
while (currentOp.isMixin()) {
normalizedArgs.add(currentOp.getIdentifier());
currentOp = currentOp.getChild(legacyArg.getNodeType());
}
normalizedArgs.add(legacyArg);
}
} catch (DataNormalizationException e) {
throw new IllegalArgumentException(String.format("Failed to normalize path %s", legacy), e);
}
return YangInstanceIdentifier.create(normalizedArgs.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project controller by opendaylight.
the class AbstractDOMBrokerWriteTransaction method checkInstanceIdentifierReferencesData.
private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
Preconditions.checkArgument(data != null, "Attempted to store null data at %s", path);
final PathArgument lastArg = path.getLastPathArgument();
Preconditions.checkArgument(lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()), "Instance identifier references %s but data identifier is %s", lastArg, data);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project controller by opendaylight.
the class BindingNormalizedCodecTest method testComplexAugmentationSerialization.
@Test
public void testComplexAugmentationSerialization() {
this.codec.onGlobalContextUpdated(this.context);
final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
assertTrue(lastArg instanceof AugmentationIdentifier);
}
Aggregations