import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
}
private @Nullable T loadDataBefore() {
- final var computed = deserialize(domData.getDataBefore());
+ final var computed = deserializeNullable(domData.dataBefore());
final var witness = DATA_BEFORE.compareAndExchangeRelease(this, null, mask(computed));
return witness == null ? computed : unmask(witness);
}
}
private @Nullable T loadDataAfter() {
- final var computed = deserialize(domData.getDataAfter());
+ final var computed = deserializeNullable(domData.dataAfter());
final var witness = DATA_AFTER.compareAndExchangeRelease(this, null, mask(computed));
return witness == null ? computed : unmask(witness);
}
return obj == NULL_DATA_OBJECT ? null : (T) verifyNotNull(obj);
}
- private @Nullable T deserialize(final Optional<NormalizedNode> normalized) {
- return normalized.isEmpty() ? null : deserialize(normalized.orElseThrow());
+ private @Nullable T deserializeNullable(final @Nullable NormalizedNode normalized) {
+ return normalized == null ? null : deserialize(normalized);
}
abstract @Nullable T deserialize(@NonNull NormalizedNode normalized);
var current = toEnter.hasNext() ? firstModifiedChild(toEnter.next()) : domData;
// ... and for everything else we can just go wild
while (toEnter.hasNext() && current != null) {
- current = current.getModifiedChild(toEnter.next()).orElse(null);
+ current = current.modifiedChild(toEnter.next());
}
- if (current == null || current.getModificationType() == UNMODIFIED) {
+ if (current == null || current.modificationType() == UNMODIFIED) {
return null;
}
return from(childCodec, current);
final var augmentChildren =
ArrayListMultimap.<BindingAugmentationCodecTreeNode<?>, DataTreeCandidateNode>create();
- for (var domChildNode : parent.getChildNodes()) {
- if (domChildNode.getModificationType() != UNMODIFIED) {
+ for (var domChildNode : parent.childNodes()) {
+ if (domChildNode.modificationType() != UNMODIFIED) {
final var type = BindingStructuralType.from(domChildNode);
if (type != BindingStructuralType.NOT_ADDRESSABLE) {
/*
* We will use that type to further specify debug log.
*/
try {
- final var childCodec = parentCodec.yangPathArgumentChild(domChildNode.getIdentifier());
+ final var childCodec = parentCodec.yangPathArgumentChild(domChildNode.name());
if (childCodec instanceof BindingDataObjectCodecTreeNode<?> childDataObjectCodec) {
populateList(result, type, childDataObjectCodec, domChildNode);
} else if (childCodec instanceof BindingAugmentationCodecTreeNode<?> childAugmentationCodec) {
switch (type) {
case INVISIBLE_LIST:
// We use parent codec intentionally.
- populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes());
+ populateListWithSingleCodec(result, childCodec, domChildNode.childNodes());
break;
case INVISIBLE_CONTAINER:
- populateList(result, childCodec, domChildNode, domChildNode.getChildNodes());
+ populateList(result, childCodec, domChildNode, domChildNode.childNodes());
break;
case UNKNOWN:
case VISIBLE_CONTAINER:
final ImmutableList.Builder<AbstractDataObjectModification<?, ?>> result,
final BindingDataObjectCodecTreeNode<?> codec, final Collection<DataTreeCandidateNode> childNodes) {
for (var child : childNodes) {
- if (child.getModificationType() != UNMODIFIED) {
+ if (child.modificationType() != UNMODIFIED) {
result.add(new LazyDataObjectModification<>(codec, child));
}
}
final Collection<DataTreeCandidateNode> children) {
// Filter out any unmodified children first
final var domChildren = children.stream()
- .filter(childMod -> childMod.getModificationType() != UNMODIFIED)
+ .filter(childMod -> childMod.modificationType() != UNMODIFIED)
.collect(ImmutableList.toImmutableList());
// Only return a modification if there is something left
return domChildren.isEmpty() ? null : new LazyAugmentationModification<>(codec, parent, domChildren);
final BindingAugmentationCodecTreeNode<A> codec, final DataTreeCandidateNode parent) {
final var builder = ImmutableList.<DataTreeCandidateNode>builder();
for (var pathArg : codec.childPathArguments()) {
- parent.getModifiedChild(pathArg).ifPresent(builder::add);
+ final var child = parent.modifiedChild(pathArg);
+ if (child != null) {
+ builder.add(child);
+ }
}
final var domChildren = builder.build();
return domChildren.isEmpty() ? null : new LazyAugmentationModification<>(codec, parent, domChildren);
DataTreeCandidateNode firstModifiedChild(final PathArgument arg) {
// Not entirely efficient linear search, but otherwise we'd have to index, which is even slower
return domChildNodes.stream()
- .filter(child -> arg.equals(child.getIdentifier()))
+ .filter(child -> arg.equals(child.name()))
.findFirst()
.orElse(null);
}
@Override
ToStringHelper addToStringAttributes(final ToStringHelper helper) {
return super.addToStringAttributes(helper)
- .add("domType", domData.getModificationType())
+ .add("domType", domData.modificationType())
.add("domChildren", domChildNodes);
}
}
final class LazyDataObjectModification<T extends DataObject>
extends AbstractDataObjectModification<T, BindingDataObjectCodecTreeNode<T>> {
LazyDataObjectModification(final BindingDataObjectCodecTreeNode<T> codec, final DataTreeCandidateNode domData) {
- super(domData, codec, codec.deserializePathArgument(domData.getIdentifier()));
+ super(domData, codec, codec.deserializePathArgument(domData.name()));
}
@Override
Collection<DataTreeCandidateNode> domChildNodes() {
- return domData.getChildNodes();
+ return domData.childNodes();
}
@Override
org.opendaylight.yangtools.yang.data.tree.api.ModificationType domModificationType() {
- return domData.getModificationType();
+ return domData.modificationType();
}
@Override
@Override
DataTreeCandidateNode firstModifiedChild(final PathArgument arg) {
- return domData.getModifiedChild(arg).orElse(null);
+ return domData.modifiedChild(arg);
}
@Override