2 * Copyright (c) 2015 Cisco Systems, Inc. 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.yangtools.yang.data.codec.gson;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Strings;
12 import com.google.gson.stream.JsonWriter;
13 import java.io.Writer;
16 * Factory Method class for JsonWriter creation
19 public final class JsonWriterFactory {
20 private JsonWriterFactory() {
21 throw new UnsupportedOperationException();
25 * Create a new JsonWriter, which writes to the specified output writer.
27 * @param writer Output writer
28 * @return A JsonWriter instance
30 public static JsonWriter createJsonWriter(final Writer writer) {
31 return new JsonWriter(writer);
35 * Create a new JsonWriter, which writes to the specified output writer.
37 * @param writer Output writer
38 * @param indentSize size of the indent
39 * @return A JsonWriter instance
41 public static JsonWriter createJsonWriter(final Writer writer, final int indentSize) {
42 JsonWriter jsonWriter = new JsonWriter(writer);
43 final String indent = Strings.repeat(" ", indentSize);
44 jsonWriter.setIndent(indent);