Merge "Bug 9092: revert to org.json temporarily"
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / impl / NormalizedNodeContext.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.netconf.sal.restconf.impl;
9
10 import java.util.HashMap;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
14
15 public class NormalizedNodeContext {
16
17     private final InstanceIdentifierContext<? extends SchemaNode> context;
18     private final NormalizedNode<?,?> data;
19     private final WriterParameters writerParameters;
20     private Map<String, Object> headers = new HashMap<>();
21
22     public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
23                                  final NormalizedNode<?, ?> data, final WriterParameters writerParameters) {
24         this.context = context;
25         this.data = data;
26         this.writerParameters = writerParameters;
27     }
28
29     public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
30             final NormalizedNode<?, ?> data, final WriterParameters writerParameters,
31             final Map<String, Object> headers) {
32         this.context = context;
33         this.data = data;
34         this.writerParameters = writerParameters;
35         this.headers = headers;
36     }
37
38     public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
39                                  final NormalizedNode<?, ?> data) {
40         this.context = context;
41         this.data = data;
42         // default writer parameters
43         this.writerParameters = new WriterParameters.WriterParametersBuilder().build();
44     }
45
46     public NormalizedNodeContext(final InstanceIdentifierContext<? extends SchemaNode> context,
47             final NormalizedNode<?, ?> data, final Map<String, Object> headers) {
48         this.context = context;
49         this.data = data;
50         // default writer parameters
51         this.writerParameters = new WriterParameters.WriterParametersBuilder().build();
52         this.headers = headers;
53     }
54
55
56     public InstanceIdentifierContext<? extends SchemaNode> getInstanceIdentifierContext() {
57         return this.context;
58     }
59
60     public NormalizedNode<?, ?> getData() {
61         return this.data;
62     }
63
64     public WriterParameters getWriterParameters() {
65         return this.writerParameters;
66     }
67
68     /**
69      * Return headers of {@code NormalizedNodeContext}.
70      *
71      * @return map of headers
72      */
73     public Map<String, Object> getNewHeaders() {
74         return this.headers;
75     }
76 }