2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.restconf.server.spi;
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.restconf.nb.rfc8040.jersey.providers.RestconfNormalizedNodeWriter;
16 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
19 * Interface for instantiating a {@link RestconfNormalizedNodeWriter} to handle the data writeout to a
20 * {@link NormalizedNodeStreamWriter}.
23 public abstract class NormalizedNodeWriterFactory {
25 * Return the default {@link NormalizedNodeWriterFactory}.
27 * @return the default {@link NormalizedNodeWriterFactory}
29 public static final NormalizedNodeWriterFactory of() {
30 return DefaultNormalizedNodeWriterFactory.INSTANCE;
33 public static final NormalizedNodeWriterFactory of(final @Nullable DepthParam depth) {
34 return depth == null ? of() : new MaxDepthNormalizedNodeWriterFactory(depth);
38 * Create a new {@link RestconfNormalizedNodeWriter} for specified {@link NormalizedNodeStreamWriter}.
40 * @param streamWriter target {@link NormalizedNodeStreamWriter}
41 * @return A {@link RestconfNormalizedNodeWriter}
43 protected abstract RestconfNormalizedNodeWriter newWriter(NormalizedNodeStreamWriter streamWriter);
45 protected abstract ToStringHelper addToStringAttributes(ToStringHelper helper);
48 public final String toString() {
49 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();