Remove the option to deliver streams over WebSockets
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / spi / NormalizedNodeWriterFactory.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.server.spi;
9
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.restconf.api.query.DepthParam;
15 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
16
17 /**
18  * Interface for instantiating a {@link NormalizedNodeWriter} to handle the data writeout to a
19  * {@link NormalizedNodeStreamWriter}.
20  */
21 @NonNullByDefault
22 public abstract class NormalizedNodeWriterFactory {
23     /**
24      * Return the default {@link NormalizedNodeWriterFactory}.
25      *
26      * @return the default {@link NormalizedNodeWriterFactory}
27      */
28     public static final NormalizedNodeWriterFactory of() {
29         return DefaultNormalizedNodeWriterFactory.INSTANCE;
30     }
31
32     public static final NormalizedNodeWriterFactory of(final @Nullable DepthParam depth) {
33         return depth == null ? of() : new MaxDepthNormalizedNodeWriterFactory(depth);
34     }
35
36     /**
37      * Create a new {@link NormalizedNodeWriter} for specified {@link NormalizedNodeStreamWriter}.
38      *
39      * @param streamWriter target {@link NormalizedNodeStreamWriter}
40      * @return A {@link NormalizedNodeWriter}
41      */
42     protected abstract NormalizedNodeWriter newWriter(NormalizedNodeStreamWriter streamWriter);
43
44     protected abstract ToStringHelper addToStringAttributes(ToStringHelper helper);
45
46     @Override
47     public final String toString() {
48         return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
49     }
50 }