Suppress UPM_UNCALLED_PRIVATE_METHOD
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer.java
1 /*
2  * Copyright (c) 2019 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.parser.rfc7950.stmt;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableSet;
12 import java.lang.invoke.MethodHandles;
13 import java.lang.invoke.VarHandle;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.MustConstraintAware;
16 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19
20 @Beta
21 public abstract class AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer<D extends DeclaredStatement<QName>>
22         extends AbstractEffectiveSimpleDataNodeContainer<D> implements MustConstraintAware {
23     private static final VarHandle MUST_CONSTRAINTS;
24
25     static {
26         try {
27             MUST_CONSTRAINTS = MethodHandles.lookup().findVarHandle(
28                 AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer.class, "mustConstraints",
29                 ImmutableSet.class);
30         } catch (NoSuchFieldException | IllegalAccessException e) {
31             throw new ExceptionInInitializerError(e);
32         }
33     }
34
35     @SuppressWarnings("unused")
36     private volatile ImmutableSet<MustDefinition> mustConstraints;
37
38     protected AbstractEffectiveMustConstraintAwareSimpleDataNodeContainer(final StmtContext<QName, D, ?> ctx) {
39         super(ctx);
40     }
41
42     @Override
43     public final ImmutableSet<MustDefinition> getMustConstraints() {
44         return derivedSet(MUST_CONSTRAINTS, MustDefinition.class);
45     }
46 }