import com.google.common.annotations.Beta;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchema;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@Beta
@NonNullByDefault
public interface MountPointNodeFactory extends MountPointSchema {
+
MountPointNode createMountPoint(ContainerNode delegate);
}
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
-import org.opendaylight.yangtools.rfc8528.model.api.StaticMountPointSchemaResolver;
import org.opendaylight.yangtools.rfc8528.model.api.YangLibraryConstants.ContainerName;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
+/**
+ * An entity able to resolve the SchemaContext for embedded mount points. This interface should not be implemented
+ * directly, but rather its domain specializations, like {@link Inline} and {@link SharedSchema} should be provided.
+ */
@Beta
-public interface MountPointNodeFactoryResolver extends MountPointSchemaResolver {
+public interface MountPointNodeFactoryResolver {
/**
* A resolver which can resolve the SchemaContext for use with mount point data based on the
* {@code ietf-yang-library} content of the mountpoint itself. This process requires two steps:
Optional<LibraryContext> findSchemaForLibrary(@NonNull ContainerName containerName);
}
+ /**
+ * A resolver which has static knowledge of the SchemaContext which should be used to interpret mount point data.
+ * Instances of this interface should be used in contexts where the mount point data is expected not to contain
+ * required {@code ietf-yang-library} data, for example due to filtering.
+ */
@NonNullByDefault
- interface SharedSchema extends MountPointNodeFactoryResolver, StaticMountPointSchemaResolver {
+ interface SharedSchema extends MountPointNodeFactoryResolver {
- @Override
MountPointNodeFactory getSchema();
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.yangtools.rfc8528.model.api;
+package org.opendaylight.yangtools.rfc8528.data.api;
import com.google.common.annotations.Beta;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
@Beta
-public interface MountPointSchema extends SchemaContextProvider {
+public interface MountPointSchema extends SchemaContextProvider, Identifiable<MountPointIdentifier> {
@Override
// FIXME: remove this override when SchemaContextProvider's method has sane semantics.
@NonNull SchemaContext getSchemaContext();
import java.io.IOException;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchema;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriterExtension;
@Beta
public interface MountPointStreamWriter extends NormalizedNodeStreamWriterExtension {
/**
- * Attempt to acquire a {@link MountPointSchemaResolver} to resolve schemas for the purposes of interpreting this
- * mount point. An empty result indicates the mount point is not attached.
+ * Attempt to acquire a {@link MountPointNodeFactoryResolver} to resolve schemas for the purposes of interpreting
+ * this mount point. An empty result indicates the mount point is not attached.
*
* @param label Mount point label, as defined via the use of {@code mount-point} statement
* @return An optional handler for mount point data
* @throws NullPointerException if label is null
*/
- Optional<MountPointSchemaResolver> findMountPoint(@NonNull MountPointIdentifier label);
+ Optional<MountPointNodeFactoryResolver> findMountPoint(@NonNull MountPointIdentifier label);
/**
* Start a new mount point with a specific root context.
*
- * @param mountSchema Mount point schema
+ * @param factory Mount point schema
* @return A new NormalizedNodeStreamWriter
* @throws IOException if an error occurs
*/
- @NonNull NormalizedNodeStreamWriter startMountPoint(@NonNull MountPointSchema mountSchema) throws IOException;
+ @NonNull NormalizedNodeStreamWriter startMountPoint(@NonNull MountPointNodeFactory factory) throws IOException;
}
import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointNode;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactory;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchema;
+import org.opendaylight.yangtools.rfc8528.data.api.MountPointSchema;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.rfc8528.model.api;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * An entity able to resolve the SchemaContext for embedded mount points. This interface should not be implemented
- * directly, but rather its domain specializations, like {@link StaticMountPointSchemaResolver} should be provided.
- */
-@Beta
-@NonNullByDefault
-public interface MountPointSchemaResolver {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.rfc8528.model.api;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * A resolver which has static knowledge of the SchemaContext which should be used to interpret mount point data.
- * Instances of this interface should be used in contexts where the mount point data is expected not to contain
- * required {@code ietf-yang-library} data, for example due to filtering.
- */
-@Beta
-@NonNullByDefault
-public interface StaticMountPointSchemaResolver extends MountPointSchemaResolver {
-
- MountPointSchema getSchema();
-}
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.AbstractIdentifiable;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
+import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactory;
+import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactoryResolver;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactoryResolver.Inline;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactoryResolver.Inline.LibraryContext;
+import org.opendaylight.yangtools.rfc8528.data.api.MountPointNodeFactoryResolver.SharedSchema;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointStreamWriter;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchema;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
-import org.opendaylight.yangtools.rfc8528.model.api.StaticMountPointSchemaResolver;
import org.opendaylight.yangtools.rfc8528.model.api.YangLibraryConstants.ContainerName;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
return;
}
- final Optional<MountPointSchemaResolver> optResolver = mountWriter.findMountPoint(getIdentifier());
+ final Optional<MountPointNodeFactoryResolver> optResolver = mountWriter.findMountPoint(getIdentifier());
if (!optResolver.isPresent()) {
LOG.debug("Mount point for {} is not present, ignoring it", getIdentifier());
return;
}
- final MountPointSchemaResolver resolver = optResolver.get();
- if (resolver instanceof StaticMountPointSchemaResolver) {
- writeTo(mountWriter, ((StaticMountPointSchemaResolver) resolver).getSchema());
+ final MountPointNodeFactoryResolver resolver = optResolver.get();
+ if (resolver instanceof SharedSchema) {
+ writeTo(mountWriter, ((SharedSchema) resolver).getSchema());
} else if (resolver instanceof Inline) {
writeInline(mountWriter, (Inline) resolver);
} else {
throw new IOException("Invalid non-container " + data);
}
- final MountPointSchema mountMeta;
+ final MountPointNodeFactory factory;
try {
- mountMeta = libContext.bindTo((ContainerNode) data);
+ factory = libContext.bindTo((ContainerNode) data);
} catch (YangParserException e) {
throw new IOException("Failed to assemble context for " + data, e);
}
- writeTo(mountWriter, mountMeta);
+ writeTo(mountWriter, factory);
return;
}
}
private void writeTo(final @NonNull MountPointStreamWriter mountWriter,
- final @NonNull MountPointSchema mountMeta) throws IOException {
+ final @NonNull MountPointNodeFactory mountMeta) throws IOException {
try (NormalizedNodeStreamWriter writer = mountWriter.startMountPoint(mountMeta)) {
for (MountPointChild child : children) {
child.writeTo(writer, mountMeta.getSchemaContext());