Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 72b2df2 | 2017-08-03 18:48:28 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yang.compiler.datamodel; |
| 17 | |
| 18 | import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yang.compiler.datamodel.utils.Parsable; |
| 20 | import org.onosproject.yang.compiler.datamodel.utils.YangConstructType; |
| 21 | |
| 22 | import java.io.Serializable; |
Vidyashree Rama | 7b9726e | 2019-08-26 13:48:33 +0530 | [diff] [blame] | 23 | import java.time.LocalDate; |
Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Reference:RFC 6020. |
| 27 | * The "revision" statement specifies the editorial revision history of |
| 28 | * the module, including the initial revision. A series of revision |
| 29 | * statements detail the changes in the module's definition. The |
| 30 | * argument is a date string in the format "YYYY-MM-DD", followed by a |
| 31 | * block of sub-statements that holds detailed revision information. A |
| 32 | * module SHOULD have at least one initial "revision" statement. For |
| 33 | * every published editorial change, a new one SHOULD be added in front |
| 34 | * of the revisions sequence, so that all revisions are in reverse |
| 35 | * chronological order. |
| 36 | * The revision's sub-statement |
| 37 | * |
| 38 | * +--------------+---------+-------------+------------------+ |
| 39 | * | substatement | section | cardinality |data model mapping| |
| 40 | * +--------------+---------+-------------+------------------+ |
| 41 | * | description | 7.19.3 | 0..1 |string | |
| 42 | * | reference | 7.19.4 | 0..1 |sring | |
| 43 | * +--------------+---------+-------------+------------------+ |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | * Represents the information about the revision. |
| 48 | */ |
| 49 | public class YangRevision |
| 50 | extends DefaultLocationInfo |
| 51 | implements YangDesc, YangReference, Parsable, Serializable, Comparable<YangRevision> { |
| 52 | |
| 53 | private static final long serialVersionUID = 8062016052L; |
| 54 | |
| 55 | /** |
| 56 | * Revision date. Date string in the format "YYYY-MM-DD" |
| 57 | */ |
Vidyashree Rama | 7b9726e | 2019-08-26 13:48:33 +0530 | [diff] [blame] | 58 | private LocalDate revDate; |
Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Description of revision. |
| 62 | */ |
| 63 | private String description; |
| 64 | |
| 65 | /** |
| 66 | * Textual reference for revision. |
| 67 | */ |
| 68 | private String reference; |
| 69 | |
| 70 | /** |
| 71 | * Creates a YANG revision object. |
| 72 | */ |
| 73 | public YangRevision() { |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the revision date. |
| 78 | * |
| 79 | * @return the revision date |
| 80 | */ |
Vidyashree Rama | 7b9726e | 2019-08-26 13:48:33 +0530 | [diff] [blame] | 81 | public LocalDate getRevDate() { |
Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 82 | return revDate; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Sets the revision date. |
| 87 | * |
| 88 | * @param revDate the revision date to set |
| 89 | */ |
Vidyashree Rama | 7b9726e | 2019-08-26 13:48:33 +0530 | [diff] [blame] | 90 | public void setRevDate(LocalDate revDate) { |
Gaurav Agrawal | a599a8f | 2017-01-10 20:45:27 +0530 | [diff] [blame] | 91 | this.revDate = revDate; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Returns the description. |
| 96 | * |
| 97 | * @return the description |
| 98 | */ |
| 99 | @Override |
| 100 | public String getDescription() { |
| 101 | return description; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Sets the description. |
| 106 | * |
| 107 | * @param description set the description |
| 108 | */ |
| 109 | @Override |
| 110 | public void setDescription(String description) { |
| 111 | this.description = description; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Returns the textual reference. |
| 116 | * |
| 117 | * @return the reference |
| 118 | */ |
| 119 | @Override |
| 120 | public String getReference() { |
| 121 | return reference; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Sets the textual reference. |
| 126 | * |
| 127 | * @param reference the reference to set |
| 128 | */ |
| 129 | @Override |
| 130 | public void setReference(String reference) { |
| 131 | this.reference = reference; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Returns the type of the parsed data. |
| 136 | * |
| 137 | * @return returns REVISION_DATA |
| 138 | */ |
| 139 | @Override |
| 140 | public YangConstructType getYangConstructType() { |
| 141 | return YangConstructType.REVISION_DATA; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Validates the data on entering the corresponding parse tree node. |
| 146 | * |
| 147 | * @throws DataModelException a violation of data model rules |
| 148 | */ |
| 149 | @Override |
| 150 | public void validateDataOnEntry() |
| 151 | throws DataModelException { |
| 152 | // TODO auto-generated method stub, to be implemented by parser |
| 153 | |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Validates the data on exiting the corresponding parse tree node. |
| 158 | * |
| 159 | * @throws DataModelException a violation of data model rules |
| 160 | */ |
| 161 | @Override |
| 162 | public void validateDataOnExit() |
| 163 | throws DataModelException { |
| 164 | // TODO auto-generated method stub, to be implemented by parser |
| 165 | |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public int compareTo(YangRevision obj) { |
| 170 | if (this == obj) { |
| 171 | return 0; |
| 172 | } |
| 173 | return getRevDate().compareTo(obj.getRevDate()); |
| 174 | } |
| 175 | } |