Class TypeRegistry

  • Direct Known Subclasses:
    WritableTypeRegistry

    public abstract class TypeRegistry
    extends java.lang.Object
    Base class for type registry. The type registry holds type information, possibly with some context, and has methods to get type information out from the registry.
    • Constructor Detail

      • TypeRegistry

        protected TypeRegistry()
    • Method Detail

      • getDeclaredType

        @Nonnull
        public abstract java.util.Optional<PDeclaredDescriptor<?>> getDeclaredType​(@Nonnull
                                                                                   TypeReference reference)
        Get the declared type with the given name and program context.
        Parameters:
        reference - The reference to the type.
        Returns:
        Optional type descriptor.
      • getService

        @Nonnull
        public abstract java.util.Optional<PService> getService​(@Nonnull
                                                                TypeReference reference)
        Get a service definition from the name and program context.
        Parameters:
        reference - The service reference.
        Returns:
        Optional service descriptor.
      • getConstantValue

        @Nonnull
        public abstract <T> java.util.Optional<T> getConstantValue​(@Nonnull
                                                                   TypeReference reference)
        This is to check to find a constant given the const name and program context. This will return empty if the constant does not exist.
        Type Parameters:
        T - The returned value type.
        Parameters:
        reference - The constant reference.
        Returns:
        The optional const value.
      • getTypedef

        @Nonnull
        public abstract java.util.Optional<TypeReference> getTypedef​(@Nonnull
                                                                     TypeReference reference)
        Get a type-definition for the given reference.
        Parameters:
        reference - The typedef reference.
        Returns:
        Optional typedef definition.
      • isKnownProgram

        public abstract boolean isKnownProgram​(@Nonnull
                                               java.lang.String program)
        Parameters:
        program - The program name.
        Returns:
        True if the program is known in this registry.
      • requireDeclaredType

        @Nonnull
        public PDeclaredDescriptor requireDeclaredType​(@Nonnull
                                                       TypeReference reference)
        Get the declared type with the given name and program context.
        Parameters:
        reference - The reference to the type.
        Returns:
        The declared type descriptor.
      • requireMessageType

        @Nonnull
        public <M extends PMessage<M>> PMessageDescriptor<M> requireMessageType​(@Nonnull
                                                                                TypeReference reference)
        Get the declared message type.
        Type Parameters:
        M - The message type.
        Parameters:
        reference - The type reference.
        Returns:
        The message type descriptor.
      • requireEnumType

        @Nonnull
        public <E extends PEnumValue<E>> PEnumDescriptor<E> requireEnumType​(@Nonnull
                                                                            TypeReference reference)
        Get the declared enum type.
        Type Parameters:
        E - The enum value type.
        Parameters:
        reference - The type reference.
        Returns:
        The enum type descriptor.
      • requireService

        @Nonnull
        public PService requireService​(@Nonnull
                                       TypeReference reference)
        Get the declared type with the given name and program context.
        Parameters:
        reference - The reference to the type.
        Returns:
        The service descriptor.
      • getTypeProvider

        @Nonnull
        public PDescriptorProvider getTypeProvider​(@Nonnull
                                                   TypeReference reference)
        Get a type provider for reference.
        Parameters:
        reference - Type reference to get provider for.
        Returns:
        The type provider.
      • getTypeProvider

        @Nonnull
        public PDescriptorProvider getTypeProvider​(@Nonnull
                                                   TypeReference reference,
                                                   @Nonnull
                                                   java.util.Map<java.lang.String,​java.lang.String> annotations)
      • finalTypeReference

        @Nonnull
        protected TypeReference finalTypeReference​(@Nonnull
                                                   TypeReference reference)
        Get the final typename of the given identifier within the context.
        Parameters:
        reference - The type name.
        Returns:
        The final type reference.