Class BaseTypeRegistry

  • All Implemented Interfaces:
    TypeRegistry, WritableTypeRegistry
    Direct Known Subclasses:
    SimpleTypeRegistry

    public abstract class BaseTypeRegistry
    extends java.lang.Object
    implements WritableTypeRegistry
    Registry for declared types referenced in a flat space program context. The registry itself does not have a context per se, as these may reference each other recursively.
    • Constructor Detail

      • BaseTypeRegistry

        protected BaseTypeRegistry()
    • Method Detail

      • registerTypedef

        public void registerTypedef​(@Nonnull
                                    java.lang.String identifier,
                                    @Nonnull
                                    java.lang.String program,
                                    @Nonnull
                                    java.lang.String target)
        Description copied from interface: WritableTypeRegistry
        Registers a typedef definition.
        Specified by:
        registerTypedef in interface WritableTypeRegistry
        Parameters:
        identifier - The typedef name (the alias) to put.
        program - The program context of the typedef.
        target - The qualified name that the name represents.
      • getProvider

        @Nonnull
        public PDescriptorProvider getProvider​(@Nonnull
                                               java.lang.String name,
                                               @Nonnull
                                               java.lang.String context,
                                               @Nullable
                                               java.util.Map<java.lang.String,java.lang.String> annotations)
        Description copied from interface: TypeRegistry
        Given a type name and a package context, fetches the type provider for the given type.
        Specified by:
        getProvider in interface TypeRegistry
        Parameters:
        name - Name of type, without any spaces.
        context - The program context of the reference.
        annotations - Annotations affecting the type.
        Returns:
        The type provider.
      • getServiceProvider

        @Nonnull
        public PServiceProvider getServiceProvider​(java.lang.String serviceName,
                                                   java.lang.String programContext)
        Description copied from interface: TypeRegistry
        Given a service name and program context, fetches the service provider for the given service.
        Specified by:
        getServiceProvider in interface TypeRegistry
        Parameters:
        serviceName - Name of the service.
        programContext - The program context of the reference.
        Returns:
        The service provider.
      • registerRecursively

        public void registerRecursively​(@Nonnull
                                        PService service)
        Description copied from interface: WritableTypeRegistry
        Register the service recursively. E.g. if the service extends a different service, make sure to register that service too.
        Specified by:
        registerRecursively in interface WritableTypeRegistry
        Parameters:
        service - the service to register.
      • registerRecursively

        public <T> void registerRecursively​(PDeclaredDescriptor<T> declaredType)
        Description copied from interface: WritableTypeRegistry
        Register a declared type recursively. If the type is a message, then iterate through the fields and register those types recursively.
        Specified by:
        registerRecursively in interface WritableTypeRegistry
        Type Parameters:
        T - The declared java type.
        Parameters:
        declaredType - The descriptor for the type.
      • finalTypename

        protected java.lang.String finalTypename​(java.lang.String typeName,
                                                 java.lang.String programContext)
        Get the final typename of the given identifier within the context.
        Parameters:
        typeName - The identifier name.
        programContext - The program context.
        Returns:
        The final typename.
      • qualifiedNameFromIdAndContext

        protected static java.lang.String qualifiedNameFromIdAndContext​(java.lang.String name,
                                                                        java.lang.String context)
        Make a qualified type name from a name identifier string and the program context.
        Parameters:
        name - The type name.
        context - The program context.
        Returns:
        The qualified name containing program name and type name.