import java.io.DataOutput;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
/**
* NormalizedNodeOutputStreamWriter will be used by distributed datastore to send normalized node in
* <p>Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
* while reading.
*/
-class LithiumNormalizedNodeOutputStreamWriter extends AbstractNormalizedNodeDataOutput {
- private final Map<String, Integer> stringCodeMap = new HashMap<>();
-
+final class LithiumNormalizedNodeOutputStreamWriter extends AbstractLithiumDataOutput {
LithiumNormalizedNodeOutputStreamWriter(final DataOutput output) {
super(output);
}
@Override
- protected short streamVersion() {
+ short streamVersion() {
return TokenTypes.LITHIUM_VERSION;
}
@Override
- protected void writeQName(final QName qname) throws IOException {
- writeString(qname.getLocalName());
- writeModule(qname.getModule());
+ void writeQNameInternal(final QName qname) throws IOException {
+ defaultWriteQName(qname);
}
+ @Override
void writeModule(final QNameModule module) throws IOException {
- writeString(module.getNamespace().toString());
- writeString(module.getRevision().map(Revision::toString).orElse(null));
+ defaultWriteModule(module);
}
@Override
- protected final void writeString(final String string) throws IOException {
- if (string != null) {
- final Integer value = stringCodeMap.get(string);
- if (value == null) {
- stringCodeMap.put(string, stringCodeMap.size());
- writeByte(TokenTypes.IS_STRING_VALUE);
- writeUTF(string);
- } else {
- writeByte(TokenTypes.IS_CODE_VALUE);
- writeInt(value);
- }
- } else {
- writeByte(TokenTypes.IS_NULL_VALUE);
- }
+ void writeAugmentationIdentifier(final AugmentationIdentifier aid) throws IOException {
+ defaultWriteAugmentationIdentifier(aid);
}
}