import java.util.Collection;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.DataObjectStep;
import org.opendaylight.yangtools.yang.binding.ExactDataObjectStep;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Key;
import org.opendaylight.yangtools.yang.binding.KeyAware;
*
* @param <T> Type of modified object
*/
-public interface DataObjectModification<T extends DataObject> extends Identifiable<DataObjectStep<?>> {
+public interface DataObjectModification<T extends DataObject> {
/**
* Represents type of modification which has occurred.
*/
DELETE
}
- @Override
- DataObjectStep<?> getIdentifier();
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @NonNull ExactDataObjectStep<T> getIdentifier() {
+ return step();
+ }
+
+ /**
+ * Return the {@link InstanceIdentifier} step this modification corresponds to.
+ *
+ * @return the {@link InstanceIdentifier} step this modification corresponds to
+ */
+ @NonNull ExactDataObjectStep<T> step();
/**
* Returns type of modified object.
*
* @return type of modified object.
*/
- @NonNull Class<T> getDataType();
+ default @NonNull Class<T> dataType() {
+ return step().type();
+ }
+
+ /**
+ * Returns type of modified object.
+ *
+ * @return type of modified object.
+ * @deprecated Use {@link #dataType()} instead.
+ */
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @NonNull Class<T> getDataType() {
+ return dataType();
+ }
+
+ /**
+ * Returns type of modification.
+ *
+ * @return type of performed modification.
+ */
+ @NonNull ModificationType modificationType();
/**
* Returns type of modification.
*
* @return type Type of performed modification.
*/
- @NonNull ModificationType getModificationType();
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @NonNull ModificationType getModificationType() {
+ return modificationType();
+ }
+
+ /**
+ * Returns before-state of top level container. Implementations are encouraged, but not required to provide this
+ * state.
+ *
+ * @return State of object before modification. Null if subtree was not present, or the implementation cannot
+ * provide the state.
+ */
+ @Nullable T dataBefore();
/**
- * Returns before-state of top level container. Implementations are encouraged, but not required
- * to provide this state.
+ * Returns before-state of top level container. Implementations are encouraged, but not required to provide this
+ * state.
*
- * @return State of object before modification. Null if subtree was not present, or the
- * implementation cannot provide the state.
+ * @return State of object before modification. Null if subtree was not present, or the implementation cannot
+ * provide the state.
+ * @deprecated Use {@link #dataBefore()} instead.
*/
- @Nullable T getDataBefore();
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @Nullable T getDataBefore() {
+ return dataBefore();
+ }
/**
* Returns after-state of top level container.
*
* @return State of object after modification. Null if subtree is not present.
*/
- @Nullable T getDataAfter();
+ @Nullable T dataAfter();
+
+ /**
+ * Returns after-state of top level container.
+ *
+ * @return State of object after modification. Null if subtree is not present.
+ * @deprecated Use {@link #dataAfter()} instead.
+ */
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @Nullable T getDataAfter() {
+ return dataAfter();
+ }
/**
* Returns unmodifiable collection of modified direct children.
*
* @return unmodifiable collection of modified direct children.
*/
- @NonNull Collection<? extends DataObjectModification<? extends DataObject>> getModifiedChildren();
+ @NonNull Collection<? extends DataObjectModification<? extends DataObject>> modifiedChildren();
+
+ /**
+ * Returns unmodifiable collection of modified direct children.
+ *
+ * @return unmodifiable collection of modified direct children.
+ * @deprecated Use {@link #modifiedChildren()} instead.
+ */
+ @Deprecated(since = "13.0.0", forRemoval = true)
+ default @NonNull Collection<? extends DataObjectModification<? extends DataObject>> getModifiedChildren() {
+ return modifiedChildren();
+ }
/**
* Returns child list item modification if {@code child} was modified by this modification.
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.DataObjectStep;
import org.opendaylight.yangtools.yang.binding.ExactDataObjectStep;
import org.opendaylight.yangtools.yang.binding.Key;
import org.opendaylight.yangtools.yang.binding.KeyAware;
}
final @NonNull DataTreeCandidateNode domData;
- final @NonNull DataObjectStep<?> identifier;
+ final @NonNull ExactDataObjectStep<T> step;
final @NonNull N codec;
@SuppressWarnings("unused")
@SuppressFBWarnings(value = "UUF_UNUSED_FIELD", justification = "https://github.com/spotbugs/spotbugs/issues/2749")
private volatile Object dataAfter;
- AbstractDataObjectModification(final DataTreeCandidateNode domData, final N codec, final DataObjectStep<?> step) {
+ AbstractDataObjectModification(final DataTreeCandidateNode domData, final N codec,
+ final ExactDataObjectStep<T> step) {
this.domData = requireNonNull(domData);
- identifier = requireNonNull(step);
+ this.step = requireNonNull(step);
this.codec = requireNonNull(codec);
}
}
@Override
- public final Class<T> getDataType() {
- return codec.getBindingClass();
+ public final ExactDataObjectStep<T> step() {
+ return step;
}
@Override
- public final DataObjectStep<?> getIdentifier() {
- return identifier;
- }
-
- @Override
- public final ModificationType getModificationType() {
+ public final ModificationType modificationType() {
final var local = (ModificationType) MODIFICATION_TYPE.getAcquire(this);
return local != null ? local : loadModificationType();
}
}
@Override
- public final T getDataBefore() {
+ public final T dataBefore() {
final var local = DATA_BEFORE.getAcquire(this);
return local != null ? unmask(local) : loadDataBefore();
}
}
@Override
- public final T getDataAfter() {
+ public final T dataAfter() {
final var local = DATA_AFTER.getAcquire(this);
return local != null ? unmask(local) : loadDataAfter();
}
abstract @Nullable DataTreeCandidateNode firstModifiedChild(YangInstanceIdentifier.PathArgument arg);
@Override
- public final ImmutableList<AbstractDataObjectModification<?, ?>> getModifiedChildren() {
+ public final ImmutableList<AbstractDataObjectModification<?, ?>> modifiedChildren() {
final var local = (ImmutableList<AbstractDataObjectModification<?, ?>>) MODIFIED_CHILDREN.getAcquire(this);
return local != null ? local : loadModifiedChilden();
}
public final <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>>
List<DataObjectModification<C>> getModifiedChildren(final Class<H> caseType, final Class<C> childType) {
return streamModifiedChildren(childType)
- .filter(child -> caseType.equals(child.identifier.caseType()))
+ .filter(child -> caseType.equals(child.step.caseType()))
.collect(Collectors.toList());
}
private <C extends DataObject> Stream<LazyDataObjectModification<C>> streamModifiedChildren(
final Class<C> childType) {
return getModifiedChildren().stream()
- .filter(child -> childType.isAssignableFrom(child.getDataType()))
+ .filter(child -> childType.isAssignableFrom(child.dataType()))
.map(child -> (LazyDataObjectModification<C>) child);
}
}
ToStringHelper addToStringAttributes(final ToStringHelper helper) {
- return helper.add("identifier", identifier).add("domData", domData);
+ return helper.add("step", step).add("domData", domData);
}
abstract @NonNull Collection<DataTreeCandidateNode> domChildNodes();
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingAugmentationCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.ExactDataObjectStep;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
private LazyAugmentationModification(final BindingAugmentationCodecTreeNode<A> codec,
final DataTreeCandidateNode parent, final ImmutableList<DataTreeCandidateNode> domChildNodes) {
- super(parent, codec, codec.deserializePathArgument(null));
+ super(parent, codec, (ExactDataObjectStep<A>) codec.deserializePathArgument(null));
this.domChildNodes = requireNonNull(domChildNodes);
}
@Override
org.opendaylight.yangtools.yang.data.tree.api.ModificationType domModificationType() {
- final var before = getDataBefore();
- final var after = getDataAfter();
+ final var before = dataBefore();
+ final var after = dataAfter();
if (before == null) {
return after == null ? org.opendaylight.yangtools.yang.data.tree.api.ModificationType.UNMODIFIED
: org.opendaylight.yangtools.yang.data.tree.api.ModificationType.APPEARED;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.ExactDataObjectStep;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
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.name()));
+ super(domData, codec, (ExactDataObjectStep<T>) codec.deserializePathArgument(domData.name()));
}
@Override