2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.rfc7950.stmt.revision_date;
10 import java.time.format.DateTimeParseException;
11 import org.opendaylight.yangtools.yang.common.Revision;
12 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
18 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20 public final class RevisionDateStatementSupport extends AbstractStatementSupport<Revision, RevisionDateStatement,
21 EffectiveStatement<Revision, RevisionDateStatement>> {
22 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
23 SubstatementValidator.builder(YangStmtMapping.REVISION_DATE).build();
25 public RevisionDateStatementSupport() {
26 super(YangStmtMapping.REVISION_DATE);
30 public Revision parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
32 return Revision.of(value);
33 } catch (DateTimeParseException e) {
34 throw new SourceException(ctx.getStatementSourceReference(), e,
35 "Revision value %s is not in required format yyyy-MM-dd", value);
40 public RevisionDateStatement createDeclared(final StmtContext<Revision, RevisionDateStatement, ?> ctx) {
41 return new RevisionDateStatementImpl(ctx);
45 public EffectiveStatement<Revision, RevisionDateStatement> createEffective(final StmtContext<Revision,
46 RevisionDateStatement, EffectiveStatement<Revision, RevisionDateStatement>> ctx) {
47 return new RevisionDateEffectiveStatementImpl(ctx);
51 protected SubstatementValidator getSubstatementValidator() {
52 return SUBSTATEMENT_VALIDATOR;