Class SimpleTypeRegistry

  • All Implemented Interfaces:
    TypeRegistry, WritableTypeRegistry

    public class SimpleTypeRegistry
    extends BaseTypeRegistry
    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. Note that this registry does not handle situations where two programs with the same name exist with a type each with the same name.
    • Constructor Detail

      • SimpleTypeRegistry

        public SimpleTypeRegistry()
    • Method Detail

      • getDeclaredType

        @Nonnull
        public <T extends PDeclaredDescriptor<T>> T getDeclaredType​(@Nonnull
                                                                    java.lang.String typeName,
                                                                    @Nonnull
                                                                    java.lang.String programContext)
        Description copied from interface: TypeRegistry
        Get the declared type with the given name and program context.
        Type Parameters:
        T - The described type.
        Parameters:
        typeName - The type name.
        programContext - The program context of the type.
        Returns:
        The declared type descriptor.
      • getConstantValue

        @Nullable
        public <T> T getConstantValue​(@Nonnull
                                      java.lang.String constReference,
                                      @Nonnull
                                      java.lang.String programContext)
        Description copied from interface: TypeRegistry
        This is to check to find a constant given the const name and program context. This will return null if the constant does not exist.
        Type Parameters:
        T - The returned value type.
        Parameters:
        constReference - The reference to the constant.
        programContext - The current program context.
        Returns:
        The const value or null.
      • getService

        @Nonnull
        public PService getService​(java.lang.String serviceName,
                                   java.lang.String programContext)
        Description copied from interface: TypeRegistry
        Get a service definition from the name and program context.
        Parameters:
        serviceName - The service name.
        programContext - The program context name to get the service in.
        Returns:
        The service or null if not found.
      • registerConstant

        public void registerConstant​(@Nonnull
                                     java.lang.String identifier,
                                     @Nonnull
                                     java.lang.String program,
                                     @Nonnull
                                     java.lang.Object value)
        Description copied from interface: WritableTypeRegistry
        Register a constant value.
        Parameters:
        identifier - The constant identifier name.
        program - The program context for the constant.
        value - The parsed value.
      • register

        public boolean register​(@Nonnull
                                PService service)
        Description copied from interface: WritableTypeRegistry
        Services are not handled as "declared types", so they need to be registered separately.
        Parameters:
        service - the service to register.
        Returns:
        True if the service was registered and not already known.
      • register

        public <T> boolean register​(PDeclaredDescriptor<T> declaredType)
        Description copied from interface: WritableTypeRegistry
        Register a declared type.
        Type Parameters:
        T - The declared java type.
        Parameters:
        declaredType - The descriptor for the type.
        Returns:
        True if the type was registered