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.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
18 * Interface for instantiating a {@link NormalizedNodeWriter} to handle the data writeout to a
19 * {@link NormalizedNodeStreamWriter}.
22 public abstract class NormalizedNodeWriterFactory {
24 * Return the default {@link NormalizedNodeWriterFactory}.
26 * @return the default {@link NormalizedNodeWriterFactory}
28 public static final NormalizedNodeWriterFactory of() {
29 return DefaultNormalizedNodeWriterFactory.INSTANCE;
32 public static final NormalizedNodeWriterFactory of(final @Nullable DepthParam depth) {
33 return depth == null ? of() : new MaxDepthNormalizedNodeWriterFactory(depth);
37 * Create a new {@link NormalizedNodeWriter} for specified {@link NormalizedNodeStreamWriter}.
39 * @param streamWriter target {@link NormalizedNodeStreamWriter}
40 * @return A {@link NormalizedNodeWriter}
42 protected abstract NormalizedNodeWriter newWriter(NormalizedNodeStreamWriter streamWriter);
44 protected abstract ToStringHelper addToStringAttributes(ToStringHelper helper);
47 public final String toString() {
48 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();