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.rfc7950.stmt.deviation;
10 import com.google.common.collect.ImmutableList;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
14 import org.opendaylight.yangtools.yang.model.api.Deviation;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.DeviationEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DocumentedNodeMixin;
23 final class DeviationEffectiveStatementImpl extends WithSubstatements<SchemaNodeIdentifier, DeviationStatement>
24 implements DeviationEffectiveStatement, Deviation,
25 DocumentedNodeMixin<SchemaNodeIdentifier, DeviationStatement> {
26 DeviationEffectiveStatementImpl(final DeviationStatement declared,
27 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
28 super(declared, substatements);
32 public SchemaPath getTargetPath() {
33 return argument().asSchemaPath();
37 public List<DeviateDefinition> getDeviates() {
38 return filterEffectiveStatementsList(DeviateDefinition.class);
42 public int hashCode() {
43 return Objects.hash(getTargetPath(), getDeviates(), getDescription().orElse(null), getReference().orElse(null));
47 public boolean equals(final Object obj) {
51 if (!(obj instanceof DeviationEffectiveStatementImpl)) {
54 final DeviationEffectiveStatementImpl other = (DeviationEffectiveStatementImpl) obj;
55 return Objects.equals(getTargetPath(), other.getTargetPath())
56 && Objects.equals(getDeviates(), other.getDeviates())
57 && Objects.equals(getDescription(), other.getDescription())
58 && Objects.equals(getReference(), other.getReference());
62 public String toString() {
63 return DeviationEffectiveStatementImpl.class.getSimpleName() + "["
64 + "targetPath=" + getTargetPath()
65 + ", deviates=" + getDeviates()
66 + ", description=" + getDescription().orElse(null)
67 + ", reference=" + getReference().orElse(null)