Add WriterParameters.EMPTY 61/98061/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 23 Oct 2021 08:58:47 +0000 (10:58 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 23 Oct 2021 09:00:13 +0000 (11:00 +0200)
We use defaults in at least two places, let's use a simple constant
for the job.

Change-Id: Iaef3e8445ea02e432dc99aaf3be33004a0449ba6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/NormalizedNodeContext.java
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/WriterParameters.java

index 3b13372abbb2a662f514728d9c0258963d7cd996..b22e163514510ec51f2be3d1d5f0943814dc662a 100644 (file)
@@ -40,7 +40,7 @@ public class NormalizedNodeContext {
         this.context = context;
         this.data = data;
         // default writer parameters
-        this.writerParameters = new WriterParameters.WriterParametersBuilder().build();
+        writerParameters = WriterParameters.EMPTY;
     }
 
     public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
@@ -48,20 +48,20 @@ public class NormalizedNodeContext {
         this.context = context;
         this.data = data;
         // default writer parameters
-        this.writerParameters = new WriterParameters.WriterParametersBuilder().build();
+        writerParameters = WriterParameters.EMPTY;
         this.headers = headers;
     }
 
     public InstanceIdentifierContext<? extends SchemaNode> getInstanceIdentifierContext() {
-        return this.context;
+        return context;
     }
 
     public NormalizedNode getData() {
-        return this.data;
+        return data;
     }
 
     public WriterParameters getWriterParameters() {
-        return this.writerParameters;
+        return writerParameters;
     }
 
     /**
@@ -70,6 +70,6 @@ public class NormalizedNodeContext {
      * @return map of headers
      */
     public Map<String, Object> getNewHeaders() {
-        return this.headers;
+        return headers;
     }
 }
index d8a42f03f0a425485913004fe5aae440fc6cc218..03958b85870c9cd1e6165f30e82b14f7858a2398 100644 (file)
@@ -13,6 +13,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public final class WriterParameters {
+    static final WriterParameters EMPTY = new WriterParametersBuilder().build();
+
     private final String content;
     private final Integer depth;
     private final List<Set<QName>> fields;
@@ -22,37 +24,37 @@ public final class WriterParameters {
     private final String withDefault;
 
     private WriterParameters(final WriterParametersBuilder builder) {
-        this.content = builder.content;
-        this.depth = builder.depth;
-        this.fields = builder.fields;
-        this.fieldPaths = builder.fieldPaths;
-        this.prettyPrint = builder.prettyPrint;
-        this.tagged = builder.tagged;
-        this.withDefault = builder.withDefault;
+        content = builder.content;
+        depth = builder.depth;
+        fields = builder.fields;
+        fieldPaths = builder.fieldPaths;
+        prettyPrint = builder.prettyPrint;
+        tagged = builder.tagged;
+        withDefault = builder.withDefault;
     }
 
     public String getContent() {
-        return this.content;
+        return content;
     }
 
     public Integer getDepth() {
-        return this.depth;
+        return depth;
     }
 
     public List<Set<QName>> getFields() {
-        return this.fields;
+        return fields;
     }
 
     public List<YangInstanceIdentifier> getFieldPaths() {
-        return this.fieldPaths;
+        return fieldPaths;
     }
 
     public boolean isPrettyPrint() {
-        return this.prettyPrint;
+        return prettyPrint;
     }
 
     public boolean isTagged() {
-        return this.tagged;
+        return tagged;
     }
 
     public String getWithDefault() {