Class BindingRuntimeContext

  • All Implemented Interfaces:
    org.opendaylight.yangtools.concepts.Immutable, org.opendaylight.yangtools.concepts.MutationBehaviour<org.opendaylight.yangtools.concepts.Immutable>

    public final class BindingRuntimeContext
    extends Object
    implements org.opendaylight.yangtools.concepts.Immutable
    Runtime Context for Java YANG Binding classes

    Runtime Context provides additional insight in Java YANG Binding, binding classes and underlying YANG schema, it contains runtime information, which could not be derived from generated classes alone using BindingReflections.

    Some of this information are for example list of all available children for cases getChoiceCaseChildren(DataNodeContainer), since choices are augmentable and new choices may be introduced by additional models.

    Same goes for all possible augmentations.

    • Method Detail

      • create

        public static BindingRuntimeContext create​(ClassLoadingStrategy strategy,
                                                   org.opendaylight.yangtools.yang.model.api.SchemaContext ctx)
        Creates Binding Runtime Context from supplied class loading strategy and schema context.
        Parameters:
        strategy - Class loading strategy to retrieve generated Binding classes
        ctx - Schema Context which describes YANG model and to which Binding classes should be mapped
        Returns:
        Instance of BindingRuntimeContext for supplied schema context.
      • getStrategy

        public ClassLoadingStrategy getStrategy()
        Returns a class loading strategy associated with this binding runtime context which is used to load classes.
        Returns:
        Class loading strategy.
      • getSchemaContext

        public org.opendaylight.yangtools.yang.model.api.SchemaContext getSchemaContext()
        Returns an stable immutable view of schema context associated with this Binding runtime context.
        Returns:
        stable view of schema context
      • getAugmentationDefinition

        public @Nullable org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode getAugmentationDefinition​(Class<?> augClass)
        Returns schema of augmentation.

        Returned schema is schema definition from which augmentation class was generated. This schema is isolated from other augmentations. This means it contains augmentation definition as was present in original YANG module.

        Children of returned schema does not contain any additional augmentations, which may be present in runtime for them, thus returned schema is unsuitable for use for validation of data.

        For retrieving AugmentationSchemaNode, which will contains full model for child nodes, you should use method getResolvedAugmentationSchema(DataNodeContainer, Class) which will return augmentation schema derived from supplied augmentation target schema.

        Parameters:
        augClass - Augmentation class
        Returns:
        Schema of augmentation or null if augmentaiton is not known in this context
        Throws:
        IllegalArgumentException - If supplied class is not an augmentation
      • getSchemaDefinition

        public org.opendaylight.yangtools.yang.model.api.DataSchemaNode getSchemaDefinition​(Class<?> cls)
        Returns defining DataSchemaNode for supplied class.

        Returned schema is schema definition from which class was generated. This schema may be isolated from augmentations, if supplied class represent node, which was child of grouping or augmentation.

        For getting augmentation schema from augmentation class use getAugmentationDefinition(Class) instead.

        Parameters:
        cls - Class which represents list, container, choice or case.
        Returns:
        Schema node, from which class was generated.
      • getActionDefinition

        public org.opendaylight.yangtools.yang.model.api.ActionDefinition getActionDefinition​(Class<? extends Action<?,​?,​?>> cls)
      • getResolvedAugmentationSchema

        public Map.Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier,​org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode> getResolvedAugmentationSchema​(org.opendaylight.yangtools.yang.model.api.DataNodeContainer target,
                                                                                                                                                                                                                      Class<? extends Augmentation<?>> aug)
      • getCaseSchemaDefinition

        public Optional<org.opendaylight.yangtools.yang.model.api.CaseSchemaNode> getCaseSchemaDefinition​(org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode schema,
                                                                                                          Class<?> childClass)
        Returns resolved case schema for supplied class.
        Parameters:
        schema - Resolved parent choice schema
        childClass - Class representing case.
        Returns:
        Optionally a resolved case schema,.empty if the choice is not legal in the given context.
        Throws:
        IllegalArgumentException - If supplied class does not represent case.
      • getTypeWithSchema

        public Map.Entry<GeneratedType,​org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus> getTypeWithSchema​(Class<?> type)
        Returns schema (DataSchemaNode, AugmentationSchemaNode or TypeDefinition) from which supplied class was generated. Returned schema may be augmented with additional information, which was not available at compile type (e.g. third party augmentations).
        Parameters:
        type - Binding Class for which schema should be retrieved.
        Returns:
        Instance of generated type (definition of Java API), along with DataSchemaNode, AugmentationSchemaNode or TypeDefinition which was used to generate supplied class.
      • getChoiceCaseChildren

        public ImmutableMap<Type,​Map.Entry<Type,​Type>> getChoiceCaseChildren​(org.opendaylight.yangtools.yang.model.api.DataNodeContainer schema)
      • getEnumMapping

        public BiMap<String,​String> getEnumMapping​(Class<?> enumClass)
        Map enum constants: yang - java.
        Parameters:
        enumClass - enum generated class
        Returns:
        mapped enum constants from yang with their corresponding values in generated binding classes
      • getEnumMapping

        public BiMap<String,​String> getEnumMapping​(String enumClassName)
        Map enum constants: yang - java.
        Parameters:
        enumClassName - enum generated class name
        Returns:
        mapped enum constants from yang with their corresponding values in generated binding classes
      • getClassForSchema

        public Class<?> getClassForSchema​(org.opendaylight.yangtools.yang.model.api.SchemaNode childSchema)
      • getAvailableAugmentationTypes

        public ImmutableMap<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier,​Type> getAvailableAugmentationTypes​(org.opendaylight.yangtools.yang.model.api.DataNodeContainer container)
      • getIdentityClass

        public Class<?> getIdentityClass​(org.opendaylight.yangtools.yang.common.QName input)