529f058fd1c68995a2dc778fefa1bc76aff6c1e3
[yangtools.git] / yang / yang-model-spi / src / main / java / org / opendaylight / yangtools / yang / model / spi / AbstractEffectiveStatementInference.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.spi;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableList;
14 import java.util.List;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19
20 /**
21  * A simple capture of an {@link EffectiveModelContext} and a list of paths. No further guarantees are made.
22  */
23 @Beta
24 public abstract class AbstractEffectiveStatementInference extends AbstractEffectiveModelContextProvider
25         implements EffectiveStatementInference {
26     private final @NonNull List<EffectiveStatement<?, ?>> path;
27
28     protected AbstractEffectiveStatementInference(final @NonNull EffectiveModelContext modelContext,
29             final @NonNull ImmutableList<EffectiveStatement<?, ?>> path) {
30         super(modelContext);
31         this.path = requireNonNull(path);
32     }
33
34     protected AbstractEffectiveStatementInference(final @NonNull EffectiveModelContext modelContext,
35             final @NonNull List<? extends EffectiveStatement<?, ?>> path) {
36         super(modelContext);
37         this.path = ImmutableList.copyOf(path);
38     }
39
40     @Override
41     public final List<EffectiveStatement<?, ?>> statementPath() {
42         return path;
43     }
44 }