Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-1204

Do not subclass NamespaceBehaviour in NamespaceBehaviourWithListeners

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Medium Medium
    • 11.0.0
    • None
    • parser

      We currently allow, in theory at least, for an IdentifierNamespace to be serviced by differing behaviours. This facility is not used and realistically all behaviours are co-located with their namespaces.

      All lookups are also based on FooNamespace.class, which means do not pass anything useful beyond the identifier – and ends up being quite weird to use for newcomers. The reactor than has to perform a rather expensive (in relative terms) lookup to acquire the behaviour and execute on it. There is also the annoying matter of ensuring the behaviour registry is correctly populated.

      Introduce an parser.spi.meta.ParserIdentifierNamespace:

      public interface ParserNamespace {
      
          @NonNull NamespaceBehaviour behaviour();
      }
      

      as well as an AbstractParserNamespace to form the baseline for all implementations.

      Then turn all parser implementation namespaces into these, eliminating their respective BEHAVIOUR constants instread of singleton INSTANCEs. All callers need to be then converted to pass 'FooNamespace.INSTANCE' instread of 'FooNamespace.class' in their interactions.

      All of reactor mechanics need to be updated to eliminate the behaviour lookup and and instead just take the behaviour from the instance.

      This will eliminate a chunk of complexity, make things a bit easier to understand, but most importantly will eliminate map-based/recursive behaviour lookups.

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: