/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020; import java.util.Collection; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative; import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement; import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UniqueEffectiveStatementImpl; public class UniqueStatementImpl extends AbstractDeclaredStatement> implements UniqueStatement { private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping .UNIQUE) .build(); protected UniqueStatementImpl(StmtContext, UniqueStatement, ?> context) { super(context); } public static class Definition extends AbstractStatementSupport, UniqueStatement, EffectiveStatement, UniqueStatement>> { public Definition() { super(Rfc6020Mapping.UNIQUE); } @Override public Collection parseArgumentValue(StmtContext ctx, String value) throws SourceException { return Utils.transformKeysStringToKeyNodes(ctx, value); } @Override public UniqueStatement createDeclared(StmtContext, UniqueStatement, ?> ctx) { return new UniqueStatementImpl(ctx); } @Override public EffectiveStatement, UniqueStatement> createEffective (StmtContext, UniqueStatement, EffectiveStatement, UniqueStatement>> ctx) { return new UniqueEffectiveStatementImpl(ctx); } @Override public void onFullDefinitionDeclared(StmtContext.Mutable, UniqueStatement, EffectiveStatement, UniqueStatement>> stmt) throws SourceException { super.onFullDefinitionDeclared(stmt); SUBSTATEMENT_VALIDATOR.validate(stmt); } } @Nonnull @Override public Collection getTag() { return argument(); } }