Seal ModelStatement
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / meta / AbstractDeclaredStatement.java
1 /*
2  * Copyright (c) 2022 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.api.meta;
9
10 import com.google.common.collect.ImmutableList;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.yang.common.Empty;
13
14 /**
15  * Abstract base class for {@link DeclaredStatement} implementations.
16  *
17  * @param <A> Argument type ({@link Empty} if statement does not have argument.)
18  */
19 public abstract non-sealed class AbstractDeclaredStatement<A> extends AbstractModelStatement<A>
20         implements DeclaredStatement<A> {
21     /**
22      * Utility method for recovering singleton lists squashed by {@link #maskList(ImmutableList)}.
23      *
24      * @param masked list to unmask
25      * @return Unmasked list
26      * @throws NullPointerException if masked is null
27      * @throws ClassCastException if masked object does not match DeclaredStatement
28      */
29     @SuppressWarnings({ "rawtypes", "unchecked" })
30     protected static final @NonNull ImmutableList<? extends DeclaredStatement<?>> unmaskList(
31             final @NonNull Object masked) {
32         return (ImmutableList) unmaskList(masked, DeclaredStatement.class);
33     }
34 }