BUG 2155 - depth parameter in URI
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / restconf / impl / WriterParameters.java
index 9b26f60dbf7613fa39887f266a61953fabef72fd..45df2f191c62225baec226714542473de4da71aa 100644 (file)
@@ -1,20 +1,52 @@
 package org.opendaylight.controller.sal.restconf.impl;
 
+import com.google.common.base.Optional;
+
 public class WriterParameters {
-    private final int depth;
+    private final Optional<Integer> depth;
     private final boolean prettyPrint;
 
-    public WriterParameters(final boolean prettyPrint, final int depth) {
-        this.prettyPrint = prettyPrint;
-        this.depth = depth;
+    private WriterParameters(final WriterParametersBuilder builder) {
+        this.prettyPrint = builder.prettyPrint;
+        this.depth = builder.depth;
     }
 
-    public int getDepth() {
+    public Optional<Integer> getDepth() {
         return depth;
     }
 
     public boolean isPrettyPrint() {
         return prettyPrint;
     }
+
+    public static class WriterParametersBuilder {
+        private Optional<Integer> depth = Optional.absent();
+        private boolean prettyPrint;
+
+        public WriterParametersBuilder() {
+        }
+
+        public Optional<Integer> getDepth() {
+            return depth;
+        }
+
+        public WriterParametersBuilder setDepth(final int depth) {
+            this.depth = Optional.of(depth);
+            return this;
+        }
+
+        public boolean isPrettyPrint() {
+            return prettyPrint;
+        }
+
+        public WriterParametersBuilder setPrettyPrint(final boolean prettyPrint) {
+            this.prettyPrint = prettyPrint;
+            return this;
+        }
+
+        public WriterParameters build() {
+            return new WriterParameters(this);
+        }
+    }
 }