Add WriterParameters.EMPTY
[netconf.git] / restconf / restconf-common / src / main / java / org / opendaylight / restconf / common / context / WriterParameters.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.common.context;
9
10 import java.util.List;
11 import java.util.Set;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15 public final class WriterParameters {
16     static final WriterParameters EMPTY = new WriterParametersBuilder().build();
17
18     private final String content;
19     private final Integer depth;
20     private final List<Set<QName>> fields;
21     private final List<YangInstanceIdentifier> fieldPaths;
22     private final boolean prettyPrint;
23     private final boolean tagged;
24     private final String withDefault;
25
26     private WriterParameters(final WriterParametersBuilder builder) {
27         content = builder.content;
28         depth = builder.depth;
29         fields = builder.fields;
30         fieldPaths = builder.fieldPaths;
31         prettyPrint = builder.prettyPrint;
32         tagged = builder.tagged;
33         withDefault = builder.withDefault;
34     }
35
36     public String getContent() {
37         return content;
38     }
39
40     public Integer getDepth() {
41         return depth;
42     }
43
44     public List<Set<QName>> getFields() {
45         return fields;
46     }
47
48     public List<YangInstanceIdentifier> getFieldPaths() {
49         return fieldPaths;
50     }
51
52     public boolean isPrettyPrint() {
53         return prettyPrint;
54     }
55
56     public boolean isTagged() {
57         return tagged;
58     }
59
60     public String getWithDefault() {
61         return withDefault;
62     }
63
64     public static class WriterParametersBuilder {
65         private String content;
66         private Integer depth;
67         private List<Set<QName>> fields;
68         private List<YangInstanceIdentifier> fieldPaths;
69         private boolean prettyPrint;
70         private boolean tagged;
71         private String withDefault;
72
73         public WriterParametersBuilder() {
74
75         }
76
77         public WriterParametersBuilder setContent(final String content) {
78             this.content = content;
79             return this;
80         }
81
82         public WriterParametersBuilder setDepth(final int depth) {
83             this.depth = depth;
84             return this;
85         }
86
87         public WriterParametersBuilder setFields(final List<Set<QName>> fields) {
88             this.fields = fields;
89             return this;
90         }
91
92         public WriterParametersBuilder setFieldPaths(final List<YangInstanceIdentifier> fieldPaths) {
93             this.fieldPaths = fieldPaths;
94             return this;
95         }
96
97         public WriterParametersBuilder setPrettyPrint(final boolean prettyPrint) {
98             this.prettyPrint = prettyPrint;
99             return this;
100         }
101
102         public WriterParametersBuilder setWithDefault(final String withDefault) {
103             this.withDefault = withDefault;
104             return this;
105         }
106
107         public WriterParameters build() {
108             return new WriterParameters(this);
109         }
110
111         public void setTagged(final boolean tagged) {
112             this.tagged = tagged;
113         }
114     }
115 }