2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
10 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RevisionEffectiveStatementImpl;
11 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
12 import java.text.ParseException;
13 import java.util.Date;
14 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 import javax.annotation.Nullable;
25 public class RevisionStatementImpl extends AbstractDeclaredStatement<Date>
26 implements RevisionStatement {
28 protected RevisionStatementImpl(
29 StmtContext<Date, RevisionStatement, ?> context) {
33 public static class Definition
35 AbstractStatementSupport<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> {
38 super(Rfc6020Mapping.REVISION);
42 public Date parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
43 throws SourceException {
46 revision = SimpleDateFormatUtil.getRevisionFormat()
48 } catch (ParseException e) {
49 throw new SourceException(String.format("Revision value %s is not in required format yyyy-MM-dd",
50 value), ctx.getStatementSourceReference(), e);
57 public RevisionStatement createDeclared(
58 StmtContext<Date, RevisionStatement, ?> ctx) {
59 return new RevisionStatementImpl(ctx);
63 public EffectiveStatement<Date, RevisionStatement> createEffective(
64 StmtContext<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> ctx) {
65 return new RevisionEffectiveStatementImpl(ctx);
70 public Date getDate() {
76 public DescriptionStatement getDescription() {
77 return firstDeclared(DescriptionStatement.class);
82 public ReferenceStatement getReference() {
83 return firstDeclared(ReferenceStatement.class);