Class EffectiveStatementBase<A,D extends DeclaredStatement<A>>
- java.lang.Object
-
- org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveStatement<A,D>
-
- org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementBase<A,D>
-
- Type Parameters:
A
- Argument type (Void
if statement does not have argument.)D
- Class representing declared version of this statement.
- All Implemented Interfaces:
EffectiveStatement<A,D>
,ModelStatement<A>
- Direct Known Subclasses:
DeclaredEffectiveStatementBase
,UndeclaredEffectiveStatementBase
public abstract class EffectiveStatementBase<A,D extends DeclaredStatement<A>> extends AbstractEffectiveStatement<A,D>
Stateful version ofAbstractEffectiveStatement
, which holds substatements in anImmutableList
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EffectiveStatementBase(StmtContext<A,D,?> ctx)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Collection<T>
allSubstatementsOfType(Class<T> type)
Collection<? extends EffectiveStatement<?,?>>
effectiveSubstatements()
Returns a collection of all effective substatements.protected EffectiveStatement<?,?>
firstEffectiveSubstatementOfType(Class<?> type)
protected <S extends SchemaNode>
SfirstSchemaNode(Class<S> type)
protected <R> R
firstSubstatementOfType(Class<?> type, Class<R> returnType)
protected <T> @Nullable T
firstSubstatementOfType(Class<T> type)
protected Collection<? extends EffectiveStatement<?,?>>
initSubstatements(Collection<? extends StmtContext<?,?,?>> substatementsInit)
Create a set of substatements.protected static @NonNull Object
maskList(ImmutableList<?> list)
Utility method for squashing singleton lists into single objects.protected static @NonNull Object
maskSet(ImmutableSet<?> set)
protected static <T> @NonNull ImmutableList<T>
unmaskList(@NonNull Object masked, @NonNull Class<T> type)
Utility method for recovering singleton lists squashed bymaskList(ImmutableList)
.protected static <T> @NonNull ImmutableSet<? extends T>
unmaskSet(@NonNull Object masked, @NonNull Class<T> type)
-
Methods inherited from class org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveStatement
get, getAll, getNamespaceContents, unmaskList
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement
findAll, findFirstEffectiveSubstatement, findFirstEffectiveSubstatementArgument, getDeclared, streamEffectiveSubstatements
-
Methods inherited from interface org.opendaylight.yangtools.yang.model.api.meta.ModelStatement
argument, getStatementSource, statementDefinition
-
-
-
-
Constructor Detail
-
EffectiveStatementBase
protected EffectiveStatementBase(StmtContext<A,D,?> ctx)
Constructor.- Parameters:
ctx
- context of statement.
-
-
Method Detail
-
initSubstatements
protected Collection<? extends EffectiveStatement<?,?>> initSubstatements(Collection<? extends StmtContext<?,?,?>> substatementsInit)
Create a set of substatements. This method is split out so it can be overridden in ExtensionEffectiveStatementImpl to leak a not-fully-initialized instance.- Parameters:
substatementsInit
- proposed substatements- Returns:
- Filtered substatements
-
effectiveSubstatements
public final Collection<? extends EffectiveStatement<?,?>> effectiveSubstatements()
Description copied from interface:EffectiveStatement
Returns a collection of all effective substatements.- Specified by:
effectiveSubstatements
in interfaceEffectiveStatement<A,D extends DeclaredStatement<A>>
- Overrides:
effectiveSubstatements
in classAbstractEffectiveStatement<A,D extends DeclaredStatement<A>>
- Returns:
- collection of all effective substatements.
-
allSubstatementsOfType
public final <T> Collection<T> allSubstatementsOfType(Class<T> type)
-
firstSubstatementOfType
protected final <T> @Nullable T firstSubstatementOfType(Class<T> type)
-
firstSubstatementOfType
protected final <R> R firstSubstatementOfType(Class<?> type, Class<R> returnType)
-
firstEffectiveSubstatementOfType
protected final EffectiveStatement<?,?> firstEffectiveSubstatementOfType(Class<?> type)
-
firstSchemaNode
protected final <S extends SchemaNode> S firstSchemaNode(Class<S> type)
-
maskList
protected static final @NonNull Object maskList(ImmutableList<?> list)
Utility method for squashing singleton lists into single objects. This is a CPU/mem trade-off, which we are usually willing to make: for the cost of an instanceof check we can save one object and re-create it when needed. The inverse operation is #unmaskSubstatements(Object)}.- Parameters:
list
- list to mask- Returns:
- Masked list
- Throws:
NullPointerException
- if list is null
-
unmaskList
protected static final <T> @NonNull ImmutableList<T> unmaskList(@NonNull Object masked, @NonNull Class<T> type)
Utility method for recovering singleton lists squashed bymaskList(ImmutableList)
.- Parameters:
masked
- list to unmask- Returns:
- Unmasked list
- Throws:
NullPointerException
- if any argument is nullClassCastException
- if masked object does not match expected class
-
maskSet
protected static final @NonNull Object maskSet(ImmutableSet<?> set)
-
unmaskSet
protected static final <T> @NonNull ImmutableSet<? extends T> unmaskSet(@NonNull Object masked, @NonNull Class<T> type)
-
-