Class AbstractEffectiveStatement<A,D extends DeclaredStatement<A>>
- java.lang.Object
-
- org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveStatement<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:
AbstractDeclaredEffectiveStatement
,AbstractUndeclaredEffectiveStatement
@Beta public abstract class AbstractEffectiveStatement<A,D extends DeclaredStatement<A>> extends Object implements EffectiveStatement<A,D>
Baseline stateless implementation of an EffectiveStatement. This class adds a few default implementations and namespace dispatch, but does not actually force any state on its subclasses. This approach adds requirements for an implementation, but it leaves it up to the final class to provide object layout.This finds immense value in catering the common case, for example effective statements which can, but typically do not, contain substatements.
-
-
Constructor Summary
Constructors Constructor Description AbstractEffectiveStatement()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<? extends EffectiveStatement<?,?>>
effectiveSubstatements()
Returns a collection of all effective substatements.<K,V,N extends IdentifierNamespace<K,V>>
Optional<? extends V>get(Class<N> namespace, K identifier)
Returns value associated with supplied identifier.<K,V,N extends IdentifierNamespace<K,V>>
Map<K,V>getAll(Class<N> namespace)
Returns all local values from supplied namespace.protected <K,V,N extends IdentifierNamespace<K,V>>
Optional<? extends Map<K,V>>getNamespaceContents(@NonNull Class<N> namespace)
Return the statement-specific contents of specified namespace, if available.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 @NonNull ImmutableList<? extends EffectiveStatement<?,?>>
unmaskList(@NonNull Object masked)
Utility method for recovering singleton lists squashed bymaskList(ImmutableList)
.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 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
findFirstEffectiveSubstatement, findFirstEffectiveSubstatementArgument, getDeclared, streamEffectiveSubstatements
-
Methods inherited from interface org.opendaylight.yangtools.yang.model.api.meta.ModelStatement
argument, getStatementSource, statementDefinition
-
-
-
-
Method Detail
-
get
public final <K,V,N extends IdentifierNamespace<K,V>> Optional<? extends V> get(Class<N> namespace, K identifier)
Description copied from interface:EffectiveStatement
Returns value associated with supplied identifier.- Specified by:
get
in interfaceEffectiveStatement<A,D extends DeclaredStatement<A>>
- Type Parameters:
K
- Identifier typeV
- Value typeN
- Namespace identifier type- Parameters:
namespace
- Namespace typeidentifier
- Identifier of element.- Returns:
- Value if present
-
getAll
public final <K,V,N extends IdentifierNamespace<K,V>> Map<K,V> getAll(Class<N> namespace)
Description copied from interface:EffectiveStatement
Returns all local values from supplied namespace.- Specified by:
getAll
in interfaceEffectiveStatement<A,D extends DeclaredStatement<A>>
- Type Parameters:
K
- Identifier typeV
- Value typeN
- Namespace identifier type- Parameters:
namespace
- Namespace type- Returns:
- Key-value mappings, empty if the namespace does not exist.
-
effectiveSubstatements
public 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>>
- Returns:
- collection of all effective substatements.
-
getNamespaceContents
protected <K,V,N extends IdentifierNamespace<K,V>> Optional<? extends Map<K,V>> getNamespaceContents(@NonNull Class<N> namespace)
Return the statement-specific contents of specified namespace, if available.- Parameters:
namespace
- Requested namespace- Returns:
- Namespace contents, if available.
-
unmaskList
protected static final @NonNull ImmutableList<? extends EffectiveStatement<?,?>> unmaskList(@NonNull Object masked)
Utility method for recovering singleton lists squashed bymaskList(ImmutableList)
.- Parameters:
masked
- list to unmask- Returns:
- Unmasked list
- Throws:
NullPointerException
- if masked is nullClassCastException
- if masked object does not match EffectiveStatement
-
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)
-
-