2 * Copyright (c) 2017 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.spi.source;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
14 import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
17 * An implicit sub-statement, which is implied to be always present in its parent, even if it does not appear in model
21 public final class ImplicitSubstatement extends StatementSourceReference {
22 private final StatementSourceReference parentRef;
24 private ImplicitSubstatement(final StatementSourceReference parentRef) {
25 this.parentRef = requireNonNull(parentRef);
29 * Create a new {@link ImplicitSubstatement}.
31 * @param parentRef Parent source reference
32 * @return A new reference
33 * @throws NullPointerException if parentRef is null
35 public static ImplicitSubstatement of(final StatementSourceReference parentRef) {
36 return new ImplicitSubstatement(parentRef);
40 public StatementOrigin statementOrigin() {
41 return StatementOrigin.CONTEXT;
45 public DeclarationReference declarationReference() {
50 public int hashCode() {
51 return parentRef.hashCode();
55 public boolean equals(final Object obj) {
56 return obj instanceof ImplicitSubstatement && parentRef.equals(((ImplicitSubstatement) obj).parentRef);
60 public String toString() {
61 return parentRef.toString();