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 java.text.ParseException;
11 import java.util.Date;
12 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
13 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
20 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RevisionDateEffectiveStatementImpl;
23 public class RevisionDateStatementImpl extends AbstractDeclaredStatement<Date> implements RevisionDateStatement {
24 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
25 SubstatementValidator.builder(YangStmtMapping.REVISION_DATE).build();
27 protected RevisionDateStatementImpl(final StmtContext<Date, RevisionDateStatement, ?> context) {
31 public static class Definition
33 AbstractStatementSupport<Date, RevisionDateStatement, EffectiveStatement<Date, RevisionDateStatement>> {
36 super(YangStmtMapping.REVISION_DATE);
40 public Date parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
42 return SimpleDateFormatUtil.getRevisionFormat().parse(value);
43 } catch (ParseException e) {
44 throw new SourceException(ctx.getStatementSourceReference(), e,
45 "Revision value %s is not in required format yyyy-MM-dd", value);
50 public RevisionDateStatement createDeclared(final StmtContext<Date, RevisionDateStatement, ?> ctx) {
51 return new RevisionDateStatementImpl(ctx);
55 public EffectiveStatement<Date, RevisionDateStatement> createEffective(
56 final StmtContext<Date, RevisionDateStatement, EffectiveStatement<Date, RevisionDateStatement>> ctx) {
57 return new RevisionDateEffectiveStatementImpl(ctx);
61 protected SubstatementValidator getSubstatementValidator() {
62 return SUBSTATEMENT_VALIDATOR;
67 public Date getDate() {