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;
12 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
13 import java.text.ParseException;
14 import java.util.Date;
15 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
24 import javax.annotation.Nullable;
26 public class RevisionStatementImpl extends AbstractDeclaredStatement<Date>
27 implements RevisionStatement {
29 protected RevisionStatementImpl(
30 StmtContext<Date, RevisionStatement, ?> context) {
34 public static class Definition
36 AbstractStatementSupport<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> {
39 super(Rfc6020Mapping.REVISION);
43 public Date parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
44 throws SourceException {
47 revision = SimpleDateFormatUtil.getRevisionFormat()
49 } catch (ParseException e) {
50 throw new IllegalArgumentException(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);