import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
/**
- *
* Stateless Normalized Node Stream Writer decorator, which performs QName translation.
*
+ * <p>
* This class serves as base for Normalized Node Stream Writer decorators with option to transform
* QNames by user-implemented {@link #transform(QName)} function.
- *
*/
public abstract class QNameTransformingStreamWriter extends ForwardingObject implements NormalizedNodeStreamWriter {
@Override
protected NormalizedNodeStreamWriter delegate() {
- return delegate;
+ return delegate;
}
@Nonnull
}
/**
- * Returns decorator, which uses supplied map to transform QNames.
- *
- * QNames not present in map are left unchanged.
+ * Returns decorator, which uses supplied map to transform QNames. QNames not present in map are left unchanged.
*
* @param delegate Underlying normalized node stream writer
* @param mapping Immutable map which represent mapping from original to new values.
}
/**
- * Returns decorator, which uses supplied map to transform QNameModules.
- *
- * QNameModules not present in map are left unchanged.
+ * Returns decorator, which uses supplied map to transform QNameModules. QNameModules not present in map are left
+ * unchanged.
*
* @param delegate Underlying normalized node stream writer
* @param mapping Immutable map which represent mapping from original to new values.
return fromFunction(delegate, new QNameModuleReplacementFunction(mapping));
}
- /**
- * Transforms a QName to new mapping.
- *
- * NOTE: If QName should be unchanged implementation needs to return original QName.
- *
- * @param key QName to transform.
- * @return Returns new value of QName.
- */
- protected abstract @Nonnull QName transform(@Nonnull QName key);
-
@Override
public void leafNode(final NodeIdentifier name, final Object value) throws IOException {
delegate().leafNode(transform(name), value);
}
@Override
- public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint) throws IOException {
+ public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
+ throws IOException {
delegate().startMapEntryNode(transform(identifier), childSizeHint);
}
delegate().flush();
}
+ /**
+ * Transforms a QName to new mapping.
+ *
+ * <p>
+ * NOTE: If QName should be unchanged implementation needs to return original QName.
+ *
+ * @param key QName to transform.
+ * @return Returns new value of QName.
+ */
+ protected abstract @Nonnull QName transform(@Nonnull QName key);
+
private NodeIdentifier transform(final NodeIdentifier name) {
return new NodeIdentifier(transform(name.getNodeType()));
}