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 {
21 private JsonWriterFactory() {
24 * Create a new JsonWriter, which writes to the specified output writer.
26 * @param writer Output writer
27 * @return A JsonWriter instance
29 public static JsonWriter createJsonWriter(Writer writer) {
30 return new JsonWriter(writer);
34 * Create a new JsonWriter, which writes to the specified output writer.
36 * @param writer Output writer
37 * @param indentSize size of the indent
38 * @return A JsonWriter instance
40 public static JsonWriter createJsonWriter(Writer writer, int indentSize) {
41 JsonWriter jsonWriter = new JsonWriter(writer);
42 final String indent = Strings.repeat(" ", indentSize);
43 jsonWriter.setIndent(indent);