Implemented ordering of yang module data nodes. Added Comparators utility class.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / parser / builder / api / AbstractSchemaNodeBuilder.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.yang.parser.builder.api;\r
9 \r
10 import java.util.ArrayList;\r
11 import java.util.List;\r
12 \r
13 import org.opendaylight.controller.yang.common.QName;\r
14 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
15 import org.opendaylight.controller.yang.model.api.Status;\r
16 import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;\r
17 \r
18 /**\r
19  * Basic implementation of SchemaNodeBuilder.\r
20  */\r
21 public abstract class AbstractSchemaNodeBuilder implements SchemaNodeBuilder {\r
22     protected final int line;\r
23     protected final QName qname;\r
24     protected Builder parent;\r
25     protected SchemaPath schemaPath;\r
26     protected String description;\r
27     protected String reference;\r
28     protected Status status = Status.CURRENT;\r
29     protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();\r
30 \r
31     protected AbstractSchemaNodeBuilder(final int line, final QName qname) {\r
32         this.line = line;\r
33         this.qname = qname;\r
34     }\r
35 \r
36     @Override\r
37     public int getLine() {\r
38         return line;\r
39     }\r
40 \r
41     public QName getQName() {\r
42         return qname;\r
43     }\r
44 \r
45     @Override\r
46     public Builder getParent() {\r
47         return parent;\r
48     }\r
49 \r
50     @Override\r
51     public void setParent(final Builder parent) {\r
52         this.parent = parent;\r
53     }\r
54 \r
55     public SchemaPath getPath() {\r
56         return schemaPath;\r
57     }\r
58 \r
59     public void setPath(SchemaPath schemaPath) {\r
60         this.schemaPath = schemaPath;\r
61     }\r
62 \r
63     public String getDescription() {\r
64         return description;\r
65     }\r
66 \r
67     public void setDescription(String description) {\r
68         this.description = description;\r
69     }\r
70 \r
71     public String getReference() {\r
72         return reference;\r
73     }\r
74 \r
75     public void setReference(String reference) {\r
76         this.reference = reference;\r
77     }\r
78 \r
79     public Status getStatus() {\r
80         return status;\r
81     }\r
82 \r
83     public void setStatus(Status status) {\r
84         if (status != null) {\r
85             this.status = status;\r
86         }\r
87     }\r
88 \r
89     @Override\r
90     public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {\r
91         addedUnknownNodes.add(unknownNode);\r
92     }\r
93 \r
94 }\r